From 3d6d8694ba2493a91042d703f369fe903232389f Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Thu, 9 Feb 2023 16:28:01 +0800 Subject: [PATCH] feat: add create workspace test (#914) --- packages/app/src/components/page-list/index.tsx | 1 + .../app/src/components/workspace-modal/index.tsx | 1 + .../workspace-setting/general/General.tsx | 2 +- .../src/components/workspace-slider-bar/index.tsx | 3 ++- tests/local-first-workspace-list.spec.ts | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/page-list/index.tsx b/packages/app/src/components/page-list/index.tsx index 7cbcf80c96..8386f902cc 100644 --- a/packages/app/src/components/page-list/index.tsx +++ b/packages/app/src/components/page-list/index.tsx @@ -106,6 +106,7 @@ export const PageList = ({ {pageList.map((pageMeta, index) => { return ( { if (isPublic) { diff --git a/packages/app/src/components/workspace-modal/index.tsx b/packages/app/src/components/workspace-modal/index.tsx index 2c67459ede..8c3850e396 100644 --- a/packages/app/src/components/workspace-modal/index.tsx +++ b/packages/app/src/components/workspace-modal/index.tsx @@ -71,6 +71,7 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => { { onClose(); }} diff --git a/packages/app/src/components/workspace-setting/general/General.tsx b/packages/app/src/components/workspace-setting/general/General.tsx index dbfdce1fff..2c33eb3bf2 100644 --- a/packages/app/src/components/workspace-setting/general/General.tsx +++ b/packages/app/src/components/workspace-setting/general/General.tsx @@ -18,7 +18,7 @@ import { Upload } from '@/components/file-upload'; export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const [showDelete, setShowDelete] = useState(false); const [showLeave, setShowLeave] = useState(false); - const [workspaceName, setWorkspaceName] = useState(workspace.name); + const [workspaceName, setWorkspaceName] = useState(workspace?.name); const { currentWorkspace, isOwner } = useAppState(); const { updateWorkspace } = useWorkspaceHelper(); const { t } = useTranslation(); diff --git a/packages/app/src/components/workspace-slider-bar/index.tsx b/packages/app/src/components/workspace-slider-bar/index.tsx index 556f560a2b..5c98f28ff3 100644 --- a/packages/app/src/components/workspace-slider-bar/index.tsx +++ b/packages/app/src/components/workspace-slider-bar/index.tsx @@ -125,7 +125,8 @@ export const WorkSpaceSliderBar = () => { - {t('All pages')} + + {t('All pages')} diff --git a/tests/local-first-workspace-list.spec.ts b/tests/local-first-workspace-list.spec.ts index ddee0e36c5..0f71989c16 100644 --- a/tests/local-first-workspace-list.spec.ts +++ b/tests/local-first-workspace-list.spec.ts @@ -27,6 +27,21 @@ test.describe('Local first workspace list', () => { //check workspace list length const workspaceCards = await page.$$('data-testid=workspace-card'); expect(workspaceCards.length).toBe(2); + + //check page list length + const closeWorkspaceModal = page.getByTestId('close-workspace-modal'); + await closeWorkspaceModal.click(); + const allPageButton = page.getByTestId('all-pages'); + await allPageButton.click(); + await page.waitForTimeout(1000); + const pageList = page.locator('[data-testid=page-list-item]'); + const result = await pageList.count(); + expect(result).toBe(1); + await page.reload(); + await page.waitForTimeout(1000); + const pageList1 = page.locator('[data-testid=page-list-item]'); + const result1 = await pageList1.count(); + expect(result1).toBe(1); }); test('create multi workspace in the workspace list', async ({ page }) => {