@element-hq/element-web-playwright-common 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +9 -0
- package/README.md +28 -0
- package/lib/element-web-test.d.ts +26 -0
- package/lib/element-web-test.d.ts.map +1 -0
- package/lib/element-web-test.js +54 -0
- package/lib/expect/axe.d.ts +11 -0
- package/lib/expect/axe.d.ts.map +1 -0
- package/lib/expect/axe.js +22 -0
- package/lib/expect/index.d.ts +6 -0
- package/lib/expect/index.d.ts.map +1 -0
- package/lib/expect/index.js +10 -0
- package/lib/expect/screenshot.d.ts +14 -0
- package/lib/expect/screenshot.d.ts.map +1 -0
- package/lib/expect/screenshot.js +48 -0
- package/lib/expect/toHaveNoViolations.d.ts +11 -0
- package/lib/expect/toHaveNoViolations.d.ts.map +1 -0
- package/lib/expect/toHaveNoViolations.js +22 -0
- package/lib/expect/toMatchScreenshot.d.ts +13 -0
- package/lib/expect/toMatchScreenshot.d.ts.map +1 -0
- package/lib/expect/toMatchScreenshot.js +44 -0
- package/lib/expect/toPassAxeCheck.d.ts +7 -0
- package/lib/expect/toPassAxeCheck.d.ts.map +1 -0
- package/lib/expect/toPassAxeCheck.js +22 -0
- package/lib/fixtures/axe.d.ts +8 -0
- package/lib/fixtures/axe.d.ts.map +1 -0
- package/lib/fixtures/axe.js +15 -0
- package/lib/fixtures/index.d.ts +10 -0
- package/lib/fixtures/index.d.ts.map +1 -0
- package/lib/fixtures/index.js +10 -0
- package/lib/fixtures/services.d.ts +57 -0
- package/lib/fixtures/services.d.ts.map +1 -0
- package/lib/fixtures/services.js +114 -0
- package/lib/fixtures/user.d.ts +31 -0
- package/lib/fixtures/user.d.ts.map +1 -0
- package/lib/fixtures/user.js +47 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +54 -0
- package/lib/logger.d.ts +10 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +59 -0
- package/lib/playwright.d.ts +2 -0
- package/lib/playwright.d.ts.map +1 -0
- package/lib/playwright.js +1 -0
- package/lib/testcontainers/HomeserverContainer.d.ts +70 -0
- package/lib/testcontainers/HomeserverContainer.d.ts.map +1 -0
- package/lib/testcontainers/HomeserverContainer.js +7 -0
- package/lib/testcontainers/index.d.ts +5 -0
- package/lib/testcontainers/index.d.ts.map +1 -0
- package/lib/testcontainers/index.js +9 -0
- package/lib/testcontainers/mailpit.d.ts +33 -0
- package/lib/testcontainers/mailpit.d.ts.map +1 -0
- package/lib/testcontainers/mailpit.js +52 -0
- package/lib/testcontainers/mas.d.ts +182 -0
- package/lib/testcontainers/mas.d.ts.map +1 -0
- package/lib/testcontainers/mas.js +311 -0
- package/lib/testcontainers/synapse.d.ts +229 -0
- package/lib/testcontainers/synapse.d.ts.map +1 -0
- package/lib/testcontainers/synapse.js +383 -0
- package/lib/utils/api.d.ts +49 -0
- package/lib/utils/api.d.ts.map +1 -0
- package/lib/utils/api.js +73 -0
- package/lib/utils/logger.d.ts +25 -0
- package/lib/utils/logger.d.ts.map +1 -0
- package/lib/utils/logger.js +74 -0
- package/lib/utils/object.d.ts +8 -0
- package/lib/utils/object.d.ts.map +1 -0
- package/lib/utils/object.js +15 -0
- package/lib/utils/port.d.ts +5 -0
- package/lib/utils/port.d.ts.map +1 -0
- package/lib/utils/port.js +20 -0
- package/lib/utils/rand.d.ts +6 -0
- package/lib/utils/rand.d.ts.map +1 -0
- package/lib/utils/rand.js +15 -0
- package/package.json +30 -0
- package/playwright-screenshots.sh +53 -0
- package/src/@types/playwright-core.d.ts +12 -0
- package/src/expect/axe.ts +37 -0
- package/src/expect/index.ts +21 -0
- package/src/expect/screenshot.ts +79 -0
- package/src/fixtures/axe.ts +22 -0
- package/src/fixtures/index.ts +15 -0
- package/src/fixtures/services.ts +188 -0
- package/src/fixtures/user.ts +93 -0
- package/src/index.ts +92 -0
- package/src/testcontainers/HomeserverContainer.ts +87 -0
- package/src/testcontainers/index.ts +15 -0
- package/src/testcontainers/mailpit.ts +62 -0
- package/src/testcontainers/mas.ts +382 -0
- package/src/testcontainers/synapse.ts +493 -0
- package/src/utils/api.ts +113 -0
- package/src/utils/logger.ts +79 -0
- package/src/utils/object.ts +16 -0
- package/src/utils/port.ts +22 -0
- package/src/utils/rand.ts +17 -0
- package/tsconfig.json +10 -0
package/Dockerfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
ARG PLAYWRIGHT_VERSION
|
|
2
|
+
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble
|
|
3
|
+
|
|
4
|
+
WORKDIR /work
|
|
5
|
+
|
|
6
|
+
# fonts-dejavu is needed for the same RTL rendering as on CI
|
|
7
|
+
RUN apt-get update && apt-get -y install docker.io fonts-dejavu
|
|
8
|
+
|
|
9
|
+
ENTRYPOINT ["npx", "playwright", "test", "--update-snapshots", "--reporter", "line"]
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @element-hq/element-web-playwright-common
|
|
2
|
+
|
|
3
|
+
Set of Playwright & testcontainers utilities to make it easier to write tests for Element Web, Element Web Modules & Element Desktop.
|
|
4
|
+
|
|
5
|
+
The main export includes a number of fixtures and custom assertions as documented in JSDoc.
|
|
6
|
+
|
|
7
|
+
The `lib/testcontainers` export contains the following modules:
|
|
8
|
+
|
|
9
|
+
- `SynapseContainer` - A testcontainer for running a Synapse server
|
|
10
|
+
- `MatrixAuthenticationServiceContainer` - A testcontainer for running a Matrix Authentication Service
|
|
11
|
+
- `MailpitContainer` - A testcontainer for running a Mailpit SMTP server
|
|
12
|
+
|
|
13
|
+
There are a number of utils available in the `lib/utils` export.
|
|
14
|
+
|
|
15
|
+
## Releases
|
|
16
|
+
|
|
17
|
+
The API is versioned using semver, with the major version incremented for breaking changes.
|
|
18
|
+
|
|
19
|
+
## Copyright & License
|
|
20
|
+
|
|
21
|
+
Copyright (c) 2025 New Vector Ltd
|
|
22
|
+
|
|
23
|
+
This software is multi licensed by New Vector Ltd (Element). It can be used either:
|
|
24
|
+
|
|
25
|
+
(1) for free under the terms of the GNU Affero General Public License (as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version); OR
|
|
26
|
+
|
|
27
|
+
(2) under the terms of a paid-for Element Commercial License agreement between you and Element (the terms of which may vary depending on what you and Element have agreed to).
|
|
28
|
+
Unless required by applicable law or agreed to in writing, software distributed under the Licenses is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licenses for the specific language governing permissions and limitations under the Licenses.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const CONFIG_JSON: {
|
|
2
|
+
default_server_config: {};
|
|
3
|
+
setting_defaults: {
|
|
4
|
+
language: string;
|
|
5
|
+
};
|
|
6
|
+
map_style_url: string;
|
|
7
|
+
features: Record<string, boolean>;
|
|
8
|
+
};
|
|
9
|
+
export interface TestFixtures {
|
|
10
|
+
/**
|
|
11
|
+
* The contents of the config.json to send when the client requests it.
|
|
12
|
+
*/
|
|
13
|
+
config: Partial<typeof CONFIG_JSON>;
|
|
14
|
+
labsFlags: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & {
|
|
17
|
+
axe: import("@axe-core/playwright").AxeBuilder;
|
|
18
|
+
checkA11y: () => Promise<void>;
|
|
19
|
+
} & import("./fixtures/services").TestFixtures & {
|
|
20
|
+
displayName?: string;
|
|
21
|
+
credentials: import("./utils/api").Credentials;
|
|
22
|
+
pageWithCredentials: import("playwright-core").Page;
|
|
23
|
+
user: import("./utils/api").Credentials;
|
|
24
|
+
} & TestFixtures, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions & import("./fixtures/services").Services>;
|
|
25
|
+
export { expect } from "./expect";
|
|
26
|
+
//# sourceMappingURL=element-web-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-web-test.d.ts","sourceRoot":"","sources":["../src/element-web-test.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,WAAW;;;;;;cAcR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;IAEpC,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,IAAI;;;;;;;;8JA2Bf,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test as base } from "./fixtures";
|
|
9
|
+
// Enable experimental service worker support
|
|
10
|
+
// See https://playwright.dev/docs/service-workers-experimental#how-to-enable
|
|
11
|
+
process.env["PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS"] = "1";
|
|
12
|
+
// This is deliberately quite a minimal config.json, so that we can test that the default settings actually work.
|
|
13
|
+
const CONFIG_JSON = {
|
|
14
|
+
default_server_config: {},
|
|
15
|
+
// The default language is set here for test consistency
|
|
16
|
+
setting_defaults: {
|
|
17
|
+
language: "en-GB",
|
|
18
|
+
},
|
|
19
|
+
// the location tests want a map style url.
|
|
20
|
+
map_style_url: "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx",
|
|
21
|
+
features: {
|
|
22
|
+
// We don't want to go through the feature announcement during the e2e test
|
|
23
|
+
feature_release_announcement: false,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export const test = base.extend({
|
|
27
|
+
config: {}, // We merge this atop the default CONFIG_JSON in the page fixture to make extending it easier
|
|
28
|
+
labsFlags: [],
|
|
29
|
+
page: async ({ homeserver, context, page, config, labsFlags }, use) => {
|
|
30
|
+
await context.route(`http://localhost:8080/config.json*`, async (route) => {
|
|
31
|
+
const json = {
|
|
32
|
+
...CONFIG_JSON,
|
|
33
|
+
...config,
|
|
34
|
+
default_server_config: {
|
|
35
|
+
"m.homeserver": {
|
|
36
|
+
base_url: homeserver.baseUrl,
|
|
37
|
+
},
|
|
38
|
+
...config.default_server_config,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
json["features"] = {
|
|
42
|
+
...json["features"],
|
|
43
|
+
// Enable the lab features
|
|
44
|
+
...labsFlags.reduce((obj, flag) => {
|
|
45
|
+
obj[flag] = true;
|
|
46
|
+
return obj;
|
|
47
|
+
}, {}),
|
|
48
|
+
};
|
|
49
|
+
await route.fulfill({ json });
|
|
50
|
+
});
|
|
51
|
+
await use(page);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export { expect } from "./expect";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ExpectMatcherState, type MatcherReturnType } from "@playwright/test";
|
|
2
|
+
import type AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
export type Expectations = {
|
|
4
|
+
/**
|
|
5
|
+
* Assert that the given AxeBuilder instance has no violations.
|
|
6
|
+
* @param receiver - The AxeBuilder instance to check.
|
|
7
|
+
*/
|
|
8
|
+
toHaveNoViolations: (this: ExpectMatcherState, receiver: AxeBuilder) => Promise<MatcherReturnType>;
|
|
9
|
+
};
|
|
10
|
+
export declare const expect: import("playwright/test").Expect<Expectations>;
|
|
11
|
+
//# sourceMappingURL=axe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/expect/axe.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG;IACvB;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtG,CAAC;AAEF,eAAO,MAAM,MAAM,gDAgBjB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024-2025 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test, expect as baseExpect } from "@playwright/test";
|
|
9
|
+
export const expect = baseExpect.extend({
|
|
10
|
+
async toHaveNoViolations(receiver) {
|
|
11
|
+
const testInfo = test.info();
|
|
12
|
+
if (!testInfo)
|
|
13
|
+
throw new Error(`toHaveNoViolations() must be called during the test`);
|
|
14
|
+
const results = await receiver.analyze();
|
|
15
|
+
await testInfo.attach("accessibility-scan-results", {
|
|
16
|
+
body: JSON.stringify(results, null, 2),
|
|
17
|
+
contentType: "application/json",
|
|
18
|
+
});
|
|
19
|
+
baseExpect(results.violations).toEqual([]);
|
|
20
|
+
return { pass: true, message: () => "", name: "toHaveNoViolations" };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Expect } from "@playwright/test";
|
|
2
|
+
import { Expectations as ScreenshotExpectations, ToMatchScreenshotOptions } from "./screenshot.js";
|
|
3
|
+
import { Expectations as AxeExpectations } from "./axe.js";
|
|
4
|
+
export declare const expect: Expect<ScreenshotExpectations & AxeExpectations>;
|
|
5
|
+
export type { ToMatchScreenshotOptions };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expect/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAEH,YAAY,IAAI,sBAAsB,EACtC,wBAAwB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,YAAY,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAEtF,eAAO,MAAM,MAAM,EAA4D,MAAM,CACjF,sBAAsB,GAAG,eAAe,CAC3C,CAAC;AAEF,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 New Vector Ltd.
|
|
3
|
+
|
|
4
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
5
|
+
Please see LICENSE files in the repository root for full details.
|
|
6
|
+
*/
|
|
7
|
+
import { mergeExpects } from "@playwright/test";
|
|
8
|
+
import { expect as screenshotExpectations, } from "./screenshot.js";
|
|
9
|
+
import { expect as axeExpectations } from "./axe.js";
|
|
10
|
+
export const expect = mergeExpects(screenshotExpectations, axeExpectations);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExpectMatcherState, type Locator, type Page, type PageAssertionsToHaveScreenshotOptions } from "@playwright/test";
|
|
2
|
+
import { type MatcherReturnType } from "playwright/types/test";
|
|
3
|
+
export interface ToMatchScreenshotOptions extends PageAssertionsToHaveScreenshotOptions {
|
|
4
|
+
css?: string;
|
|
5
|
+
}
|
|
6
|
+
export type Expectations = {
|
|
7
|
+
toMatchScreenshot: (this: ExpectMatcherState, receiver: Page | Locator, name: `${string}.png`, options?: ToMatchScreenshotOptions) => Promise<MatcherReturnType>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Provides an upgrade to the `toHaveScreenshot` expectation.
|
|
11
|
+
* Unfortunately, we can't just extend the existing `toHaveScreenshot` expectation
|
|
12
|
+
*/
|
|
13
|
+
export declare const expect: import("playwright/test").Expect<Expectations>;
|
|
14
|
+
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/expect/screenshot.ts"],"names":[],"mappings":"AAQA,OAAO,EAIH,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,qCAAqC,EAC7C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW/D,MAAM,WAAW,wBAAyB,SAAQ,qCAAqC;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,iBAAiB,EAAE,CACf,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,IAAI,GAAG,OAAO,EACxB,IAAI,EAAE,GAAG,MAAM,MAAM,EACrB,OAAO,CAAC,EAAE,wBAAwB,KACjC,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,gDAiCjB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024-2025 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test, expect as baseExpect, } from "@playwright/test";
|
|
9
|
+
import { sanitizeForFilePath } from "playwright-core/lib/utils";
|
|
10
|
+
import { extname } from "node:path";
|
|
11
|
+
// Based on https://github.com/microsoft/playwright/blob/2b77ed4d7aafa85a600caa0b0d101b72c8437eeb/packages/playwright/src/util.ts#L206C8-L210C2
|
|
12
|
+
function sanitizeFilePathBeforeExtension(filePath) {
|
|
13
|
+
const ext = extname(filePath);
|
|
14
|
+
const base = filePath.substring(0, filePath.length - ext.length);
|
|
15
|
+
return sanitizeForFilePath(base) + ext;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Provides an upgrade to the `toHaveScreenshot` expectation.
|
|
19
|
+
* Unfortunately, we can't just extend the existing `toHaveScreenshot` expectation
|
|
20
|
+
*/
|
|
21
|
+
export const expect = baseExpect.extend({
|
|
22
|
+
async toMatchScreenshot(receiver, name, options) {
|
|
23
|
+
const testInfo = test.info();
|
|
24
|
+
if (!testInfo)
|
|
25
|
+
throw new Error(`toMatchScreenshot() must be called during the test`);
|
|
26
|
+
if (!testInfo.tags.includes("@screenshot")) {
|
|
27
|
+
throw new Error("toMatchScreenshot() must be used in a test tagged with @screenshot");
|
|
28
|
+
}
|
|
29
|
+
const page = "page" in receiver ? receiver.page() : receiver;
|
|
30
|
+
let style;
|
|
31
|
+
if (options?.css) {
|
|
32
|
+
// We add a custom style tag before taking screenshots
|
|
33
|
+
style = (await page.addStyleTag({
|
|
34
|
+
content: options.css,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
const screenshotName = sanitizeFilePathBeforeExtension(name);
|
|
38
|
+
await baseExpect(receiver).toHaveScreenshot(screenshotName, options);
|
|
39
|
+
await style?.evaluate((tag) => tag.remove());
|
|
40
|
+
testInfo.annotations.push({
|
|
41
|
+
// `_` prefix hides it from the HTML reporter
|
|
42
|
+
type: "_screenshot",
|
|
43
|
+
// include a path relative to `playwright/snapshots/`
|
|
44
|
+
description: testInfo.snapshotPath(screenshotName).split("/playwright/snapshots/", 2)[1],
|
|
45
|
+
});
|
|
46
|
+
return { pass: true, message: () => "", name: "toMatchScreenshot" };
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ExpectMatcherState, type MatcherReturnType } from "@playwright/test";
|
|
2
|
+
import type AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
export type Expectations = {
|
|
4
|
+
/**
|
|
5
|
+
* Assert that the given AxeBuilder instance has no violations.
|
|
6
|
+
* @param receiver - The AxeBuilder instance to check.
|
|
7
|
+
*/
|
|
8
|
+
toHaveNoViolations: (this: ExpectMatcherState, receiver: AxeBuilder) => Promise<MatcherReturnType>;
|
|
9
|
+
};
|
|
10
|
+
export declare const expect: import("playwright/test").Expect<Expectations>;
|
|
11
|
+
//# sourceMappingURL=toHaveNoViolations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toHaveNoViolations.d.ts","sourceRoot":"","sources":["../../src/expect/toHaveNoViolations.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG;IACvB;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtG,CAAC;AAEF,eAAO,MAAM,MAAM,gDAgBjB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test, expect as baseExpect } from "@playwright/test";
|
|
9
|
+
export const expect = baseExpect.extend({
|
|
10
|
+
async toHaveNoViolations(receiver) {
|
|
11
|
+
const testInfo = test.info();
|
|
12
|
+
if (!testInfo)
|
|
13
|
+
throw new Error(`toHaveNoViolations() must be called during the test`);
|
|
14
|
+
const results = await receiver.analyze();
|
|
15
|
+
await testInfo.attach("accessibility-scan-results", {
|
|
16
|
+
body: JSON.stringify(results, null, 2),
|
|
17
|
+
contentType: "application/json",
|
|
18
|
+
});
|
|
19
|
+
baseExpect(results.violations).toEqual([]);
|
|
20
|
+
return { pass: true, message: () => "", name: "toHaveNoViolations" };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ExpectMatcherState, type Locator, type Page } from "@playwright/test";
|
|
2
|
+
import { type MatcherReturnType } from "playwright/types/test";
|
|
3
|
+
export type Expectations = {
|
|
4
|
+
toMatchScreenshot: (this: ExpectMatcherState, receiver: Page | Locator, name: `${string}.png`, options?: {
|
|
5
|
+
mask?: Array<Locator>;
|
|
6
|
+
includeDialogBackground?: boolean;
|
|
7
|
+
showTooltips?: boolean;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
css?: string;
|
|
10
|
+
}) => Promise<MatcherReturnType>;
|
|
11
|
+
};
|
|
12
|
+
export declare const expect: import("playwright/test").Expect<Expectations>;
|
|
13
|
+
//# sourceMappingURL=toMatchScreenshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toMatchScreenshot.d.ts","sourceRoot":"","sources":["../../src/expect/toMatchScreenshot.ts"],"names":[],"mappings":"AAQA,OAAO,EAIH,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,IAAI,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW/D,MAAM,MAAM,YAAY,GAAG;IACvB,iBAAiB,EAAE,CACf,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,IAAI,GAAG,OAAO,EACxB,IAAI,EAAE,GAAG,MAAM,MAAM,EACrB,OAAO,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtB,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KAChB,KACA,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,MAAM,gDAkCjB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test, expect as baseExpect, } from "@playwright/test";
|
|
9
|
+
import { sanitizeForFilePath } from "playwright-core/lib/utils";
|
|
10
|
+
import { extname } from "node:path";
|
|
11
|
+
// Based on https://github.com/microsoft/playwright/blob/2b77ed4d7aafa85a600caa0b0d101b72c8437eeb/packages/playwright/src/util.ts#L206C8-L210C2
|
|
12
|
+
function sanitizeFilePathBeforeExtension(filePath) {
|
|
13
|
+
const ext = extname(filePath);
|
|
14
|
+
const base = filePath.substring(0, filePath.length - ext.length);
|
|
15
|
+
return sanitizeForFilePath(base) + ext;
|
|
16
|
+
}
|
|
17
|
+
export const expect = baseExpect.extend({
|
|
18
|
+
async toMatchScreenshot(receiver, name, options) {
|
|
19
|
+
const testInfo = test.info();
|
|
20
|
+
if (!testInfo)
|
|
21
|
+
throw new Error(`toMatchScreenshot() must be called during the test`);
|
|
22
|
+
if (!testInfo.tags.includes("@screenshot")) {
|
|
23
|
+
throw new Error("toMatchScreenshot() must be used in a test tagged with @screenshot");
|
|
24
|
+
}
|
|
25
|
+
const page = "page" in receiver ? receiver.page() : receiver;
|
|
26
|
+
let style;
|
|
27
|
+
if (options?.css) {
|
|
28
|
+
// We add a custom style tag before taking screenshots
|
|
29
|
+
style = (await page.addStyleTag({
|
|
30
|
+
content: options.css,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
const screenshotName = sanitizeFilePathBeforeExtension(name);
|
|
34
|
+
await baseExpect(receiver).toHaveScreenshot(screenshotName, options);
|
|
35
|
+
await style?.evaluate((tag) => tag.remove());
|
|
36
|
+
testInfo.annotations.push({
|
|
37
|
+
// `_` prefix hides it from the HTML reporter
|
|
38
|
+
type: "_screenshot",
|
|
39
|
+
// include a path relative to `playwright/snapshots/`
|
|
40
|
+
description: testInfo.snapshotPath(screenshotName).split("/playwright/snapshots/", 2)[1],
|
|
41
|
+
});
|
|
42
|
+
return { pass: true, message: () => "", name: "toMatchScreenshot" };
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ExpectMatcherState, type MatcherReturnType } from "@playwright/test";
|
|
2
|
+
import type AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
export type Expectations = {
|
|
4
|
+
toPassAxeCheck: (this: ExpectMatcherState, receiver: AxeBuilder) => Promise<MatcherReturnType>;
|
|
5
|
+
};
|
|
6
|
+
export declare const expect: import("playwright/test").Expect<Expectations>;
|
|
7
|
+
//# sourceMappingURL=toPassAxeCheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toPassAxeCheck.d.ts","sourceRoot":"","sources":["../../src/expect/toPassAxeCheck.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG;IACvB,cAAc,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAClG,CAAC;AAEF,eAAO,MAAM,MAAM,gDAgBjB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test, expect as baseExpect } from "@playwright/test";
|
|
9
|
+
export const expect = baseExpect.extend({
|
|
10
|
+
async toPassAxeCheck(receiver) {
|
|
11
|
+
const testInfo = test.info();
|
|
12
|
+
if (!testInfo)
|
|
13
|
+
throw new Error(`toPassAxeCheck() must be called during the test`);
|
|
14
|
+
const results = await receiver.analyze();
|
|
15
|
+
await testInfo.attach("accessibility-scan-results", {
|
|
16
|
+
body: JSON.stringify(results, null, 2),
|
|
17
|
+
contentType: "application/json",
|
|
18
|
+
});
|
|
19
|
+
baseExpect(results.violations).toEqual([]);
|
|
20
|
+
return { pass: true, message: () => "", name: "toPassAxeCheck" };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
2
|
+
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & {
|
|
3
|
+
/**
|
|
4
|
+
* AxeBuilder instance for the current page
|
|
5
|
+
*/
|
|
6
|
+
axe: AxeBuilder;
|
|
7
|
+
}, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions>;
|
|
8
|
+
//# sourceMappingURL=axe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/fixtures/axe.ts"],"names":[],"mappings":"AASA,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,eAAO,MAAM,IAAI;IACb;;OAEG;SACE,UAAU;sGAMjB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024-2025 New Vector Ltd.
|
|
3
|
+
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
6
|
+
Please see LICENSE files in the repository root for full details.
|
|
7
|
+
*/
|
|
8
|
+
import { test as base } from "@playwright/test";
|
|
9
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
10
|
+
export const test = base.extend({
|
|
11
|
+
axe: async ({ page }, use) => {
|
|
12
|
+
const builder = new AxeBuilder({ page });
|
|
13
|
+
await use(builder);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { type Services, type WorkerOptions } from "./services.js";
|
|
2
|
+
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & {
|
|
3
|
+
axe: import("@axe-core/playwright").AxeBuilder;
|
|
4
|
+
} & import("./services.js").TestFixtures & {
|
|
5
|
+
displayName?: string;
|
|
6
|
+
credentials: import("../utils/api.js").Credentials;
|
|
7
|
+
pageWithCredentials: import("playwright-core").Page;
|
|
8
|
+
user: import("../utils/api.js").Credentials;
|
|
9
|
+
}, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions & import("./services.js").WorkerOptions & import("./services.js").Services>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAElE,eAAO,MAAM,IAAI;;;;;;;iLAAwB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 New Vector Ltd.
|
|
3
|
+
|
|
4
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
5
|
+
Please see LICENSE files in the repository root for full details.
|
|
6
|
+
*/
|
|
7
|
+
import { mergeTests } from "@playwright/test";
|
|
8
|
+
import { test as axe } from "./axe.js";
|
|
9
|
+
import { test as user } from "./user.js";
|
|
10
|
+
export const test = mergeTests(axe, user);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type MailpitClient } from "mailpit-api";
|
|
2
|
+
import { type StartedNetwork } from "testcontainers";
|
|
3
|
+
import { type StartedPostgreSqlContainer } from "@testcontainers/postgresql";
|
|
4
|
+
import { type SynapseConfig, type StartedMatrixAuthenticationServiceContainer, type HomeserverContainer, type StartedHomeserverContainer, type StartedMailpitContainer } from "../testcontainers/index.js";
|
|
5
|
+
import { Logger } from "../utils/logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Test-scoped fixtures available in the test
|
|
8
|
+
*/
|
|
9
|
+
export interface TestFixtures {
|
|
10
|
+
/**
|
|
11
|
+
* The mailpit client instance for the test.
|
|
12
|
+
* This is a fresh client instance with no messages from prior tests.
|
|
13
|
+
*/
|
|
14
|
+
mailpitClient: MailpitClient;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkerOptions {
|
|
17
|
+
/**
|
|
18
|
+
* The synapse configuration to use for the homeserver.
|
|
19
|
+
*/
|
|
20
|
+
synapseConfig: Partial<SynapseConfig>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Worker-scoped "service" fixtures available in the test
|
|
24
|
+
*/
|
|
25
|
+
export interface Services {
|
|
26
|
+
/**
|
|
27
|
+
* The logger instance for the worker.
|
|
28
|
+
*/
|
|
29
|
+
logger: Logger;
|
|
30
|
+
/**
|
|
31
|
+
* The started testcontainers network instance for the worker.
|
|
32
|
+
*/
|
|
33
|
+
network: StartedNetwork;
|
|
34
|
+
/**
|
|
35
|
+
* The started postgres container instance for the worker.
|
|
36
|
+
*/
|
|
37
|
+
postgres: StartedPostgreSqlContainer;
|
|
38
|
+
/**
|
|
39
|
+
* The started mailpit container instance for the worker.
|
|
40
|
+
*/
|
|
41
|
+
mailpit: StartedMailpitContainer;
|
|
42
|
+
/**
|
|
43
|
+
* The homeserver instance container to use for the worker.
|
|
44
|
+
*/
|
|
45
|
+
_homeserver: HomeserverContainer<unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* The started homeserver instance container for the worker.
|
|
48
|
+
*/
|
|
49
|
+
homeserver: StartedHomeserverContainer;
|
|
50
|
+
/**
|
|
51
|
+
* The Matrix Authentication Service container instance for the worker.
|
|
52
|
+
* May be undefined if no delegated auth is in use.
|
|
53
|
+
*/
|
|
54
|
+
mas?: StartedMatrixAuthenticationServiceContainer;
|
|
55
|
+
}
|
|
56
|
+
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & TestFixtures, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions & WorkerOptions & Services>;
|
|
57
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/fixtures/services.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAuB,KAAK,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAElG,OAAO,EACH,KAAK,aAAa,EAElB,KAAK,2CAA2C,EAChD,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAE/B,KAAK,uBAAuB,EAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,aAAa,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,0BAA0B,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,uBAAuB,CAAC;IAEjC;;OAEG;IACH,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC1C;;OAEG;IACH,UAAU,EAAE,0BAA0B,CAAC;IAEvC;;;OAGG;IACH,GAAG,CAAC,EAAE,2CAA2C,CAAC;CACrD;AAED,eAAO,MAAM,IAAI,kRA0Gf,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024-2025 New Vector Ltd.
|
|
3
|
+
|
|
4
|
+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
5
|
+
Please see LICENSE files in the repository root for full details.
|
|
6
|
+
*/
|
|
7
|
+
import { test as base } from "@playwright/test";
|
|
8
|
+
import { Network } from "testcontainers";
|
|
9
|
+
import { PostgreSqlContainer } from "@testcontainers/postgresql";
|
|
10
|
+
import { SynapseContainer, MailpitContainer, } from "../testcontainers/index.js";
|
|
11
|
+
import { Logger } from "../utils/logger.js";
|
|
12
|
+
export const test = base.extend({
|
|
13
|
+
logger: [
|
|
14
|
+
// eslint-disable-next-line no-empty-pattern
|
|
15
|
+
async ({}, use) => {
|
|
16
|
+
const logger = new Logger();
|
|
17
|
+
await use(logger);
|
|
18
|
+
},
|
|
19
|
+
{ scope: "worker" },
|
|
20
|
+
],
|
|
21
|
+
network: [
|
|
22
|
+
// eslint-disable-next-line no-empty-pattern
|
|
23
|
+
async ({}, use) => {
|
|
24
|
+
const network = await new Network().start();
|
|
25
|
+
await use(network);
|
|
26
|
+
await network.stop();
|
|
27
|
+
},
|
|
28
|
+
{ scope: "worker" },
|
|
29
|
+
],
|
|
30
|
+
postgres: [
|
|
31
|
+
async ({ logger, network }, use) => {
|
|
32
|
+
const container = await new PostgreSqlContainer()
|
|
33
|
+
.withNetwork(network)
|
|
34
|
+
.withNetworkAliases("postgres")
|
|
35
|
+
.withLogConsumer(logger.getConsumer("postgres"))
|
|
36
|
+
.withTmpFs({
|
|
37
|
+
"/dev/shm/pgdata/data": "",
|
|
38
|
+
})
|
|
39
|
+
.withEnvironment({
|
|
40
|
+
PG_DATA: "/dev/shm/pgdata/data",
|
|
41
|
+
})
|
|
42
|
+
.withCommand([
|
|
43
|
+
"-c",
|
|
44
|
+
"shared_buffers=128MB",
|
|
45
|
+
"-c",
|
|
46
|
+
`fsync=off`,
|
|
47
|
+
"-c",
|
|
48
|
+
`synchronous_commit=off`,
|
|
49
|
+
"-c",
|
|
50
|
+
"full_page_writes=off",
|
|
51
|
+
])
|
|
52
|
+
.start();
|
|
53
|
+
await use(container);
|
|
54
|
+
await container.stop();
|
|
55
|
+
},
|
|
56
|
+
{ scope: "worker" },
|
|
57
|
+
],
|
|
58
|
+
mailpit: [
|
|
59
|
+
async ({ logger, network }, use) => {
|
|
60
|
+
const container = await new MailpitContainer()
|
|
61
|
+
.withNetwork(network)
|
|
62
|
+
.withNetworkAliases("mailpit")
|
|
63
|
+
.withLogConsumer(logger.getConsumer("mailpit"))
|
|
64
|
+
.start();
|
|
65
|
+
await use(container);
|
|
66
|
+
await container.stop();
|
|
67
|
+
},
|
|
68
|
+
{ scope: "worker" },
|
|
69
|
+
],
|
|
70
|
+
mailpitClient: async ({ mailpit: container }, use) => {
|
|
71
|
+
await container.client.deleteMessages();
|
|
72
|
+
await use(container.client);
|
|
73
|
+
},
|
|
74
|
+
synapseConfig: [{}, { scope: "worker" }],
|
|
75
|
+
_homeserver: [
|
|
76
|
+
async ({ logger }, use) => {
|
|
77
|
+
const container = new SynapseContainer().withLogConsumer(logger.getConsumer("synapse"));
|
|
78
|
+
await use(container);
|
|
79
|
+
},
|
|
80
|
+
{ scope: "worker" },
|
|
81
|
+
],
|
|
82
|
+
homeserver: [
|
|
83
|
+
async ({ logger, network, _homeserver: homeserver, synapseConfig, mas }, use) => {
|
|
84
|
+
if (homeserver instanceof SynapseContainer) {
|
|
85
|
+
homeserver.withConfig(synapseConfig);
|
|
86
|
+
}
|
|
87
|
+
const container = await homeserver
|
|
88
|
+
.withNetwork(network)
|
|
89
|
+
.withNetworkAliases("homeserver")
|
|
90
|
+
.withLogConsumer(logger.getConsumer("homeserver"))
|
|
91
|
+
.withMatrixAuthenticationService(mas)
|
|
92
|
+
.start();
|
|
93
|
+
await use(container);
|
|
94
|
+
await container.stop();
|
|
95
|
+
},
|
|
96
|
+
{ scope: "worker" },
|
|
97
|
+
],
|
|
98
|
+
mas: [
|
|
99
|
+
// eslint-disable-next-line no-empty-pattern
|
|
100
|
+
async ({}, use) => {
|
|
101
|
+
// we stub the mas fixture to allow `homeserver` to depend on it to ensure
|
|
102
|
+
// when it is specified by `masHomeserver` it is started before the homeserver
|
|
103
|
+
await use(undefined);
|
|
104
|
+
},
|
|
105
|
+
{ scope: "worker" },
|
|
106
|
+
],
|
|
107
|
+
context: async ({ logger, context, request, homeserver }, use, testInfo) => {
|
|
108
|
+
homeserver.setRequest(request);
|
|
109
|
+
await logger.onTestStarted(context);
|
|
110
|
+
await use(context);
|
|
111
|
+
await logger.onTestFinished(testInfo);
|
|
112
|
+
await homeserver.onTestFinished(testInfo);
|
|
113
|
+
},
|
|
114
|
+
});
|