Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
143ad6d
Spike AXE A11Y testing in Cypress
t3chguy Jul 27, 2022
7347ac0
Fix NewRoomIntro breaking html/aria list rules
t3chguy Jul 28, 2022
0d1dc82
Fix HeaderButtons breaking aria role semantics rules
t3chguy Jul 28, 2022
c00548c
missing type
t3chguy Jul 28, 2022
b4b516c
Switch left panel from aside to nav and include space panel
t3chguy Jul 28, 2022
1cc238b
Give the page a main heading of the room name when viewing a room
t3chguy Jul 28, 2022
a1f4ec0
Use header landmark on RoomHeader
t3chguy Jul 28, 2022
55532c9
Improve aria attributes on composer when autocomplete is closed
t3chguy Jul 28, 2022
7dea9b0
Fix aria-owns on RoomHeader
t3chguy Jul 28, 2022
20737ab
Give Spinner an aria role
t3chguy Jul 28, 2022
415cb0b
Give server picker help button an aria label
t3chguy Jul 28, 2022
324b899
Improve auth aria attributes and semantics
t3chguy Jul 28, 2022
95e0066
Improve heading semantics in use case selection screen
t3chguy Jul 28, 2022
e5927b5
Fix autocomplete attribute to be valid
t3chguy Jul 28, 2022
f99f7c0
Fix heading semantics on login page
t3chguy Jul 28, 2022
ca65131
Improve Cypress axe testing
t3chguy Jul 28, 2022
2e3b9bb
Add axe tests
t3chguy Jul 28, 2022
0c4526f
Stop synapse after the timeline tests
t3chguy Jul 28, 2022
d8d5eac
Await spinners to fade before percy snapshotting timeline tests
t3chguy Jul 28, 2022
222a024
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Jul 28, 2022
1ff21a1
Improve naming of plugin
t3chguy Jul 28, 2022
78f8581
Update snapshots
t3chguy Jul 28, 2022
30621ac
Fix accidental heading change
t3chguy Jul 28, 2022
69d527e
Fix double synapse stoppage
t3chguy Jul 28, 2022
5a81dbb
Fix Cypress timeline avatar assertions to be DPI agnostic
t3chguy Jul 29, 2022
3275bf9
Fix aria attributes on date separators
t3chguy Jul 29, 2022
bf88ed9
delint
t3chguy Jul 29, 2022
173bde7
Update snapshots
t3chguy Jul 29, 2022
30edbee
Revert style change
t3chguy Jul 29, 2022
5d040c3
Skip redundant call
t3chguy Jul 29, 2022
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
9 changes: 9 additions & 0 deletions cypress/e2e/1-register/register.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ describe("Registration", () => {
});

it("registers an account and lands on the home screen", () => {
cy.injectAxe();

cy.get(".mx_ServerPicker_change", { timeout: 15000 }).click();
cy.get(".mx_ServerPickerDialog_continue").should("be.visible");
cy.percySnapshot("Server Picker");
cy.checkA11y();

cy.get(".mx_ServerPickerDialog_otherHomeserver").type(synapse.baseUrl);
cy.get(".mx_ServerPickerDialog_continue").click();
Expand All @@ -46,6 +49,7 @@ describe("Registration", () => {
// Hide the server text as it contains the randomly allocated Synapse port
const percyCSS = ".mx_ServerPicker_server { visibility: hidden !important; }";
cy.percySnapshot("Registration", { percyCSS });
cy.checkA11y();

cy.get("#mx_RegistrationForm_username").type("alice");
cy.get("#mx_RegistrationForm_password").type("totally a great password");
Expand All @@ -55,16 +59,21 @@ describe("Registration", () => {

cy.get(".mx_RegistrationEmailPromptDialog").should("be.visible");
cy.percySnapshot("Registration email prompt", { percyCSS });
cy.checkA11y();
cy.get(".mx_RegistrationEmailPromptDialog button.mx_Dialog_primary").click();

cy.stopMeasuring("create-account");
cy.get(".mx_InteractiveAuthEntryComponents_termsPolicy").should("be.visible");
cy.percySnapshot("Registration terms prompt", { percyCSS });
cy.checkA11y();

cy.get(".mx_InteractiveAuthEntryComponents_termsPolicy input").click();
cy.startMeasuring("from-submit-to-home");
cy.get(".mx_InteractiveAuthEntryComponents_termsSubmit").click();

cy.get(".mx_UseCaseSelection_skip").should("exist");
cy.percySnapshot("Use-case selection screen");
cy.checkA11y();
cy.get(".mx_UseCaseSelection_skip .mx_AccessibleButton").click();

cy.url().should('contain', '/#/home');
Expand Down
30 changes: 19 additions & 11 deletions cypress/e2e/14-timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { MessageEvent } from "matrix-events-sdk";

import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import type { EventType } from "matrix-js-sdk/src/@types/event";
import type { MatrixClient } from "matrix-js-sdk/src/client";
import { SynapseInstance } from "../../plugins/synapsedocker";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { Layout } from "../../../src/settings/enums/Layout";
Expand All @@ -46,10 +45,14 @@ const expectDisplayName = (e: JQuery<HTMLElement>, displayName: string): void =>
};

const expectAvatar = (e: JQuery<HTMLElement>, avatarUrl: string): void => {
cy.getClient().then((cli: MatrixClient) => {
cy.all([
cy.window({ log: false }),
cy.getClient(),
]).then(([win, cli]) => {
const size = AVATAR_SIZE * win.devicePixelRatio;
expect(e.find(".mx_BaseAvatar_image").attr("src")).to.equal(
// eslint-disable-next-line no-restricted-properties
cli.mxcUrlToHttp(avatarUrl, AVATAR_SIZE, AVATAR_SIZE, AVATAR_RESIZE_METHOD),
cli.mxcUrlToHttp(avatarUrl, size, size, AVATAR_RESIZE_METHOD),
);
});
};
Expand All @@ -75,15 +78,17 @@ describe("Timeline", () => {
cy.startSynapse("default").then(data => {
synapse = data;
cy.initTestUser(synapse, OLD_NAME).then(() =>
cy.window({ log: false }).then(() => {
cy.createRoom({ name: ROOM_NAME }).then(_room1Id => {
roomId = _room1Id;
});
cy.createRoom({ name: ROOM_NAME }).then(_room1Id => {
roomId = _room1Id;
}),
);
});
});

afterEach(() => {
cy.stopSynapse(synapse);
});

describe("useOnlyCurrentProfiles", () => {
beforeEach(() => {
cy.uploadContent(OLD_AVATAR).then((url) => {
Expand All @@ -95,10 +100,6 @@ describe("Timeline", () => {
});
});

afterEach(() => {
cy.stopSynapse(synapse);
});

it("should show historical profiles if disabled", () => {
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, false);
sendEvent(roomId);
Expand Down Expand Up @@ -146,11 +147,16 @@ describe("Timeline", () => {
});

describe("message displaying", () => {
beforeEach(() => {
cy.injectAxe();
});

it("should create and configure a room on IRC layout", () => {
cy.visit("/#/room/" + roomId);
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary[data-layout=irc] " +
".mx_GenericEventListSummary_summary", "created and configured the room.");
cy.get(".mx_Spinner").should("not.exist");
cy.percySnapshot("Configured room on IRC layout");
});

Expand All @@ -174,10 +180,12 @@ describe("Timeline", () => {
.should('have.css', "margin-inline-start", "104px")
.should('have.css', "inset-inline-start", "0px");

cy.get(".mx_Spinner").should("not.exist");
// Exclude timestamp from snapshot
const percyCSS = ".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp "
+ "{ visibility: hidden !important; }";
cy.percySnapshot("Event line with inline start margin on IRC layout", { percyCSS });
cy.checkA11y();
});

it("should click top left of view source event toggle", () => {
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/2-login/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ describe("Login", () => {
});

it("logs in with an existing account and lands on the home screen", () => {
cy.injectAxe();

cy.get("#mx_LoginForm_username", { timeout: 15000 }).should("be.visible");
cy.percySnapshot("Login");
cy.checkA11y();

cy.get(".mx_ServerPicker_change").click();
cy.get(".mx_ServerPickerDialog_otherHomeserver").type(synapse.baseUrl);
Expand Down
2 changes: 2 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { performance } from "./performance";
import { synapseDocker } from "./synapsedocker";
import { webserver } from "./webserver";
import { docker } from "./docker";
import { log } from "./log";

/**
* @type {Cypress.PluginConfig}
Expand All @@ -31,4 +32,5 @@ export default function(on: PluginEvents, config: PluginConfigOptions) {
performance(on, config);
synapseDocker(on, config);
webserver(on, config);
log(on, config);
}
35 changes: 35 additions & 0 deletions cypress/plugins/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/// <reference types="cypress" />

import PluginEvents = Cypress.PluginEvents;
import PluginConfigOptions = Cypress.PluginConfigOptions;

export function log(on: PluginEvents, config: PluginConfigOptions) {
on("task", {
log(message: string) {
console.log(message);

return null;
},
table(message: string) {
console.table(message);

return null;
},
});
}
61 changes: 61 additions & 0 deletions cypress/support/axe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/// <reference types="cypress" />

import "cypress-axe";
import * as axe from "axe-core";
import { Options } from "cypress-axe";

import Chainable = Cypress.Chainable;

function terminalLog(violations: axe.Result[]): void {
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`,
);

// pluck specific keys to keep the table readable
const violationData = violations.map(({ id, impact, description, nodes }) => ({
id,
impact,
description,
nodes: nodes.length,
}));

cy.task('table', violationData);
}

Cypress.Commands.overwrite("checkA11y", (
originalFn: Chainable["checkA11y"],
context?: string | Node | axe.ContextObject | undefined,
options: Options = {},
violationCallback?: ((violations: axe.Result[]) => void) | undefined,
skipFailures?: boolean,
): void => {
return originalFn(context, {
...options,
rules: {
// Disable contrast checking for now as we have too many issues with it
'color-contrast': {
enabled: false,
},
...options.rules,
},
}, violationCallback ?? terminalLog, skipFailures);
});
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ import "./iframes";
import "./timeline";
import "./network";
import "./composer";
import "./axe";
6 changes: 5 additions & 1 deletion cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"dom",
"dom.iterable"
],
"types": ["cypress", "@percy/cypress"],
"types": [
"cypress",
"cypress-axe",
"@percy/cypress"
],
"resolveJsonModule": true,
"esModuleInterop": true,
"moduleResolution": "node",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@
"@typescript-eslint/parser": "^5.6.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
"allchange": "^1.0.6",
"axe-core": "^4.4.3",
"babel-jest": "^26.6.3",
"blob-polyfill": "^6.0.20211015",
"chokidar": "^3.5.1",
"cypress": "^10.3.0",
"cypress-axe": "^1.0.0",
"cypress-real-events": "^1.7.1",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
Expand Down
10 changes: 5 additions & 5 deletions res/css/views/auth/_AuthBody.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ limitations under the License.
flex-direction: column;
}

h2 {
h1 {
font-size: $font-24px;
font-weight: 600;
font-weight: $font-semi-bold;
margin-top: 8px;
color: $authpage-primary-color;
}

h3 {
h2 {
font-size: $font-14px;
font-weight: 600;
font-weight: $font-semi-bold;
color: $authpage-secondary-color;
}

h3.mx_AuthBody_centered {
h2.mx_AuthBody_centered {
text-align: center;
}

Expand Down
4 changes: 2 additions & 2 deletions res/css/views/dialogs/_ServerPickerDialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ limitations under the License.
}
}

> h4 {
> h2 {
font-size: $font-15px;
font-weight: $font-semi-bold;
color: $secondary-content;
margin-left: 8px;
margin: 16px 0 16px 8px;
}

> a {
Expand Down
2 changes: 1 addition & 1 deletion res/css/views/elements/_ServerPicker.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ limitations under the License.
font-size: $font-14px;
line-height: $font-20px;

> h3 {
> h2 {
font-weight: $font-semi-bold;
margin: 0 0 20px;
grid-column: 1;
Expand Down
2 changes: 1 addition & 1 deletion res/css/views/elements/_UseCaseSelection.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ limitations under the License.
text-align: center;
}

h4 {
h3 {
margin: 0;
font-weight: 400;
font-size: $font-16px;
Expand Down
5 changes: 4 additions & 1 deletion res/css/views/messages/_DateSeparator.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ limitations under the License.
border-bottom: 1px solid $menu-selected-color;
}

.mx_DateSeparator > div {
.mx_DateSeparator > h2 {
margin: 0 25px;
flex: 0 0 auto;
font-size: inherit;
font-weight: inherit;
color: inherit;
}

.mx_DateSeparator_jumpToDateMenu {
Expand Down
4 changes: 2 additions & 2 deletions src/components/structures/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {

return (
<div className={containerClasses}>
<aside className="mx_LeftPanel_roomListContainer">
<div className="mx_LeftPanel_roomListContainer">
{ this.renderSearchDialExplore() }
{ this.renderBreadcrumbs() }
{ !this.props.isMinimized && (
Expand All @@ -401,7 +401,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
{ roomList }
</div>
</div>
</aside>
</div>
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ class LoggedInView extends React.Component<IProps, IState> {
<div className={bodyClasses}>
<div className='mx_LeftPanel_outerWrapper'>
<LeftPanelLiveShareWarning isMinimized={this.props.collapseLhs || false} />
<div className='mx_LeftPanel_wrapper'>
<nav className='mx_LeftPanel_wrapper'>
<BackdropPanel
blurMultiplier={0.5}
backgroundImage={this.state.backgroundImage}
Expand All @@ -693,7 +693,7 @@ class LoggedInView extends React.Component<IProps, IState> {
resizeNotifier={this.props.resizeNotifier}
/>
</div>
</div>
</nav>
</div>
<ResizeHandle passRef={this.resizeHandler} id="lp-resizer" />
<div className="mx_RoomView_wrapper">
Expand Down
Loading