Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Weimann <michael.weimann@nordeck.net>
  • Loading branch information
weeman1337 committed Nov 15, 2024
1 parent 8b4c603 commit cbe9968
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
3 changes: 2 additions & 1 deletion e2e/src/deploy/elementWeb/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"default_country_code": "GB",
"show_labs_settings": false,
"features": {
"feature_ask_to_join": true
"feature_ask_to_join": true,
"feature_release_announcement": false
},
"default_federate": true,
"default_theme": "light",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[
{
"rule": "color-contrast",
"description": "Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds",
"rule": "color-contrast-enhanced",
"description": "Ensures the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds",
"targets": [
{
"target": [
".mx_RoomSearch_spotlightTriggerText"
],
"failureSummary": "Fix any of the following:\n Element has insufficient color contrast of 3.5 (foreground color: #6c737e, background color: #d8dde4, font size: 9.8pt (13px), font weight: normal). Expected contrast ratio of 4.5:1"
},
"failureSummary": "Fix any of the following:\n Element has insufficient color contrast of 6.5 (foreground color: #474a51, background color: #d8dde4, font size: 9.8pt (13px), font weight: normal). Expected contrast ratio of 7:1"
}
]
},
{
"rule": "color-contrast",
"description": "Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds",
"targets": [
{
"target": [
"kbd"
Expand Down
27 changes: 16 additions & 11 deletions e2e/src/pages/elementWebPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class ElementWebPage {
private readonly startChatButton: Locator;

constructor(private readonly page: Page) {
this.navigationRegion = page.getByRole('navigation');
this.mainRegion = page.getByRole('main');
this.navigationRegion = page.locator('.mx_LeftPanel_wrapper');
this.mainRegion = page.locator('.mx_RoomView_wrapper');
this.headerRegion = this.mainRegion.locator('header');
this.sendMessageTextbox = page.getByRole('textbox', { name: /message…/ });
this.roomNameText = this.headerRegion.getByRole('heading');
Expand Down Expand Up @@ -140,7 +140,11 @@ export class ElementWebPage {
}

async toggleRoomInfo() {
await this.headerRegion.getByRole('button', { name: 'Room info' }).click();
// nth(1) targets the (i) button in the room header
await this.headerRegion
.getByRole('button', { name: 'Room info' })
.first()
.click();
}

async sendMessage(message: string) {
Expand All @@ -157,15 +161,10 @@ export class ElementWebPage {
await this.sendMessage(`/addwidget ${url}`);

await this.toggleRoomInfo();
await this.page
.getByRole('button', { name: 'Custom' })
.locator('..')
.getByRole('button', { name: 'Pin' })
.click();
await this.page.getByRole('menuitem', { name: 'Extensions' }).click();
await this.page.getByRole('button', { name: 'Pin' }).click();

await this.page
.getByRole('button', { name: 'Set my room layout for everyone' })
.click();
await this.page.getByText('Set layout for everyone').click();
}

async inviteUser(username: string) {
Expand Down Expand Up @@ -244,6 +243,12 @@ export class ElementWebPage {
{ synapseUrl, credentials },
);

// Bypass the unsupported browser toast by setting a local storage key
// https://github.com/element-hq/element-web/blob/9a126795a81d13aba2d331b38df75878682d54a1/src/SupportedBrowser.ts#L94
await this.page.evaluate(() => {
window.localStorage.setItem('mx_accepts_unsupported_browser', 'true');
});

// Reload and use the credentials
await this.page.goto(getElementWebUrl());

Expand Down

0 comments on commit cbe9968

Please sign in to comment.