Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

test: coverage on enable public workspace (#1733)

Himself6562955e7de458
diff --git a/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx b/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx
index e85e1a80a4..d82cf55b27 100644
--- a/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx
+++ b/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx
@@ -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={() => {
diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx
index 62fdaf4c11..3fc42eff50 100644
--- a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx
+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx
@@ -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={() => {
diff --git a/tests/libs/setting.ts b/tests/libs/setting.ts
index 61a24f7720..267f3e2cb4 100644
--- a/tests/libs/setting.ts
+++ b/tests/libs/setting.ts
@@ -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"]');
+}
diff --git a/tests/parallels/affine/affine-public-workspace.spec.ts b/tests/parallels/affine/affine-public-workspace.spec.ts
new file mode 100644
index 0000000000..2cd6ecd61d
--- /dev/null
+++ b/tests/parallels/affine/affine-public-workspace.spec.ts
@@ -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
+ );
+ });
+});
diff --git a/tests/parallels/affine-workspace.spec.ts b/tests/parallels/affine/affine-workspace.spec.ts
similarity index 83%
rename from tests/parallels/affine-workspace.spec.ts
rename to tests/parallels/affine/affine-workspace.spec.ts
index 2a0c182fb2..aa51fb92ff 100644
--- a/tests/parallels/affine-workspace.spec.ts
+++ b/tests/parallels/affine/affine-workspace.spec.ts
@@ -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 }) => {