AFFiNE/tests/parallels/affine/affine-workspace.spec.ts

65 lines
2.5 KiB
TypeScript
Raw Normal View History

import { expect } from '@playwright/test';
import { waitMarkdownImported } from '../../libs/page-logic';
2023-03-28 08:25:16 +03:00
// 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 '../../libs/playwright';
import { clickCollaborationPanel } from '../../libs/setting';
import {
clickNewPageButton,
clickSideBarAllPageButton,
clickSideBarCurrentWorkspaceBanner,
clickSideBarSettingButton,
} from '../../libs/sidebar';
import { createFakeUser, loginUser, openHomePage } from '../../libs/utils';
import {
assertCurrentWorkspaceFlavour,
createWorkspace,
2023-04-07 00:14:23 +03:00
openWorkspaceListModal,
} from '../../libs/workspace';
test.describe('affine workspace', () => {
test('should login with user A', async ({ page }) => {
await openHomePage(page);
2023-03-28 08:25:16 +03:00
await waitMarkdownImported(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);
2023-03-28 08:25:16 +03:00
await waitMarkdownImported(page);
const [a] = await createFakeUser();
await loginUser(page, a);
2023-03-21 06:26:05 +03:00
const name = `test-${Date.now()}`;
await createWorkspace({ name }, page);
await page.waitForTimeout(50);
await clickSideBarSettingButton(page);
await page.waitForTimeout(50);
await clickCollaborationPanel(page);
await page.getByTestId('local-workspace-enable-cloud-button').click();
await page.getByTestId('confirm-enable-cloud-button').click();
await page.waitForSelector("[data-testid='member-length']", {
timeout: 20000,
});
await clickSideBarAllPageButton(page);
await clickNewPageButton(page);
await page.locator('[data-block-is-title="true"]').type('Hello, world!', {
delay: 50,
});
await assertCurrentWorkspaceFlavour('affine', page);
2023-04-07 00:14:23 +03:00
await openWorkspaceListModal(page);
await page.getByTestId('workspace-list-modal-sign-out').click();
await page.waitForTimeout(1000);
await assertCurrentWorkspaceFlavour('local', page);
});
});