Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7be8064

Browse files
authored
Merge branch 'develop' into weeman1337/dm-bot-fix
2 parents 0a4c240 + d5db131 commit 7be8064

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+565
-87
lines changed

cypress/e2e/1-register/register.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ describe("Registration", () => {
3333
});
3434

3535
it("registers an account and lands on the home screen", () => {
36+
cy.injectAxe();
37+
3638
cy.get(".mx_ServerPicker_change", { timeout: 15000 }).click();
3739
cy.get(".mx_ServerPickerDialog_continue").should("be.visible");
3840
cy.percySnapshot("Server Picker");
41+
cy.checkA11y();
3942

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

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

5660
cy.get(".mx_RegistrationEmailPromptDialog").should("be.visible");
5761
cy.percySnapshot("Registration email prompt", { percyCSS });
62+
cy.checkA11y();
5863
cy.get(".mx_RegistrationEmailPromptDialog button.mx_Dialog_primary").click();
5964

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

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

74+
cy.get(".mx_UseCaseSelection_skip").should("exist");
75+
cy.percySnapshot("Use-case selection screen");
76+
cy.checkA11y();
6877
cy.get(".mx_UseCaseSelection_skip .mx_AccessibleButton").click();
6978

7079
cy.url().should('contain', '/#/home');

cypress/e2e/14-timeline/timeline.spec.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { MessageEvent } from "matrix-events-sdk";
2020

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

4847
const expectAvatar = (e: JQuery<HTMLElement>, avatarUrl: string): void => {
49-
cy.getClient().then((cli: MatrixClient) => {
48+
cy.all([
49+
cy.window({ log: false }),
50+
cy.getClient(),
51+
]).then(([win, cli]) => {
52+
const size = AVATAR_SIZE * win.devicePixelRatio;
5053
expect(e.find(".mx_BaseAvatar_image").attr("src")).to.equal(
5154
// eslint-disable-next-line no-restricted-properties
52-
cli.mxcUrlToHttp(avatarUrl, AVATAR_SIZE, AVATAR_SIZE, AVATAR_RESIZE_METHOD),
55+
cli.mxcUrlToHttp(avatarUrl, size, size, AVATAR_RESIZE_METHOD),
5356
);
5457
});
5558
};
@@ -75,15 +78,17 @@ describe("Timeline", () => {
7578
cy.startSynapse("default").then(data => {
7679
synapse = data;
7780
cy.initTestUser(synapse, OLD_NAME).then(() =>
78-
cy.window({ log: false }).then(() => {
79-
cy.createRoom({ name: ROOM_NAME }).then(_room1Id => {
80-
roomId = _room1Id;
81-
});
81+
cy.createRoom({ name: ROOM_NAME }).then(_room1Id => {
82+
roomId = _room1Id;
8283
}),
8384
);
8485
});
8586
});
8687

88+
afterEach(() => {
89+
cy.stopSynapse(synapse);
90+
});
91+
8792
describe("useOnlyCurrentProfiles", () => {
8893
beforeEach(() => {
8994
cy.uploadContent(OLD_AVATAR).then((url) => {
@@ -95,10 +100,6 @@ describe("Timeline", () => {
95100
});
96101
});
97102

98-
afterEach(() => {
99-
cy.stopSynapse(synapse);
100-
});
101-
102103
it("should show historical profiles if disabled", () => {
103104
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, false);
104105
sendEvent(roomId);
@@ -146,11 +147,16 @@ describe("Timeline", () => {
146147
});
147148

148149
describe("message displaying", () => {
150+
beforeEach(() => {
151+
cy.injectAxe();
152+
});
153+
149154
it("should create and configure a room on IRC layout", () => {
150155
cy.visit("/#/room/" + roomId);
151156
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
152157
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary[data-layout=irc] " +
153158
".mx_GenericEventListSummary_summary", "created and configured the room.");
159+
cy.get(".mx_Spinner").should("not.exist");
154160
cy.percySnapshot("Configured room on IRC layout");
155161
});
156162

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

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

183191
it("should set inline start padding to a hidden event line", () => {

cypress/e2e/2-login/login.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ describe("Login", () => {
4141
});
4242

4343
it("logs in with an existing account and lands on the home screen", () => {
44+
cy.injectAxe();
45+
4446
cy.get("#mx_LoginForm_username", { timeout: 15000 }).should("be.visible");
4547
cy.percySnapshot("Login");
48+
cy.checkA11y();
4649

4750
cy.get(".mx_ServerPicker_change").click();
4851
cy.get(".mx_ServerPickerDialog_otherHomeserver").type(synapse.baseUrl);

cypress/plugins/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { performance } from "./performance";
2222
import { synapseDocker } from "./synapsedocker";
2323
import { webserver } from "./webserver";
2424
import { docker } from "./docker";
25+
import { log } from "./log";
2526

2627
/**
2728
* @type {Cypress.PluginConfig}
@@ -31,4 +32,5 @@ export default function(on: PluginEvents, config: PluginConfigOptions) {
3132
performance(on, config);
3233
synapseDocker(on, config);
3334
webserver(on, config);
35+
log(on, config);
3436
}

cypress/plugins/log.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/// <reference types="cypress" />
18+
19+
import PluginEvents = Cypress.PluginEvents;
20+
import PluginConfigOptions = Cypress.PluginConfigOptions;
21+
22+
export function log(on: PluginEvents, config: PluginConfigOptions) {
23+
on("task", {
24+
log(message: string) {
25+
console.log(message);
26+
27+
return null;
28+
},
29+
table(message: string) {
30+
console.table(message);
31+
32+
return null;
33+
},
34+
});
35+
}

cypress/support/axe.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/// <reference types="cypress" />
18+
19+
import "cypress-axe";
20+
import * as axe from "axe-core";
21+
import { Options } from "cypress-axe";
22+
23+
import Chainable = Cypress.Chainable;
24+
25+
function terminalLog(violations: axe.Result[]): void {
26+
cy.task(
27+
'log',
28+
`${violations.length} accessibility violation${
29+
violations.length === 1 ? '' : 's'
30+
} ${violations.length === 1 ? 'was' : 'were'} detected`,
31+
);
32+
33+
// pluck specific keys to keep the table readable
34+
const violationData = violations.map(({ id, impact, description, nodes }) => ({
35+
id,
36+
impact,
37+
description,
38+
nodes: nodes.length,
39+
}));
40+
41+
cy.task('table', violationData);
42+
}
43+
44+
Cypress.Commands.overwrite("checkA11y", (
45+
originalFn: Chainable["checkA11y"],
46+
context?: string | Node | axe.ContextObject | undefined,
47+
options: Options = {},
48+
violationCallback?: ((violations: axe.Result[]) => void) | undefined,
49+
skipFailures?: boolean,
50+
): void => {
51+
return originalFn(context, {
52+
...options,
53+
rules: {
54+
// Disable contrast checking for now as we have too many issues with it
55+
'color-contrast': {
56+
enabled: false,
57+
},
58+
...options.rules,
59+
},
60+
}, violationCallback ?? terminalLog, skipFailures);
61+
});

cypress/support/e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ import "./iframes";
3636
import "./timeline";
3737
import "./network";
3838
import "./composer";
39+
import "./axe";

cypress/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"dom",
88
"dom.iterable"
99
],
10-
"types": ["cypress", "@percy/cypress"],
10+
"types": [
11+
"cypress",
12+
"cypress-axe",
13+
"@percy/cypress"
14+
],
1115
"resolveJsonModule": true,
1216
"esModuleInterop": true,
1317
"moduleResolution": "node",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@
167167
"@typescript-eslint/parser": "^5.6.0",
168168
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
169169
"allchange": "^1.0.6",
170+
"axe-core": "^4.4.3",
170171
"babel-jest": "^26.6.3",
171172
"blob-polyfill": "^6.0.20211015",
172173
"chokidar": "^3.5.1",
173174
"cypress": "^10.3.0",
175+
"cypress-axe": "^1.0.0",
174176
"cypress-real-events": "^1.7.1",
175177
"enzyme": "^3.11.0",
176178
"enzyme-to-json": "^3.6.2",

res/css/views/auth/_AuthBody.pcss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ limitations under the License.
2929
flex-direction: column;
3030
}
3131

32-
h2 {
32+
h1 {
3333
font-size: $font-24px;
34-
font-weight: 600;
34+
font-weight: $font-semi-bold;
3535
margin-top: 8px;
3636
color: $authpage-primary-color;
3737
}
3838

39-
h3 {
39+
h2 {
4040
font-size: $font-14px;
41-
font-weight: 600;
41+
font-weight: $font-semi-bold;
4242
color: $authpage-secondary-color;
4343
}
4444

45-
h3.mx_AuthBody_centered {
45+
h2.mx_AuthBody_centered {
4646
text-align: center;
4747
}
4848

0 commit comments

Comments
 (0)