Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
Signed-off-by: Swikriti Tripathi <[email protected]>
  • Loading branch information
SwikritiT committed Apr 4, 2022
1 parent 1b27d77 commit 3bec9d6
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 100 deletions.
8 changes: 4 additions & 4 deletions tests/e2e/cucumber/features/integrations/link.oc10.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
Feature: link

# batch action download isn't available in oc10 yet
# when the feature is implemented use the scenario above
@issue-6239
Scenario: public link in oc10
Given the following users have been created
Given "Admin" creates following users
| id |
| Alice |
When "Alice" logs in
Expand All @@ -20,7 +18,6 @@ Feature: link
And "Alice" creates a public link for the following resource using the sidebar panel
| resource | name | role | dateOfExpiration | password |
| folderPublic | myPublicLink | uploader | +5 days | 12345 |
And "Alice" logs out
# Then "Alice" should see 1 public link
When "Anonymous" opens the public link "myPublicLink"
And "Anonymous" unlocks the public link with password "12345"
Expand All @@ -35,3 +32,6 @@ Feature: link
# Then the public should not see the following files on the files-drop page
# | textfile.txt |
And "Anonymous" logs out
When "Alice" edits the public link named "myPublicLink" of file "folderPublic" changing following
| role |
| editor |
40 changes: 0 additions & 40 deletions tests/e2e/cucumber/features/integrations/link.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,3 @@ Feature: link
And "Alice" edits the public link named "myPublicLink" of file "folderPublic" changing following
| role |
| editor |

# batch action download isn't available in oc10 yet
# when the feature is implemented use the scenario above
@issue-6239 @skipOnOCIS
Scenario: public link in oc10
Given the following users have been created
| id |
| Alice |
When "Alice" logs in
And "Alice" opens the "files" app
And "Alice" creates the following resources
| resource | type |
| folderPublic | folder |
And "Alice" uploads the following resources
| resource | to |
| lorem.txt | folderPublic |
# Then "Alice" should see the following resource
# | folderPublic/lorem.txt |
And "Alice" creates a public link for the following resource using the sidebar panel
| resource | name | role | dateOfExpiration | password |
| folderPublic | myPublicLink | uploader | +5 days | 12345 |
And "Alice" logs out
# Then "Alice" should see 1 public link
When "Anonymous" opens the public link "myPublicLink"
And "Anonymous" unlocks the public link with password "12345"
# Then the public should not see the following resource
# | lorem.txt |
And "Anonymous" drop uploads following resources
| resource |
| textfile.txt |
# Then the public should see the following files on the files-drop page
# | textfile.txt |
# When the public reloads the public link pages
# Then the public should not see the following files on the files-drop page
# | textfile.txt |
And "Anonymous" logs out
When "Alice" logs in
And "Alice" edits the public link named "myPublicLink" of file "folderPublic" changing following
| role |
| editor |
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/steps/app-files/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ When(
resource: string,
stepTable: DataTable
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ id: stepUser })
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const linkObject = new objects.applicationFiles.Link({ page })
const editInfo = stepTable.hashes()
for (const linkEdit of editInfo) {
Expand Down
30 changes: 0 additions & 30 deletions tests/e2e/cucumber/steps/app-files/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,6 @@ When(
}
)

When(
'{string} downloads the following file(s) using batch action',
async function (this: World, stepUser: string, stepTable: DataTable) {
const { page } = this.actorsEnvironment.getActor({ id: stepUser })
let downloads
const resourceObject = new objects.applicationFiles.Resource({ page })
const downloadInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { resource, from } = stepRow

if (!acc[from]) {
acc[from] = []
}

acc[from].push(resource)

return acc
}, {})

for (const folder of Object.keys(downloadInfo)) {
const files = downloadInfo[folder]
downloads = await resourceObject.downloadFilesBatchAction({ folder, names: files })
}

expect(downloads.length).toBe(1)
downloads.forEach((download) => {
expect(download.suggestedFilename()).toBe('download.tar')
})
}
)

When(
'{string} renames the following resource(s)',
async function (this: World, stepUser: string, stepTable: DataTable) {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/environment/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class LinksEnvironment {
return linkStore.get(key)
}

createLink({ key, link }: { key: string; link: Link }): Link {
storeLink({ key, link }: { key: string; link: Link }): Link {
if (linkStore.has(key)) {
throw new Error(`link with key '${key}' already exists`)
}
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/support/objects/app-files/link/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type editLinkArgs = {
password: string
}

const fillPublicLinK = async (page, name, role, dateOfExpiration, password): Promise<void> => {
const fillPublicLink = async (page, name, role, dateOfExpiration, password): Promise<void> => {
if (name) {
await page.locator('#oc-files-file-link-name').fill(name)
}
Expand Down Expand Up @@ -79,7 +79,7 @@ export const createLink = async (args: createLinkArgs): Promise<string> => {
break
}
await page.locator('#files-file-link-add').click()
await fillPublicLinK(page, name, role, dateOfExpiration, password)
await fillPublicLink(page, name, role, dateOfExpiration, password)
await page.locator('#oc-files-file-link-create').click()
return await page
.locator(`//ul/li//h5[contains(text(),'${name}')]/following-sibling::div/a`)
Expand All @@ -106,7 +106,7 @@ export const editLink = async (args: editLinkArgs): Promise<string> => {
if (newName) {
name = newName
}
await fillPublicLinK(page, name, role, dateOfExpiration, password)
await fillPublicLink(page, name, role, dateOfExpiration, password)
await page.locator('#oc-files-file-link-save').click()
return await page
.locator(`//ul/li//h5[contains(text(),'${name}')]/following-sibling::div/a`)
Expand Down
20 changes: 8 additions & 12 deletions tests/e2e/support/objects/app-files/link/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page } from 'playwright'
import {createLink, editLink, createLinkArgs, editLinkArgs} from './actions'
import { createLink, editLink, createLinkArgs, editLinkArgs } from './actions'
import { LinksEnvironment } from '../../../environment'

export class Link {
Expand All @@ -15,7 +15,7 @@ export class Link {
const startUrl = this.#page.url()
const url = await createLink({ ...args, page: this.#page })

this.#linksEnvironment.createLink({
this.#linksEnvironment.storeLink({
key: args.name,
link: { name: args.name, url, password: args.password }
})
Expand All @@ -25,16 +25,12 @@ export class Link {

async edit(args: Omit<editLinkArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
let name = args.oldName
const url = await editLink({ page: this.#page, ...args })
this.#linksEnvironment.createLink({
key: args.name,
link: { name: args.name, url, password: args.password }

this.#linksEnvironment.storeLink({
key: args.newName,
link: { name: args.newName, url, password: args.password }
})
// if (args.newName) {
// name = args.newName
// }
// linkStore.set(name, { name: name, url, password: args.password })
// await this.#page.goto(startUrl)
// }
await this.#page.goto(startUrl)
}
}
9 changes: 0 additions & 9 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
createResourceArgs,
deleteResource,
deleteResourceArgs,
downloadResourceBatchAction,
downloadResources,
downloadResourcesArgs,
moveOrCopyResource,
Expand Down Expand Up @@ -47,14 +46,6 @@ export class Resource {
return downloads
}

async downloadFilesBatchAction(args: Omit<downloadResourcesArgs, 'page'>): Promise<Download[]> {
const startUrl = this.#page.url()
const downloads = await downloadResourceBatchAction({ page: this.#page, ...args })
await this.#page.goto(startUrl)

return downloads
}

async rename(args: Omit<renameResourceArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await renameResource({ ...args, page: this.#page })
Expand Down

0 comments on commit 3bec9d6

Please sign in to comment.