test: coverage on enable public workspace (#1733)

This commit is contained in:
Himself65 2023-03-28 20:57:50 -05:00 committed by GitHub
parent f18127dfd6
commit 62955e7de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 8 deletions

View File

@ -38,6 +38,7 @@ export const EnableAffineCloudModal: React.FC<EnableAffineCloudModalProps> = ({
{/* <StyleTips>{t('Retain cached cloud data')}</StyleTips> */}
<div>
<StyleButton
data-testid="confirm-enable-affine-cloud-button"
shape="round"
type="primary"
onClick={() => {

View File

@ -58,7 +58,12 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({
<Content weight="500">{t('Share with link')}</Content>
</Wrapper>
<FlexWrapper>
<Input width={582} value={shareUrl} disabled={true}></Input>
<Input
data-testid="share-url"
width={582}
value={shareUrl}
disabled={true}
></Input>
<Button
onClick={copyUrl}
type="light"
@ -86,6 +91,7 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({
<>
<Wrapper marginBottom="42px">{t('Publishing Description')}</Wrapper>
<Button
data-testid="publish-to-web-button"
onClick={() => {
publishWorkspace(true);
}}
@ -118,6 +124,7 @@ const PublishPanelLocal: React.FC<PublishPanelLocalProps> = ({
{t('Publishing')}
</Box>
<Button
data-testid="publish-enable-affine-cloud-button"
type="light"
shape="circle"
onClick={() => {

View File

@ -3,3 +3,7 @@ import type { Page } from '@playwright/test';
export async function clickCollaborationPanel(page: Page) {
await page.click('[data-tab-key="collaboration"]');
}
export async function clickPublishPanel(page: Page) {
await page.click('[data-tab-key="publish"]');
}

View File

@ -0,0 +1,36 @@
import { expect } from '@playwright/test';
import { waitMarkdownImported } from '../../libs/page-logic';
import { test } from '../../libs/playwright';
import { clickPublishPanel } from '../../libs/setting';
import { clickSideBarSettingButton } from '../../libs/sidebar';
import { createFakeUser, loginUser, openHomePage } from '../../libs/utils';
import { createWorkspace } from '../../libs/workspace';
test.describe('affine public workspace', () => {
test('enable public workspace', async ({ page }) => {
await openHomePage(page);
await waitMarkdownImported(page);
const [a] = await createFakeUser();
await loginUser(page, a);
const name = `test-${Date.now()}`;
await createWorkspace({ name }, page);
await page.waitForTimeout(50);
await clickSideBarSettingButton(page);
await page.waitForTimeout(50);
await clickPublishPanel(page);
await page.getByTestId('publish-enable-affine-cloud-button').click();
await page.getByTestId('confirm-enable-affine-cloud-button').click();
await page.getByTestId('publish-to-web-button').waitFor({
timeout: 10000,
});
await page.getByTestId('publish-to-web-button').click();
await page.getByTestId('share-url').waitFor({
timeout: 10000,
});
const url = await page.getByTestId('share-url').inputValue();
expect(url.startsWith('http://localhost:8080/public-workspace/')).toBe(
true
);
});
});

View File

@ -1,22 +1,22 @@
import { expect } from '@playwright/test';
import { waitMarkdownImported } from '../libs/page-logic';
import { waitMarkdownImported } from '../../libs/page-logic';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userA = require('../fixtures/userA.json');
import { test } from '../libs/playwright';
import { clickCollaborationPanel } from '../libs/setting';
const userA = require('../../fixtures/userA.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';
} from '../../libs/sidebar';
import { createFakeUser, loginUser, openHomePage } from '../../libs/utils';
import {
assertCurrentWorkspaceFlavour,
createWorkspace,
} from '../libs/workspace';
} from '../../libs/workspace';
test.describe('affine workspace', () => {
test('should login with user A', async ({ page }) => {