Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tests/e2e/features/smoke/sse.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Feature: server sent events
| item-trashed | x |
| item-restored | x |
| item-moved | x |
| item-favorite-added | x |
| item-favorite-removed | x |
| folder-created | x |
| space-created | x |
| space-member-added | x |
| space-member-removed | x |
| space-share-updated | x |
Expand Down Expand Up @@ -45,6 +48,9 @@ Feature: server sent events
| name | id |
| Marketing | marketing |

# space-created
Then "Alice" should get "space-created" SSE event

# space-member-added
When "Alice" adds the following member to the space "Marketing" using API
| user | role | shareType |
Expand Down Expand Up @@ -285,3 +291,44 @@ Feature: server sent events

And "Brian" logs out
And "Alice" logs out

@webkit-skip
Scenario: favorite sse events update the favorites view across tabs
Given "Alice" creates the following file into personal space using API
| pathToFile | content |
| example.txt | lorem ipsum |
And "Alice" logs in

# tab 2. open the favorites page in the second tab
And "Alice" opens a new tab
And "Alice" navigates to the favorites page
And following resource should not be displayed in the files list for user "Alice"
| resource |
| example.txt |

# tab 1. item-favorite-added - mark as favorite
When "Alice" switches to tab 1
And "Alice" marks the following resource as favorite using "context menu"
| resource |
| example.txt |
Then "Alice" should get "item-favorite-added" SSE event

# tab 2 check that the resource is displayed without a reload
When "Alice" switches to tab 2
Then following resource should be displayed in the files list for user "Alice"
| resource |
| example.txt |

# tab 1. item-favorite-removed - unmark as favorite
When "Alice" switches to tab 1
And "Alice" removes the following resource from favorites using "context menu"
| resource |
| example.txt |
Then "Alice" should get "item-favorite-removed" SSE event

# tab 2 check that the resource is not displayed without a reload
When "Alice" switches to tab 2
Then following resource should not be displayed in the files list for user "Alice"
| resource |
| example.txt |
And "Alice" logs out
18 changes: 18 additions & 0 deletions tests/e2e/steps/ui/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ When(
}
)

When(
'{string} opens a new tab',
async function ({ world }: { world: World }, stepUser: string): Promise<void> {
const actor = world.actorsEnvironment.getActor({ key: stepUser })
await actor.newTab()
await actor.page.goto(appConfig.baseUrl)
await actor.page.locator('#web-content').waitFor()
}
)

When(
'{string} switches to tab {int}',
async function ({ world }: { world: World }, stepUser: string, tab: number): Promise<void> {
const actor = world.actorsEnvironment.getActor({ key: stepUser })
await actor.switchTab(tab - 1)
}
)

When(
'{string} closes the current tab',
async function ({ world }: { world: World }, stepUser: string): Promise<void> {
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/support/environment/actor/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export class ActorEnvironment extends EventEmitter implements Actor {
return page
}

public async switchTab(index: number): Promise<Page> {
const page = this.tabs[index]
if (!page) {
throw new Error(`No tab found at index ${index}. Open tabs: ${this.tabs.length}`)
}
this.page = page
await page.bringToFront()
return page
}

public async closeCurrentTab(): Promise<void> {
await this.page.close()
this.tabs.pop()
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/support/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Actor {
close(): Promise<void>
savePage(page: Page): void
newTab(): Promise<Page>
switchTab(index: number): Promise<Page>
closeCurrentTab(): Promise<void>
}

Expand Down