Files
AFFiNE-Mirror/tests/affine-cloud/e2e/template.spec.ts
L-Sun a9ad01491c test(core): enable no-floating-promises rule for tests (#11915)
Sometimes, missing `await` in the test code can cause timing issues, leading to test failures. This PR enables the `no-floating-promises` rule for the test code to ensure that such errors do not occur.
2025-04-23 08:17:41 +00:00

34 lines
984 B
TypeScript

import { test } from '@affine-test/kit/playwright';
import { createRandomUser, loginUser } from '@affine-test/kit/utils/cloud';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
test.beforeEach(async ({ page }) => {
const user = await createRandomUser();
await loginUser(page, user);
});
test('import from template should work', async ({ page }) => {
await page.goto('https://affine.pro/templates', { waitUntil: 'load' });
await page.click('.template-list > a:first-child');
const importLink = page.getByText('Use this template');
const href = await importLink.evaluate((el: HTMLElement) => {
const a = el.closest('a');
if (!a) {
throw new Error('Import link not found');
}
return a.href;
});
const url = new URL(href);
await page.goto(url.pathname + url.search);
const btn = page.getByTestId('import-template-to-workspace-btn');
await btn.isVisible();
await btn.click();
await waitForEditorLoad(page);
});