Files
AFFiNE-Mirror/tests/affine-cloud/e2e/migration.spec.skip.ts
T
fengmk2 ee878e8f27 chore: improve Cloud E2E Test speed (#13103)
Before 11m

![before_wechat_2025-07-09_105625_157](https://github.com/user-attachments/assets/68eb1026-cacd-4d0f-a0b9-e4f76a1df45a)

After 7m

![afterwechat_2025-07-09_110410_383](https://github.com/user-attachments/assets/bc154cfb-88d2-4e25-bfab-bc0ecc0499ce)


#### PR Dependency Tree


* **PR #13103** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Expanded cloud end-to-end test coverage by increasing test shards from
6 to 10 for improved parallelization.
* Added a new suite of end-to-end tests focused on page sharing,
including scenarios for sharing links, table of contents, edgeless mode,
and image previews.
* Removed several redundant or relocated sharing-related tests,
retaining only the reference link verification in the affected suite.
* Updated test output format to use the "list" reporter for clearer test
results.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-09 03:32:14 +00:00

110 lines
2.9 KiB
TypeScript

import { readFile } from 'node:fs/promises';
import { Path, test } from '@affine-test/kit/playwright';
import {
createRandomUser,
deleteUser,
enableCloudWorkspace,
getLoginCookie,
loginUser,
runPrisma,
} from '@affine-test/kit/utils/cloud';
import { coreUrl } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
let user: {
id: string;
name: string;
email: string;
password: string;
};
test.beforeEach(async () => {
user = await createRandomUser();
});
test.beforeEach(async ({ page, context }) => {
await loginUser(page, user, {
beforeLogin: async () => {
expect(await getLoginCookie(context)).toBeUndefined();
},
afterLogin: async () => {
expect(await getLoginCookie(context)).toBeTruthy();
await page.reload();
await waitForEditorLoad(page);
expect(await getLoginCookie(context)).toBeTruthy();
},
});
});
test.afterEach(async () => {
// if you want to keep the user in the database for debugging,
// comment this line
await deleteUser(user.email);
});
// TODO(@eyhn) mock migration from server data after page level upgrade implemented.
test.skip('migration', async ({ page, browser }) => {
let workspaceId: string;
{
// create the old cloud workspace in another browser
const context = await browser.newContext();
const page = await context.newPage();
await loginUser(page, user);
await page.reload();
await createLocalWorkspace(
{
name: 'test',
},
page
);
await enableCloudWorkspace(page);
await clickNewPageButton(page);
await waitForEditorLoad(page);
// http://localhost:8080/workspace/2bc0b6c8-f68d-4dd3-98a8-be746754f9e1/xxx
workspaceId = page.url().split('/')[4];
await runPrisma(async client => {
const sqls = (
await readFile(
Path.dir(import.meta.url).join(
'fixtures',
'0.9.0-canary.9-snapshots.sql'
).value,
'utf-8'
)
)
.replaceAll('2bc0b6c8-f68d-4dd3-98a8-be746754f9e1', workspaceId)
.split('\n');
await client.snapshot.deleteMany({
where: {
workspaceId,
},
});
for (const sql of sqls) {
await client.$executeRawUnsafe(sql);
}
});
await page.close();
}
await page.reload();
await page.waitForTimeout(1000);
await page.goto(`${coreUrl}/workspace/${workspaceId}/all`);
await page.getByTestId('upgrade-workspace-button').click();
await expect(page.getByText('Refresh Current Page')).toBeVisible({
timeout: 60000,
});
await page.goto(
// page 'F1SX6cgNxy' has edgeless mode
`${coreUrl}/workspace/${workspaceId}/F1SX6cgNxy`
);
await page.waitForTimeout(5000);
await page.reload();
await waitForEditorLoad(page);
});