AFFiNE/tests/parallels/affine/affine-workspace.spec.ts
Flrande 35fb10c95b
feat: add preloading template (#2655)
Co-authored-by: Himself65 <himself65@outlook.com>
2023-06-07 17:31:54 +08:00

56 lines
2.0 KiB
TypeScript

import { expect } from '@playwright/test';
import { openHomePage } from '../../libs/load-page';
import { waitEditorLoad } from '../../libs/page-logic';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userA = require('../../fixtures/userA.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userB = require('../../fixtures/userB.json');
import { test } from '@affine-test/kit/playwright';
import {
clickNewPageButton,
clickSideBarCurrentWorkspaceBanner,
} from '../../libs/sidebar';
import { createFakeUser, loginUser } from '../../libs/utils';
import {
assertCurrentWorkspaceFlavour,
createWorkspace,
enableAffineCloudWorkspace,
openWorkspaceListModal,
} from '../../libs/workspace';
test('should login with user A', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
const [a] = await createFakeUser(userA, userB);
await loginUser(page, a);
await clickSideBarCurrentWorkspaceBanner(page);
const footer = page.locator('[data-testid="workspace-list-modal-footer"]');
expect(await footer.getByText(userA.name).isVisible()).toBe(true);
expect(await footer.getByText(userA.email).isVisible()).toBe(true);
await assertCurrentWorkspaceFlavour('local', page);
});
test('should enable affine workspace successfully', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
const [a] = await createFakeUser();
await loginUser(page, a);
const name = `test-${Date.now()}`;
await createWorkspace({ name }, page);
await page.waitForTimeout(50);
await enableAffineCloudWorkspace(page);
await clickNewPageButton(page);
await page.locator('[data-block-is-title="true"]').type('Hello, world!', {
delay: 50,
});
await page.waitForTimeout(1000);
await assertCurrentWorkspaceFlavour('affine', page);
await openWorkspaceListModal(page);
await page.getByTestId('workspace-list-modal-sign-out').click();
await waitEditorLoad(page);
await assertCurrentWorkspaceFlavour('local', page);
});