Skip to content

Commit

Permalink
Fix E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed May 18, 2022
1 parent ba46940 commit 0ddd311
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ export default defineComponent({
return this.linkListCollapsed ? this.$gettext('Show more') : this.$gettext('Show less')
},
defaultNewLinkName() {
return this.$gettext('Link')
},
quicklink() {
return this.currentFileOutgoingLinks.find((link) => link.quicklink === true)
},
Expand Down Expand Up @@ -173,7 +169,6 @@ export default defineComponent({
label: this.$gettext(role.label)
}
})
// add empty permission link if oCIS for alias link
return [
// { role: null, name: 'Alias link', label: this.$gettext('Only invited people') },
Expand Down Expand Up @@ -238,10 +233,14 @@ export default defineComponent({
},
displayLinks() {
const linkShares = this.links
const sortedLinkShares = linkShares.sort((a, b) => {
return b.stime - a.stime
})
if (this.links.length > 3 && this.linkListCollapsed) {
return this.links.slice(0, 3)
return sortedLinkShares.slice(0, 3)
}
return this.links
return sortedLinkShares
},
indirectLinks() {
Expand Down Expand Up @@ -342,7 +341,7 @@ export default defineComponent({
addNewLink() {
this.createLink({
link: {
name: this.newLinkName,
name: this.$gettext('Link'),
role: this.availableRoleOptions[0],
expiration: this.expirationDate.default,
password: null
Expand Down
8 changes: 5 additions & 3 deletions tests/e2e/cucumber/features/integrations/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ Feature: link
| 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" creates a public link for the resource "folderPublic" using the sidebar panel
And "Alice" renames the most recently created public link of resource "folderPublic" to "myPublicLink"
And "Alice" edits the public link named "myPublicLink" of resource "folderPublic" changing role to "uploader"
And "Alice" sets the expiration date of the public link named "myPublicLink" of resource "folderPublic" to "+5 days"
And "Alice" sets the password of the public link named "myPublicLink" of resource "folderPublic" to "12345"
#Then "Alice" should see 1 public link
When "Anonymous" opens the public link "myPublicLink"
And "Anonymous" unlocks the public link with password "12345"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Feature: spaces.personal

Scenario: unstructured collection of testable space interactions,
once all needed features are there, split this into independent tests.
contains following features:
- ✓ assign role to user
- ✓ create space & internal alias to differentiate multiple spaces with the same name
- ✓ open space
- ✓ rename space
- ✓ change/set space subtitle
- ✓ change/set space description
- ✓ change/set space quota
- ✓ resources & existing resource actions
- ✗ change/set space image
- ✗ trash bin
- ✗ share
- ✗ link
once all needed features are there, split this into independent tests.
contains following features:
- ✓ assign role to user
- ✓ create space & internal alias to differentiate multiple spaces with the same name
- ✓ open space
- ✓ rename space
- ✓ change/set space subtitle
- ✓ change/set space description
- ✓ change/set space quota
- ✓ resources & existing resource actions
- ✗ change/set space image
- ✗ trash bin
- ✗ share
- ✗ link
Given "Admin" creates following users
| id |
| Alice |
Expand Down Expand Up @@ -47,10 +47,11 @@ Feature: spaces.personal
| lorem.txt | folderPublic |
| lorem.txt | folder_to_shared |

# borrowed from link.feature, all existing resource actions can be reused
When "Alice" creates a public link for the following resource using the sidebar panel
| resource | name | role | dateOfExpiration | password |
| folderPublic | team.1 | uploader | +5 days | 12345 |
And "Alice" creates a public link for the resource "folderPublic" using the sidebar panel
And "Alice" renames the most recently created public link of resource "folderPublic" to "team.1"
And "Alice" edits the public link named "team.1" of resource "folderPublic" changing role to "uploader"
And "Alice" sets the expiration date of the public link named "team.1" of resource "folderPublic" to "+5 days"
And "Alice" sets the password of the public link named "team.1" of resource "folderPublic" to "12345"

# borrowed from share.feature
When "Alice" shares the following resource using the sidebar panel
Expand All @@ -65,16 +66,18 @@ Feature: spaces.personal
And "Alice" updates the space "team.2" description to "management team - description"
And "Alice" updates the space "team.2" quota to "500"

# borrowed from link.feature, all existing resource actions can be reused
And "Alice" creates the following resources
| resource | type |
| folderPublic | folder |
And "Alice" uploads the following resources
| resource | to |
| lorem.txt | folderPublic |
When "Alice" creates a public link for the following resource using the sidebar panel
| resource | name | role | dateOfExpiration | password |
| folderPublic | team.2 | uploader | +5 days | 54321 |

And "Alice" creates a public link for the resource "folderPublic" using the sidebar panel
And "Alice" renames the most recently created public link of resource "folderPublic" to "team.2"
And "Alice" edits the public link named "team.2" of resource "folderPublic" changing role to "uploader"
And "Alice" sets the expiration date of the public link named "team.2" of resource "folderPublic" to "+5 days"
And "Alice" sets the password of the public link named "team.2" of resource "folderPublic" to "54321"

# borrowed from link.feature, all existing resource actions can be reused
When "Anonymous" opens the public link "team.1"
Expand All @@ -91,18 +94,18 @@ Feature: spaces.personal
| name |
| folder_to_shared |
And "Brian" renames the following resource
| resource | as |
| resource | as |
| folder_to_shared/lorem.txt | lorem_new.txt |
And "Brian" uploads the following resource
| resource | to |
| resource | to |
| simple.pdf | folder_to_shared |
And "Alice" navigates to the projects space page
And "Alice" navigates to the project space "team.1"
And "Alice" uploads the following resource
| resource | to | create_version |
| PARENT/simple.pdf | folder_to_shared | true |
When "Brian" restores following resources
| resource | to | version |
| resource | to | version |
| simple.pdf | folder_to_shared | 1 |
When "Alice" deletes the following resources
| resource |
Expand Down
62 changes: 44 additions & 18 deletions tests/e2e/cucumber/steps/app-files/link.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
import { DataTable, When } from '@cucumber/cucumber'
import { When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import { World } from '../../environment'
import { objects } from '../../../support'

When(
/^"([^"]*)" creates a public link for the following resource(s)? using the (sidebar panel|quick action)$/,
'{string} creates a public link for the resource {string} using the sidebar panel',
async function (this: World, stepUser: string, resource: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const linkObject = new objects.applicationFiles.Link({ page })
await linkObject.create({
resource,
name: 'Link'
})
}
)

When(
'{string} renames the most recently created public link of resource {string} to {string}',
async function (this: World, stepUser: string, resource: string, newName: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const linkObject = new objects.applicationFiles.Link({ page })
const linkName = await linkObject.changeName({ resource, newName })
expect(newName).toBe(linkName)
}
)

When(
'{string} sets the expiration date of the public link named {string} of resource {string} to {string}',
async function (
this: World,
stepUser: string,
_: string,
actionType: string,
stepTable: DataTable
) {
linkName: string,
resource: string,
expireDate: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const linkObject = new objects.applicationFiles.Link({ page })
await linkObject.addExpiration({ resource, linkName, expireDate })
}
)

When(
'{string} sets the password of the public link named {string} of resource {string} to {string}',
async function (
this: World,
stepUser: string,
linkName: string,
resource: string,
newPassword: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const linkObject = new objects.applicationFiles.Link({ page })
const shareInfo = stepTable.hashes()
for (const linkShare of shareInfo) {
const { resource, name, role, dateOfExpiration, password } = linkShare
await linkObject.create({
resource,
name,
role,
dateOfExpiration,
password,
via: actionType === 'quick action' ? 'QUICK_ACTION' : 'SIDEBAR_PANEL'
})
}
await linkObject.addPassword({ resource, linkName, newPassword })
}
)

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/steps/app-files/page/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ When(
}

const { page } = actor
const { url } = this.linksEnvironment.getLink({ key: name })
const { url } = this.linksEnvironment.getLink({ name })
const pageObject = new objects.applicationFiles.page.Public({ page })
await pageObject.open({ url })
}
Expand Down
17 changes: 11 additions & 6 deletions tests/e2e/support/environment/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ import { Link } from '../types'
import { linkStore } from '../store'

export class LinksEnvironment {
getLink({ key }: { key: string }): Link {
if (!linkStore.has(key)) {
throw new Error(`link with key '${key}' not found`)
getLink({ name }: { name: string }): Link {
if (!linkStore.has(name)) {
throw new Error(`link with name '${name}' not found`)
}
return linkStore.get(name)
}

return linkStore.get(key)
updateLinkName({ key, link }: { key: string; link: Link }): any {
if (!linkStore.has(key)) {
throw new Error(`link with name '${key}' not found`)
}
linkStore.set(link.name, link)
linkStore.delete(key)
}

createLink({ key, link }: { key: string; link: Link }): Link {
if (linkStore.has(key)) {
throw new Error(`link with key '${key}' already exists`)
}

linkStore.set(key, link)

return link
}

Expand Down
Loading

0 comments on commit 0ddd311

Please sign in to comment.