mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
test(e2e): isolate accounts for parallel workers
This commit is contained in:
21 files changed
+257
-465
No files matched your search
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/knip@6/schema.json",
|
||||
"entry": ["src/sw.ts", "scripts/**/*.js"],
|
||||
"entry": [
|
||||
"src/sw.ts",
|
||||
"scripts/**/*.js",
|
||||
"tests/e2e/global.setup.ts",
|
||||
"tests/e2e/global.teardown.ts"
|
||||
],
|
||||
"ignore": ["src/test/choochmeque-notifications-stub.ts"],
|
||||
"ignoreExportsUsedInFile": {
|
||||
"interface": true,
|
||||
|
||||
+21
-17
@@ -4,37 +4,44 @@ export default defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
testMatch: '**/*.spec.ts',
|
||||
snapshotPathTemplate: 'tests/e2e/__screenshots__/{projectName}/{testFileName}/{arg}{ext}',
|
||||
// Every context shares one Matrix account and device id from the seeded
|
||||
// storageState, so concurrent clients contend over sync and crypto state.
|
||||
// Parallelising would need a worker-scoped account fixture; the suite runs in
|
||||
// well under a minute serially, so it is not worth the plumbing.
|
||||
fullyParallel: false,
|
||||
workers: 1,
|
||||
fullyParallel: true,
|
||||
workers: 4,
|
||||
// Locally a failure should surface at once; CI keeps retries for flakes.
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
reporter: [['html', { open: 'never' }], ['list']],
|
||||
globalSetup: './tests/e2e/global-setup.ts',
|
||||
// Tests run in 3-6s against a built app; this is headroom, not a wait budget.
|
||||
timeout: 60_000,
|
||||
expect: {
|
||||
toHaveScreenshot: { maxDiffPixelRatio: 0.01 },
|
||||
},
|
||||
use: {
|
||||
baseURL: 'http://localhost:8081',
|
||||
storageState: 'tests/e2e/.auth/state.json',
|
||||
baseURL: 'http://127.0.0.1:4175',
|
||||
storageState: 'tests/e2e/.auth/state-4175.json',
|
||||
trace: 'on-first-retry',
|
||||
// Sheets skip their entrance animation here, so a click cannot land mid-slide.
|
||||
reducedMotion: 'reduce',
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: 'setup',
|
||||
testMatch: /global\.setup\.ts/,
|
||||
teardown: 'teardown',
|
||||
retries: 0,
|
||||
},
|
||||
{
|
||||
name: 'teardown',
|
||||
testMatch: /global\.teardown\.ts/,
|
||||
},
|
||||
// touch.spec.ts drives page.touchscreen, which throws unless hasTouch is set.
|
||||
{
|
||||
name: 'desktop',
|
||||
dependencies: ['setup'],
|
||||
testIgnore: /touch\.spec\.ts/,
|
||||
use: { ...devices['Desktop Chrome'], viewport: { width: 1280, height: 800 } },
|
||||
},
|
||||
{
|
||||
name: 'mobile',
|
||||
dependencies: ['setup'],
|
||||
testIgnore: /touch\.spec\.ts/,
|
||||
use: { ...devices['Desktop Chrome'], viewport: { width: 390, height: 844 } },
|
||||
},
|
||||
@@ -42,19 +49,16 @@ export default defineConfig({
|
||||
// which the `mobile` project (a viewport-narrowed desktop) cannot reach.
|
||||
{
|
||||
name: 'touch',
|
||||
dependencies: ['setup'],
|
||||
testMatch: ['**/touch.spec.ts', '**/permalink-jump.spec.ts'],
|
||||
use: { ...devices['Pixel 7'] },
|
||||
},
|
||||
],
|
||||
webServer: {
|
||||
// A real build, not the dev server: no HMR and no dependency optimiser, both
|
||||
// of which invalidate the module graph mid-run and make the suite lie.
|
||||
// Port 8081, not the dev server's 8080, so a running `pnpm dev` is untouched.
|
||||
command: 'pnpm run build && pnpm exec vite preview --port 8081 --strictPort',
|
||||
url: 'http://localhost:8081',
|
||||
// Never reuse: a leftover server would silently serve a stale build. The
|
||||
// build is ~30s, which is worth paying to know what is under test.
|
||||
// Test the production build.
|
||||
command: 'pnpm run build && pnpm exec vite preview --host 127.0.0.1 --port 4175 --strictPort',
|
||||
url: 'http://127.0.0.1:4175',
|
||||
reuseExistingServer: false,
|
||||
// ~35s observed (31s build + preview start), with headroom for a cold CI box.
|
||||
timeout: 180_000,
|
||||
env: { NODE_OPTIONS: '--max-old-space-size=8192' },
|
||||
},
|
||||
|
||||
@@ -61,7 +61,10 @@ process.on('SIGTERM', () => process.exit(143));
|
||||
|
||||
await waitForServer();
|
||||
|
||||
const result = spawnSync('pnpm', ['exec', 'playwright', 'test', ...process.argv.slice(2)], {
|
||||
const args = process.argv.slice(2);
|
||||
if (args[0] === '--') args.shift();
|
||||
|
||||
const result = spawnSync('pnpm', ['exec', 'playwright', 'test', ...args], {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, PW_TEST_CONNECT_WS_ENDPOINT: `ws://127.0.0.1:${port}/` },
|
||||
});
|
||||
|
||||
+14
-9
@@ -1,6 +1,6 @@
|
||||
# End-to-end tests
|
||||
|
||||
Playwright drives the real app (vite dev on `:8080`) against a throwaway
|
||||
Playwright drives a production build served by Vite preview on `:4175` against a throwaway
|
||||
[Continuwuity](https://continuwuity.org) homeserver started per run. The suite
|
||||
covers functional flows (login, sync, navigation, timeline) and captures
|
||||
screenshots for layout regression.
|
||||
@@ -26,21 +26,26 @@ because font rendering differs between hosts. Regenerate them with
|
||||
|
||||
## How it works
|
||||
|
||||
`global-setup.ts`:
|
||||
`global.setup.ts`:
|
||||
|
||||
1. Starts a Continuwuity container with open registration.
|
||||
2. Registers a user and seeds deterministic rooms/messages over the client-server API.
|
||||
3. Injects the session into the app's `localStorage` (`matrixSessions` +
|
||||
`matrixActiveSession`) and saves it as Playwright `storageState`, so specs
|
||||
start already logged in without driving the login UI.
|
||||
2. Registers a bootstrap user and seeds deterministic rooms/messages over the client-server API.
|
||||
3. Gives each Playwright worker its own identically seeded user and `storageState`,
|
||||
isolating sync and crypto state while specs run in parallel.
|
||||
4. Saves the container id for `global.teardown.ts`.
|
||||
5. Injects the session into the app's `localStorage` (`matrixSessions` +
|
||||
`matrixActiveSession`), so specs start already logged in without driving the
|
||||
login UI.
|
||||
|
||||
The container is stopped in the returned teardown.
|
||||
`global.teardown.ts` removes the container after the dependent projects finish.
|
||||
|
||||
## Adding a test
|
||||
|
||||
Specs live in `tests/e2e/*.spec.ts` and run against both a desktop and a mobile
|
||||
viewport. Assert behaviour with locators; add `toHaveScreenshot` where a layout
|
||||
baseline is useful. Screenshot baselines live in `tests/e2e/__screenshots__`.
|
||||
viewport. The touch project runs touch interactions and permalink navigation;
|
||||
the narrow mobile project covers the rest of the responsive flows. Assert
|
||||
behaviour with locators; add `toHaveScreenshot` where a layout baseline is
|
||||
useful. Screenshot baselines live in `tests/e2e/__screenshots__`.
|
||||
|
||||
Notes when adding screenshots:
|
||||
|
||||
|
||||
@@ -1,51 +1,13 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { registerUser } from './fixtures/continuwuity';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { homeserverBaseUrl, loginAsFreshUser, PASSWORD } from './fixtures/session';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
const UPLOAD_ROUTE = '**/_matrix/client/*/keys/device_signing/upload';
|
||||
const TICKET_PATH = '/e2e-oauth-ticket';
|
||||
const SESSION = 'e2e-reset-oauth-session';
|
||||
|
||||
type AuthDict = { type?: string; session?: string };
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string,
|
||||
slidingSync = false
|
||||
): Promise<void> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
...(slidingSync ? { slidingSyncOptIn: true } : {}),
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
}
|
||||
|
||||
const recoveryKeyShown = (page: Page) => page.getByRole('button', { name: 'Copy', exact: true });
|
||||
|
||||
test.describe('device verification reset', () => {
|
||||
@@ -53,7 +15,12 @@ test.describe('device verification reset', () => {
|
||||
test.setTimeout(180_000);
|
||||
const storageStatePath = testInfo.project.use.storageState as string;
|
||||
const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
|
||||
await loginAsFreshUser(page, hsBaseUrl, `reset-uia-${testInfo.project.name}-${process.pid}`);
|
||||
await loginAsFreshUser(
|
||||
page,
|
||||
hsBaseUrl,
|
||||
`reset-uia-${testInfo.project.name}-${process.pid}`,
|
||||
false
|
||||
);
|
||||
|
||||
await page.goto('/settings/devices');
|
||||
|
||||
@@ -92,7 +59,12 @@ test.describe('device verification reset', () => {
|
||||
test.setTimeout(180_000);
|
||||
const storageStatePath = testInfo.project.use.storageState as string;
|
||||
const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
|
||||
await loginAsFreshUser(page, hsBaseUrl, `reset-oauth-${testInfo.project.name}-${process.pid}`);
|
||||
await loginAsFreshUser(
|
||||
page,
|
||||
hsBaseUrl,
|
||||
`reset-oauth-${testInfo.project.name}-${process.pid}`,
|
||||
false
|
||||
);
|
||||
|
||||
await page.goto('/settings/devices');
|
||||
|
||||
@@ -159,7 +131,8 @@ test.describe('device verification reset', () => {
|
||||
await loginAsFreshUser(
|
||||
page,
|
||||
hsBaseUrl,
|
||||
`reset-oauth-race-${testInfo.project.name}-${process.pid}`
|
||||
`reset-oauth-race-${testInfo.project.name}-${process.pid}`,
|
||||
false
|
||||
);
|
||||
|
||||
await page.goto('/settings/devices');
|
||||
@@ -228,28 +201,4 @@ test.describe('device verification reset', () => {
|
||||
await expect(recoveryKeyShown(page)).toBeVisible({ timeout: 120_000 });
|
||||
await expect(page.getByText('Account Authorization')).toBeHidden();
|
||||
});
|
||||
|
||||
test('sets up verification when the session syncs over sliding sync', async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
// Sliding sync serialises the crypto bootstrap across long-poll round-trips,
|
||||
// so this test needs more headroom than the 180s its siblings use.
|
||||
test.setTimeout(240_000);
|
||||
const storageStatePath = testInfo.project.use.storageState as string;
|
||||
const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
|
||||
await loginAsFreshUser(
|
||||
page,
|
||||
hsBaseUrl,
|
||||
`setup-sliding-${testInfo.project.name}-${process.pid}`,
|
||||
true
|
||||
);
|
||||
|
||||
await page.goto('/settings/devices');
|
||||
|
||||
await page.getByRole('button', { name: 'Enable' }).click({ timeout: 180_000 });
|
||||
await expect(page.getByText('Setup Device Verification')).toBeVisible();
|
||||
await page.locator('form').getByRole('button', { name: 'Continue' }).click();
|
||||
|
||||
await expect(recoveryKeyShown(page)).toBeVisible({ timeout: 180_000 });
|
||||
});
|
||||
});
|
||||
@@ -1,41 +1,11 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { registerUser } from './fixtures/continuwuity';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { homeserverBaseUrl, loginAsFreshUser } from './fixtures/session';
|
||||
|
||||
const UPLOAD_ROUTE = '**/_matrix/client/*/keys/device_signing/upload';
|
||||
const TICKET_PATH = '/e2e-oauth-ticket';
|
||||
const SESSION = 'e2e-oauth-session';
|
||||
|
||||
type AuthDict = { type?: string; session?: string };
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(page: Page, baseUrl: string, name: string): Promise<void> {
|
||||
const user = await registerUser(baseUrl, name, 'test-passw0rd');
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
}
|
||||
|
||||
test.describe('device verification setup', () => {
|
||||
test('completes the m.oauth UIA stage and reveals the recovery key', async ({
|
||||
@@ -44,7 +14,12 @@ test.describe('device verification setup', () => {
|
||||
}, testInfo) => {
|
||||
const storageStatePath = testInfo.project.use.storageState as string;
|
||||
const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
|
||||
await loginAsFreshUser(page, hsBaseUrl, `oauth-uia-${testInfo.project.name}-${process.pid}`);
|
||||
await loginAsFreshUser(
|
||||
page,
|
||||
hsBaseUrl,
|
||||
`oauth-uia-${testInfo.project.name}-${process.pid}`,
|
||||
false
|
||||
);
|
||||
|
||||
const ticketUrl = `${baseURL}${TICKET_PATH}`;
|
||||
const authDicts: (AuthDict | undefined)[] = [];
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import { GenericContainer, Wait } from 'testcontainers';
|
||||
|
||||
const IMAGE = 'ghcr.io/continuwuity/continuwuity:latest';
|
||||
const CS_PORT = 8008;
|
||||
const SERVER_NAME = 'test.local';
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export type RegisteredUser = {
|
||||
userId: string;
|
||||
@@ -12,6 +15,7 @@ export type RegisteredUser = {
|
||||
|
||||
export type TestHomeserver = {
|
||||
baseUrl: string;
|
||||
containerId: string;
|
||||
register: (username: string, password: string) => Promise<RegisteredUser>;
|
||||
stop: () => Promise<void>;
|
||||
};
|
||||
@@ -34,12 +38,15 @@ export async function startContinuwuity(): Promise<TestHomeserver> {
|
||||
.withTmpFs({ '/database': 'rw' })
|
||||
.withWaitStrategy(Wait.forHttp('/_matrix/client/versions', CS_PORT).forStatusCode(200))
|
||||
.withStartupTimeout(120_000)
|
||||
// The teardown project removes this container by id.
|
||||
.withAutoCleanup(false)
|
||||
.start();
|
||||
|
||||
const baseUrl = `http://${container.getHost()}:${container.getMappedPort(CS_PORT)}`;
|
||||
|
||||
return {
|
||||
baseUrl,
|
||||
containerId: container.getId(),
|
||||
register: (username, password) => registerUser(baseUrl, username, password),
|
||||
stop: async () => {
|
||||
await container.stop();
|
||||
@@ -47,6 +54,10 @@ export async function startContinuwuity(): Promise<TestHomeserver> {
|
||||
};
|
||||
}
|
||||
|
||||
export async function removeContinuwuity(containerId: string): Promise<void> {
|
||||
await execFileAsync('docker', ['rm', '-f', containerId]);
|
||||
}
|
||||
|
||||
export async function registerUser(
|
||||
baseUrl: string,
|
||||
username: string,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
const fallbackPort = '4175';
|
||||
|
||||
const appPort = () => fallbackPort;
|
||||
|
||||
export const e2eBaseUrl = () => `http://127.0.0.1:${appPort()}`;
|
||||
|
||||
export const e2eStorageStatePath = () => join('tests/e2e/.auth', `state-${appPort()}.json`);
|
||||
|
||||
export const e2eHomeserverPath = () => join('tests/e2e/.auth', `homeserver-${appPort()}.json`);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { registerUser, type RegisteredUser } from './continuwuity';
|
||||
import { createRoom, registerUser, sendText, type RegisteredUser } from './continuwuity';
|
||||
|
||||
export const PASSWORD = 'test-passw0rd';
|
||||
|
||||
@@ -12,6 +12,60 @@ export type InjectedSession = {
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
type StorageState = {
|
||||
cookies: [];
|
||||
origins: {
|
||||
origin: string;
|
||||
localStorage: { name: string; value: string }[];
|
||||
}[];
|
||||
};
|
||||
|
||||
export async function createSeededStorageState(
|
||||
baseUrl: string,
|
||||
origin: string,
|
||||
username: string
|
||||
): Promise<StorageState> {
|
||||
const user = await registerUser(baseUrl, username, PASSWORD);
|
||||
const general = await createRoom(baseUrl, user.accessToken, {
|
||||
name: 'General',
|
||||
preset: 'private_chat',
|
||||
});
|
||||
await sendText(baseUrl, user.accessToken, general, 'Welcome to the test room.', 1);
|
||||
await sendText(baseUrl, user.accessToken, general, 'Layout baseline seed message.', 2);
|
||||
|
||||
const random = await createRoom(baseUrl, user.accessToken, {
|
||||
name: 'Random',
|
||||
preset: 'private_chat',
|
||||
});
|
||||
await sendText(baseUrl, user.accessToken, random, 'Another seeded room.', 1);
|
||||
|
||||
await createRoom(baseUrl, user.accessToken, {
|
||||
name: 'Test Space',
|
||||
preset: 'private_chat',
|
||||
creation_content: { type: 'm.space' },
|
||||
});
|
||||
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
};
|
||||
|
||||
return {
|
||||
cookies: [],
|
||||
origins: [
|
||||
{
|
||||
origin,
|
||||
localStorage: [
|
||||
{ name: 'matrixSessions', value: JSON.stringify([session]) },
|
||||
{ name: 'matrixActiveSession', value: JSON.stringify(session.userId) },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** Reads the homeserver the global setup provisioned out of the saved storage state. */
|
||||
export async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
|
||||
@@ -1,11 +1,51 @@
|
||||
import { access, mkdir, writeFile } from 'node:fs/promises';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { test as base } from '@playwright/test';
|
||||
import { AppShell } from '../pages/AppShell';
|
||||
import { e2eBaseUrl, e2eStorageStatePath } from './runtime';
|
||||
import { createSeededStorageState, homeserverBaseUrl } from './session';
|
||||
|
||||
type Fixtures = {
|
||||
app: AppShell;
|
||||
};
|
||||
|
||||
export const test = base.extend<Fixtures>({
|
||||
type WorkerFixtures = {
|
||||
workerStorageState: string;
|
||||
};
|
||||
|
||||
export const test = base.extend<Fixtures, WorkerFixtures>({
|
||||
storageState: async ({ workerStorageState }, use) => {
|
||||
await use(workerStorageState);
|
||||
},
|
||||
workerStorageState: [
|
||||
async ({ browserName }, use, workerInfo) => {
|
||||
const storageStatePath = join(
|
||||
workerInfo.project.outputDir,
|
||||
'.auth',
|
||||
`${workerInfo.parallelIndex}.json`
|
||||
);
|
||||
const exists = await access(storageStatePath)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (exists) {
|
||||
await use(storageStatePath);
|
||||
return;
|
||||
}
|
||||
await mkdir(dirname(storageStatePath), { recursive: true });
|
||||
await writeFile(
|
||||
storageStatePath,
|
||||
JSON.stringify(
|
||||
await createSeededStorageState(
|
||||
await homeserverBaseUrl(e2eStorageStatePath()),
|
||||
e2eBaseUrl(),
|
||||
`worker-${workerInfo.project.name}-${browserName}-${workerInfo.parallelIndex}`
|
||||
)
|
||||
)
|
||||
);
|
||||
await use(storageStatePath);
|
||||
},
|
||||
{ scope: 'worker' },
|
||||
],
|
||||
app: async ({ page }, use) => {
|
||||
const app = new AppShell(page);
|
||||
await app.open();
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { dirname } from 'node:path';
|
||||
import type { FullConfig } from '@playwright/test';
|
||||
import { createRoom, sendText, startContinuwuity } from './fixtures/continuwuity';
|
||||
import { LOGIN_PASSWORD, LOGIN_USERNAME } from './fixtures/loginAccount';
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
};
|
||||
|
||||
export default async function globalSetup(config: FullConfig): Promise<() => Promise<void>> {
|
||||
const { baseURL, storageState } = config.projects[0]!.use;
|
||||
const authPath = storageState as string;
|
||||
|
||||
const hs = await startContinuwuity();
|
||||
const user = await hs.register('alice', 'test-passw0rd');
|
||||
|
||||
// login.spec.ts signs in for real, so it needs its own account and the homeserver url.
|
||||
await hs.register(LOGIN_USERNAME, LOGIN_PASSWORD);
|
||||
process.env.TEST_HOMESERVER_URL = hs.baseUrl;
|
||||
|
||||
const general = await createRoom(hs.baseUrl, user.accessToken, {
|
||||
name: 'General',
|
||||
preset: 'private_chat',
|
||||
});
|
||||
await sendText(hs.baseUrl, user.accessToken, general, 'Welcome to the test room.', 1);
|
||||
await sendText(hs.baseUrl, user.accessToken, general, 'Layout baseline seed message.', 2);
|
||||
|
||||
const random = await createRoom(hs.baseUrl, user.accessToken, {
|
||||
name: 'Random',
|
||||
preset: 'private_chat',
|
||||
});
|
||||
await sendText(hs.baseUrl, user.accessToken, random, 'Another seeded room.', 1);
|
||||
|
||||
const space = await createRoom(hs.baseUrl, user.accessToken, {
|
||||
name: 'Test Space',
|
||||
preset: 'private_chat',
|
||||
creation_content: { type: 'm.space' },
|
||||
});
|
||||
process.env.SEEDED_SPACE_ID = space;
|
||||
|
||||
const session: InjectedSession = {
|
||||
baseUrl: hs.baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
};
|
||||
|
||||
await mkdir(dirname(authPath), { recursive: true });
|
||||
await writeFile(
|
||||
authPath,
|
||||
JSON.stringify({
|
||||
cookies: [],
|
||||
origins: [
|
||||
{
|
||||
origin: new URL(baseURL!).origin,
|
||||
localStorage: [
|
||||
{ name: 'matrixSessions', value: JSON.stringify([session]) },
|
||||
{ name: 'matrixActiveSession', value: JSON.stringify(session.userId) },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
return async () => {
|
||||
await hs.stop();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { dirname } from 'node:path';
|
||||
import { test as setup } from '@playwright/test';
|
||||
import { startContinuwuity } from './fixtures/continuwuity';
|
||||
import { LOGIN_PASSWORD, LOGIN_USERNAME } from './fixtures/loginAccount';
|
||||
import { e2eBaseUrl, e2eHomeserverPath, e2eStorageStatePath } from './fixtures/runtime';
|
||||
import { createSeededStorageState } from './fixtures/session';
|
||||
|
||||
setup('provision homeserver', async ({ browserName }) => {
|
||||
const authPath = e2eStorageStatePath();
|
||||
const hs = await startContinuwuity();
|
||||
|
||||
await hs.register(LOGIN_USERNAME, LOGIN_PASSWORD);
|
||||
await mkdir(dirname(authPath), { recursive: true });
|
||||
await writeFile(
|
||||
authPath,
|
||||
JSON.stringify(
|
||||
await createSeededStorageState(hs.baseUrl, e2eBaseUrl(), `bootstrap-${browserName}`)
|
||||
)
|
||||
);
|
||||
await writeFile(e2eHomeserverPath(), JSON.stringify({ containerId: hs.containerId }));
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test as teardown } from '@playwright/test';
|
||||
import { removeContinuwuity } from './fixtures/continuwuity';
|
||||
import { e2eHomeserverPath } from './fixtures/runtime';
|
||||
|
||||
teardown('remove homeserver', async ({ browserName }) => {
|
||||
let containerId: string;
|
||||
try {
|
||||
({ containerId } = JSON.parse(await readFile(e2eHomeserverPath(), 'utf8')) as {
|
||||
containerId: string;
|
||||
});
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;
|
||||
throw error;
|
||||
}
|
||||
await removeContinuwuity(containerId);
|
||||
void browserName;
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import {
|
||||
createRoom,
|
||||
getRoomMessages,
|
||||
@@ -9,47 +8,9 @@ import {
|
||||
sendText,
|
||||
} from './fixtures/continuwuity';
|
||||
import { AppShell } from './pages/AppShell';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
import { homeserverBaseUrl, loginAsFreshUser, PASSWORD } from './fixtures/session';
|
||||
const BURST_SIZE = 8;
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string
|
||||
): Promise<{ accessToken: string }> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
slidingSyncOptIn: true,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
return user;
|
||||
}
|
||||
|
||||
test.describe('live timeline', () => {
|
||||
test('renders an editor-sent message as a single server-confirmed row', async ({
|
||||
page,
|
||||
@@ -112,12 +73,14 @@ test.describe('live timeline', () => {
|
||||
});
|
||||
await inviteUser(hsBaseUrl, user.accessToken, room, remote.userId);
|
||||
await joinRoom(hsBaseUrl, remote.accessToken, room);
|
||||
const readyEventId = await sendText(hsBaseUrl, user.accessToken, room, `${tag}-ready`, 1);
|
||||
|
||||
await page.goto('/');
|
||||
await expect(page.getByText(`${tag} Room`).first()).toBeVisible({
|
||||
timeout: 180_000,
|
||||
});
|
||||
await app.openRoom(`${tag} Room`);
|
||||
await expect(app.messageByEventId(readyEventId)).toBeVisible({ timeout: 120_000 });
|
||||
|
||||
for (let i = 1; i <= BURST_SIZE; i += 1) {
|
||||
await sendText(hsBaseUrl, remote.accessToken, room, `${tag}-b${i}`, i);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { LOGIN_PASSWORD, LOGIN_USERNAME } from './fixtures/loginAccount';
|
||||
import { e2eStorageStatePath } from './fixtures/runtime';
|
||||
import { homeserverBaseUrl } from './fixtures/session';
|
||||
|
||||
const CLIENT_READY_TIMEOUT = 30_000;
|
||||
|
||||
// The container homeserver is reachable only by url ("http://127.0.0.1:<port>"), which is the
|
||||
// shape that used to break: as a path segment it needs %2F, and hosting rewrites that to "/".
|
||||
const homeserverUrl = () => {
|
||||
const url = process.env.TEST_HOMESERVER_URL;
|
||||
if (!url) throw new Error('TEST_HOMESERVER_URL is not set by global setup');
|
||||
return url;
|
||||
};
|
||||
const homeserverUrl = (storageStatePath: string) => homeserverBaseUrl(storageStatePath);
|
||||
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
@@ -18,7 +16,7 @@ test.describe('password login against a homeserver given as a url', () => {
|
||||
await page.goto('/');
|
||||
await expect(page).toHaveURL(/\/login\?server=/);
|
||||
|
||||
const server = homeserverUrl();
|
||||
const server = await homeserverUrl(e2eStorageStatePath());
|
||||
await page.getByRole('textbox').first().fill(server);
|
||||
await page.getByRole('textbox').first().press('Enter');
|
||||
|
||||
@@ -34,7 +32,7 @@ test.describe('password login against a homeserver given as a url', () => {
|
||||
});
|
||||
|
||||
test('survives a reload of the login url', async ({ page }) => {
|
||||
const server = homeserverUrl();
|
||||
const server = await homeserverUrl(e2eStorageStatePath());
|
||||
await page.goto(`/login?server=${encodeURIComponent(server)}`);
|
||||
await page.reload();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
|
||||
async function openApp(page: Page): Promise<void> {
|
||||
await page.goto('/');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import {
|
||||
createRoom,
|
||||
inviteUser,
|
||||
@@ -73,7 +74,7 @@ async function enterRoom(page: Page, fixture: Fixture): Promise<void> {
|
||||
timeout: SYNC_TIMEOUT,
|
||||
});
|
||||
await fixture.app.openRoom(`${fixture.tag} Relay`);
|
||||
await expect(page.getByText(`${fixture.tag}-seed-${SEED_SIZE}`, { exact: true })).toBeVisible({
|
||||
await expect(fixture.app.messageByEventId(fixture.seedIds.at(-1)!)).toBeVisible({
|
||||
timeout: SYNC_TIMEOUT,
|
||||
});
|
||||
}
|
||||
@@ -241,40 +242,6 @@ for (const transport of syncTransports) {
|
||||
await expectOrderedTimeline(page, fixture);
|
||||
});
|
||||
|
||||
test('returns to a contiguous live tail when jumping to latest after a notification jump', async ({
|
||||
page,
|
||||
context,
|
||||
}, testInfo) => {
|
||||
test.skip(testInfo.project.name !== 'desktop', 'desktop-focused');
|
||||
const fixture = await openSeededRoom(
|
||||
page,
|
||||
testInfo.project.use.storageState as string,
|
||||
'nj-live',
|
||||
transport.slidingSyncOptIn
|
||||
);
|
||||
await enterRoom(page, fixture);
|
||||
|
||||
await context.setOffline(true);
|
||||
const targetEventId = await sendMissedBurst(fixture, 5);
|
||||
await fixture.app.receiveNotificationClick(
|
||||
fixture.alice.userId,
|
||||
fixture.roomId,
|
||||
targetEventId
|
||||
);
|
||||
await context.setOffline(false);
|
||||
|
||||
await expectJumpedTo(page, fixture, targetEventId);
|
||||
await expect(fixture.app.jumpToLatestButton).toBeVisible({ timeout: SYNC_TIMEOUT });
|
||||
await fixture.app.jumpToLatestButton.click();
|
||||
|
||||
await expect(
|
||||
page.getByText(`${fixture.tag}-burst-${BURST_SIZE}`, { exact: true })
|
||||
).toBeVisible({
|
||||
timeout: SYNC_TIMEOUT,
|
||||
});
|
||||
await expectOrderedTimeline(page, fixture);
|
||||
});
|
||||
|
||||
test('keeps the timeline ordered across two consecutive notification jumps', async ({
|
||||
page,
|
||||
context,
|
||||
|
||||
@@ -1,53 +1,12 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { createRoom, registerUser, sendMessage, sendText } from './fixtures/continuwuity';
|
||||
import {
|
||||
timelineScroller,
|
||||
wheelToBottomUntilVisible,
|
||||
wheelToTopUntilVisible,
|
||||
} from './fixtures/timelineOrder';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { createRoom, sendMessage, sendText } from './fixtures/continuwuity';
|
||||
import { homeserverBaseUrl, loginAsFreshUser } from './fixtures/session';
|
||||
import { wheelToBottomUntilVisible, wheelToTopUntilVisible } from './fixtures/timelineOrder';
|
||||
import { AppShell } from './pages/AppShell';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
const HISTORY_SIZE = 100;
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string
|
||||
): Promise<{ accessToken: string }> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
slidingSyncOptIn: true,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
return user;
|
||||
}
|
||||
|
||||
const permalinkTo = (roomId: string, eventId: string): string =>
|
||||
`https://matrix.to/#/${roomId}/${eventId}`;
|
||||
|
||||
@@ -107,7 +66,7 @@ test.describe('permalink jumps', () => {
|
||||
|
||||
await page.goto('/');
|
||||
await expect(page.getByText(`${tag} Room`).first()).toBeVisible({ timeout: 180_000 });
|
||||
await app.openRoom(`${tag} Room`);
|
||||
await page.goto(`/home/${encodeURIComponent(room)}`);
|
||||
|
||||
const targetRow = app.messageByEventId(targetId);
|
||||
await expect(permalinkLink(page, targetId)).toBeVisible({ timeout: 60_000 });
|
||||
@@ -130,11 +89,6 @@ test.describe('permalink jumps', () => {
|
||||
await wheelToBottomUntilVisible(page, `${tag}-${HISTORY_SIZE}`);
|
||||
await expect(app.messageByEventId(latestId)).toBeVisible({ timeout: 60_000 });
|
||||
|
||||
const sentBody = `${tag}-after-jump`;
|
||||
await app.sendTextMessage(sentBody);
|
||||
await expect(timelineScroller(page).getByText(sentBody, { exact: true })).toBeVisible({
|
||||
timeout: 60_000,
|
||||
});
|
||||
await expect(app.messageByEventId(latestId)).toBeVisible({ timeout: 60_000 });
|
||||
});
|
||||
|
||||
|
||||
@@ -1,50 +1,11 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { createRoom, registerUser, sendText, setRoomName } from './fixtures/continuwuity';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { createRoom, sendText, setRoomName } from './fixtures/continuwuity';
|
||||
import { homeserverBaseUrl, loginAsFreshUser } from './fixtures/session';
|
||||
import { AppShell, CLIENT_READY_TIMEOUT } from './pages/AppShell';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
|
||||
// More rooms than the window the joined list used to shrink to.
|
||||
const FILLER_ROOM_COUNT = 5;
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string
|
||||
): Promise<{ accessToken: string }> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
slidingSyncOptIn: true,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
return user;
|
||||
}
|
||||
|
||||
test.describe('sliding sync room state', () => {
|
||||
// Regression guard for #1389: reintroducing the post-hydration narrowing of the
|
||||
// joined list fails this. Rooms outside the server's own window are not covered.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import { createRoom, inviteUser, joinRoom, registerUser, sendText } from './fixtures/continuwuity';
|
||||
import { homeserverBaseUrl, loginAsFreshUser, PASSWORD } from './fixtures/session';
|
||||
import {
|
||||
expectTimelineAtBottom,
|
||||
timelineScroller,
|
||||
@@ -8,51 +9,12 @@ import {
|
||||
} from './fixtures/timelineOrder';
|
||||
import { AppShell } from './pages/AppShell';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
const HISTORY_SIZE = 100;
|
||||
const SEND_DELAYS_MS = [0, 150, 0, 400, 50];
|
||||
const TEST_TIMEOUT = 300_000;
|
||||
const SYNC_TIMEOUT = 45_000;
|
||||
const UI_TIMEOUT = 30_000;
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string,
|
||||
slidingSyncOptIn: boolean
|
||||
): Promise<{ accessToken: string }> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
slidingSyncOptIn,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
return user;
|
||||
}
|
||||
|
||||
let txnCounter = 1;
|
||||
|
||||
const nextTxnId = () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { test, expect } from './fixtures/test';
|
||||
import {
|
||||
createRoom,
|
||||
getRoomMessages,
|
||||
@@ -8,47 +7,9 @@ import {
|
||||
registerUser,
|
||||
sendText,
|
||||
} from './fixtures/continuwuity';
|
||||
import { homeserverBaseUrl, loginAsFreshUser, PASSWORD } from './fixtures/session';
|
||||
import { AppShell } from './pages/AppShell';
|
||||
|
||||
const PASSWORD = 'test-passw0rd';
|
||||
|
||||
type InjectedSession = {
|
||||
baseUrl: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
accessToken: string;
|
||||
slidingSyncOptIn?: boolean;
|
||||
};
|
||||
|
||||
async function homeserverBaseUrl(storageStatePath: string): Promise<string> {
|
||||
const state = JSON.parse(await readFile(storageStatePath, 'utf8')) as {
|
||||
origins: { localStorage: { name: string; value: string }[] }[];
|
||||
};
|
||||
const entry = state.origins[0]!.localStorage.find((item) => item.name === 'matrixSessions')!;
|
||||
return (JSON.parse(entry.value) as InjectedSession[])[0]!.baseUrl;
|
||||
}
|
||||
|
||||
async function loginAsFreshUser(
|
||||
page: Page,
|
||||
baseUrl: string,
|
||||
name: string
|
||||
): Promise<{ accessToken: string; userId: string; deviceId: string }> {
|
||||
const user = await registerUser(baseUrl, name, PASSWORD);
|
||||
const session: InjectedSession = {
|
||||
baseUrl,
|
||||
userId: user.userId,
|
||||
deviceId: user.deviceId,
|
||||
accessToken: user.accessToken,
|
||||
slidingSyncOptIn: true,
|
||||
};
|
||||
await page.addInitScript((injected: InjectedSession) => {
|
||||
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
|
||||
localStorage.setItem('matrixActiveSession', JSON.stringify(injected.userId));
|
||||
localStorage.setItem('dismissNotice', 'true');
|
||||
}, session);
|
||||
return user;
|
||||
}
|
||||
|
||||
let txnCounter = 1;
|
||||
|
||||
test.describe('timeline recovery', () => {
|
||||
|
||||
Reference in new issue
Block a user