mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-24 04:27:27 +08:00
test: add workspace ref in e2e (#3217)
This commit is contained in:
@@ -26,10 +26,6 @@ export const test = base.extend<{
|
|||||||
appData: string;
|
appData: string;
|
||||||
sessionData: string;
|
sessionData: string;
|
||||||
};
|
};
|
||||||
workspace: {
|
|
||||||
// get current workspace
|
|
||||||
current: () => Promise<any>; // todo: type
|
|
||||||
};
|
|
||||||
router: {
|
router: {
|
||||||
goto: (path: RoutePath) => Promise<void>;
|
goto: (path: RoutePath) => Promise<void>;
|
||||||
};
|
};
|
||||||
@@ -121,14 +117,4 @@ export const test = base.extend<{
|
|||||||
});
|
});
|
||||||
await use(appInfo);
|
await use(appInfo);
|
||||||
},
|
},
|
||||||
workspace: async ({ page }, use) => {
|
|
||||||
await use({
|
|
||||||
current: async () => {
|
|
||||||
return await page.evaluate(async () => {
|
|
||||||
// @ts-expect-error
|
|
||||||
return globalThis.currentWorkspace;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { test } from '@affine-test/kit/playwright';
|
|
||||||
import { expect } from '@playwright/test';
|
|
||||||
|
|
||||||
test('the link has expired', async ({ page }) => {
|
|
||||||
await page.goto('http://localhost:8080//invite/abc');
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
expect(page.getByText('The link has expired')).not.toBeUndefined();
|
|
||||||
});
|
|
||||||
@@ -3,10 +3,12 @@ import { resolve } from 'node:path';
|
|||||||
import { rootDir, test } from '@affine-test/kit/playwright';
|
import { rootDir, test } from '@affine-test/kit/playwright';
|
||||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||||
import { newPage, waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
import { newPage, waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('should create a page with a local first avatar', async ({ page }) => {
|
test('should create a page with a local first avatar', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -35,5 +37,7 @@ test('should create a page with a local first avatar', async ({ page }) => {
|
|||||||
.getAttribute('src');
|
.getAttribute('src');
|
||||||
// out user uploaded avatar
|
// out user uploaded avatar
|
||||||
expect(blobUrl).toContain('blob:');
|
expect(blobUrl).toContain('blob:');
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ test('edit collection', async ({ page }) => {
|
|||||||
await page.waitForTimeout(100);
|
await page.waitForTimeout(100);
|
||||||
expect(await first.textContent()).toBe('123');
|
expect(await first.textContent()).toBe('123');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('edit collection and change filter date', async ({ page }) => {
|
test('edit collection and change filter date', async ({ page }) => {
|
||||||
await createAndPinCollection(page);
|
await createAndPinCollection(page);
|
||||||
const collections = page.getByTestId('collections');
|
const collections = page.getByTestId('collections');
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('New a page , then delete it in all pages, permanently delete it', async ({
|
test('New a page , then delete it in all pages, permanently delete it', async ({
|
||||||
page,
|
page,
|
||||||
|
workspace,
|
||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
@@ -50,5 +50,7 @@ test('New a page , then delete it in all pages, permanently delete it', async ({
|
|||||||
'Tips: Click Add to Favorites/Trash and the page will appear here.'
|
'Tips: Click Add to Favorites/Trash and the page will appear here.'
|
||||||
)
|
)
|
||||||
).not.toBeUndefined();
|
).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
|||||||
import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting';
|
import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting';
|
||||||
import { openSettingModal } from '@affine-test/kit/utils/setting';
|
import { openSettingModal } from '@affine-test/kit/utils/setting';
|
||||||
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
|
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('Create new workspace, then delete it', async ({ page }) => {
|
test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await clickSideBarCurrentWorkspaceBanner(page);
|
await clickSideBarCurrentWorkspaceBanner(page);
|
||||||
@@ -43,7 +42,9 @@ test('Create new workspace, then delete it', async ({ page }) => {
|
|||||||
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
||||||
'Demo Workspace'
|
'Demo Workspace'
|
||||||
);
|
);
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete last workspace', async ({ page }) => {
|
test('Delete last workspace', async ({ page }) => {
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test.skip('New a page ,then open it and export html', async ({ page }) => {
|
test.skip('New a page ,then open it and export html', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -37,9 +39,15 @@ test.skip('New a page ,then open it and export html', async ({ page }) => {
|
|||||||
expect(download.suggestedFilename()).toBe(
|
expect(download.suggestedFilename()).toBe(
|
||||||
'this is a new page to export html content.html'
|
'this is a new page to export html content.html'
|
||||||
);
|
);
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('New a page ,then open it and export markdown', async ({ page }) => {
|
test.skip('New a page ,then open it and export markdown', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
await getBlockSuiteEditorTitle(page).click();
|
await getBlockSuiteEditorTitle(page).click();
|
||||||
await page
|
await page
|
||||||
@@ -64,5 +72,7 @@ test.skip('New a page ,then open it and export markdown', async ({ page }) => {
|
|||||||
expect(download.suggestedFilename()).toBe(
|
expect(download.suggestedFilename()).toBe(
|
||||||
'this is a new page to export markdown content.md'
|
'this is a new page to export markdown content.md'
|
||||||
);
|
);
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ import {
|
|||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { waitForLogMessage } from '@affine-test/kit/utils/utils';
|
import { waitForLogMessage } from '@affine-test/kit/utils/utils';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('New a page and open it ,then favorite it', async ({ page }) => {
|
test('New a page and open it ,then favorite it', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -26,7 +28,9 @@ test('New a page and open it ,then favorite it', async ({ page }) => {
|
|||||||
await clickPageMoreActions(page);
|
await clickPageMoreActions(page);
|
||||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||||
await favoriteBtn.click();
|
await favoriteBtn.click();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Export to html, markdown and png', async ({ page }) => {
|
test('Export to html, markdown and png', async ({ page }) => {
|
||||||
@@ -74,7 +78,7 @@ test.skip('Export to pdf', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Cancel favorite', async ({ page }) => {
|
test('Cancel favorite', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -115,5 +119,7 @@ test('Cancel favorite', async ({ page }) => {
|
|||||||
'Tips: Click Add to Favorites/Trash and the page will appear here.'
|
'Tips: Click Add to Favorites/Trash and the page will appear here.'
|
||||||
)
|
)
|
||||||
).not.toBeUndefined();
|
).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('Show favorite items in sidebar', async ({ page }) => {
|
test('Show favorite items in sidebar', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -32,9 +32,12 @@ test('Show favorite items in sidebar', async ({ page }) => {
|
|||||||
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
||||||
'this is a new page to favorite'
|
'this is a new page to favorite'
|
||||||
);
|
);
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Show favorite reference in sidebar', async ({ page }) => {
|
test('Show favorite reference in sidebar', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -69,10 +72,14 @@ test('Show favorite reference in sidebar', async ({ page }) => {
|
|||||||
await expect(
|
await expect(
|
||||||
page.locator('[data-type="favorite-list-item"] >> text=Another page')
|
page.locator('[data-type="favorite-list-item"] >> text=Another page')
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Deleted page's reference will not be shown in sidebar", async ({
|
test("Deleted page's reference will not be shown in sidebar", async ({
|
||||||
page,
|
page,
|
||||||
|
workspace,
|
||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
@@ -116,4 +123,7 @@ test("Deleted page's reference will not be shown in sidebar", async ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
await expect(collapseButton).not.toBeVisible();
|
await expect(collapseButton).not.toBeVisible();
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,20 +5,24 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('click btn new page', async ({ page }) => {
|
test('click btn new page', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
const originPageId = page.url().split('/').reverse()[0];
|
const originPageId = page.url().split('/').reverse()[0];
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
const newPageId = page.url().split('/').reverse()[0];
|
const newPageId = page.url().split('/').reverse()[0];
|
||||||
expect(newPageId).not.toBe(originPageId);
|
expect(newPageId).not.toBe(originPageId);
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('click btn bew page and find it in all pages', async ({ page }) => {
|
test('click btn bew page and find it in all pages', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -27,5 +31,7 @@ test('click btn bew page and find it in all pages', async ({ page }) => {
|
|||||||
await page.getByTestId('all-pages').click();
|
await page.getByTestId('all-pages').click();
|
||||||
const cell = page.getByRole('cell', { name: 'this is a new page' });
|
const cell = page.getByRole('cell', { name: 'this is a new page' });
|
||||||
expect(cell).not.toBeUndefined();
|
expect(cell).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('click btn bew page and open in tab', async ({ page }) => {
|
test('click btn bew page and open in tab', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -30,5 +29,7 @@ test('click btn bew page and open in tab', async ({ page }) => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
expect(newTabPage.url()).toBe(newPageUrl);
|
expect(newTabPage.url()).toBe(newPageUrl);
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('New a page , then delete it in all pages, restore it', async ({
|
test('New a page , then delete it in all pages, restore it', async ({
|
||||||
page,
|
page,
|
||||||
|
workspace,
|
||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
@@ -52,5 +52,7 @@ test('New a page , then delete it in all pages, restore it', async ({
|
|||||||
name: 'this is a new page to restore',
|
name: 'this is a new page to restore',
|
||||||
});
|
});
|
||||||
expect(restoreCell).not.toBeUndefined();
|
expect(restoreCell).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('New a page ,then open it and show delete modal', async ({ page }) => {
|
test('New a page ,then open it and show delete modal', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await newPage(page);
|
await newPage(page);
|
||||||
@@ -27,11 +29,14 @@ test('New a page ,then open it and show delete modal', async ({ page }) => {
|
|||||||
await deleteBtn.click();
|
await deleteBtn.click();
|
||||||
const confirmTip = page.getByText('Delete page?');
|
const confirmTip = page.getByText('Delete page?');
|
||||||
expect(confirmTip).not.toBeUndefined();
|
expect(confirmTip).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('New a page ,then go to all pages and show delete modal', async ({
|
test('New a page ,then go to all pages and show delete modal', async ({
|
||||||
page,
|
page,
|
||||||
|
workspace,
|
||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
@@ -54,5 +59,7 @@ test('New a page ,then go to all pages and show delete modal', async ({
|
|||||||
await deleteBtn.click();
|
await deleteBtn.click();
|
||||||
const confirmTip = page.getByText('Delete page?');
|
const confirmTip = page.getByText('Delete page?');
|
||||||
expect(confirmTip).not.toBeUndefined();
|
expect(confirmTip).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
newPage,
|
newPage,
|
||||||
waitEditorLoad,
|
waitEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('New a page , then delete it in all pages, finally find it in trash', async ({
|
test('New a page , then delete it in all pages, finally find it in trash', async ({
|
||||||
page,
|
page,
|
||||||
|
workspace,
|
||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
@@ -39,5 +39,7 @@ test('New a page , then delete it in all pages, finally find it in trash', async
|
|||||||
expect(
|
expect(
|
||||||
page.getByRole('cell', { name: 'this is a new page to delete' })
|
page.getByRole('cell', { name: 'this is a new page to delete' })
|
||||||
).not.toBeUndefined();
|
).not.toBeUndefined();
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import {
|
|||||||
} from '@affine-test/kit/utils/workspace';
|
} from '@affine-test/kit/utils/workspace';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('just one item in the workspace list at first', async ({ page }) => {
|
test('just one item in the workspace list at first', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
const workspaceName = page.getByTestId('workspace-name');
|
const workspaceName = page.getByTestId('workspace-name');
|
||||||
@@ -19,9 +22,15 @@ test('just one item in the workspace list at first', async ({ page }) => {
|
|||||||
.filter({ hasText: 'AFFiNE TestLocal WorkspaceAvailable Offline' })
|
.filter({ hasText: 'AFFiNE TestLocal WorkspaceAvailable Offline' })
|
||||||
.nth(3)
|
.nth(3)
|
||||||
).not.toBeNull();
|
).not.toBeNull();
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create one workspace in the workspace list', async ({ page }) => {
|
test('create one workspace in the workspace list', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
const newWorkspaceNameStr = 'New Workspace';
|
const newWorkspaceNameStr = 'New Workspace';
|
||||||
@@ -48,9 +57,15 @@ test('create one workspace in the workspace list', async ({ page }) => {
|
|||||||
const pageList1 = page.locator('[data-testid=page-list-item]');
|
const pageList1 = page.locator('[data-testid=page-list-item]');
|
||||||
const result1 = await pageList1.count();
|
const result1 = await pageList1.count();
|
||||||
expect(result1).toBe(0);
|
expect(result1).toBe(0);
|
||||||
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create multi workspace in the workspace list', async ({ page }) => {
|
test('create multi workspace in the workspace list', async ({
|
||||||
|
page,
|
||||||
|
workspace,
|
||||||
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
await createWorkspace({ name: 'New Workspace 2' }, page);
|
await createWorkspace({ name: 'New Workspace 2' }, page);
|
||||||
@@ -71,8 +86,9 @@ test('create multi workspace in the workspace list', async ({ page }) => {
|
|||||||
await page.getByTestId('draggable-item').nth(1).click();
|
await page.getByTestId('draggable-item').nth(1).click();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
// @ts-expect-error
|
const currentWorkspace = await workspace.current();
|
||||||
const currentId: string = await page.evaluate(() => currentWorkspace.id);
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
|
|
||||||
await openWorkspaceListModal(page);
|
await openWorkspaceListModal(page);
|
||||||
const sourceElement = page.getByTestId('draggable-item').nth(2);
|
const sourceElement = page.getByTestId('draggable-item').nth(2);
|
||||||
@@ -122,7 +138,7 @@ test('create multi workspace in the workspace list', async ({ page }) => {
|
|||||||
await page.getByTestId('draggable-item').nth(2).click();
|
await page.getByTestId('draggable-item').nth(2).click();
|
||||||
await workspaceChangePromise;
|
await workspaceChangePromise;
|
||||||
|
|
||||||
// @ts-expect-error
|
const nextWorkspace = await workspace.current();
|
||||||
const nextId: string = await page.evaluate(() => currentWorkspace.id);
|
|
||||||
expect(currentId).toBe(nextId);
|
expect(currentWorkspace.id).toBe(nextWorkspace.id);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
import { test } from '@affine-test/kit/playwright';
|
import { test } from '@affine-test/kit/playwright';
|
||||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||||
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
||||||
import { assertCurrentWorkspaceFlavour } from '@affine-test/kit/utils/workspace';
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('preset workspace name', async ({ page }) => {
|
test('preset workspace name', async ({ page, workspace }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
const workspaceName = page.getByTestId('workspace-name');
|
const workspaceName = page.getByTestId('workspace-name');
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
expect(await workspaceName.textContent()).toBe('Demo Workspace');
|
expect(await workspaceName.textContent()).toBe('Demo Workspace');
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('default workspace avatar', async ({ page }) => {
|
test('Open language switch menu', async ({ page, workspace }) => {
|
||||||
// const workspaceAvatar = page.getByTestId('workspace-avatar');
|
|
||||||
// expect(
|
|
||||||
// await workspaceAvatar.locator('img').getAttribute('src')
|
|
||||||
// ).not.toBeNull();
|
|
||||||
// });
|
|
||||||
test('Open language switch menu', async ({ page }) => {
|
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitEditorLoad(page);
|
await waitEditorLoad(page);
|
||||||
const editorOptionMenuButton = page.getByTestId('editor-option-menu');
|
const editorOptionMenuButton = page.getByTestId('editor-option-menu');
|
||||||
@@ -29,5 +24,7 @@ test('Open language switch menu', async ({ page }) => {
|
|||||||
await expect(languageMenuButton).toBeVisible();
|
await expect(languageMenuButton).toBeVisible();
|
||||||
const actual = await languageMenuButton.innerText();
|
const actual = await languageMenuButton.innerText();
|
||||||
expect(actual).toEqual('English');
|
expect(actual).toEqual('English');
|
||||||
await assertCurrentWorkspaceFlavour('local', page);
|
const currentWorkspace = await workspace.current();
|
||||||
|
|
||||||
|
expect(currentWorkspace.flavour).toContain('local');
|
||||||
});
|
});
|
||||||
|
|||||||
+21
-1
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|||||||
import path, { resolve } from 'node:path';
|
import path, { resolve } from 'node:path';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
|
|
||||||
|
import type { Workspace } from '@blocksuite/store';
|
||||||
import { test as baseTest } from '@playwright/test';
|
import { test as baseTest } from '@playwright/test';
|
||||||
|
|
||||||
export const rootDir = resolve(__dirname, '..', '..');
|
export const rootDir = resolve(__dirname, '..', '..');
|
||||||
@@ -26,7 +27,26 @@ function generateUUID() {
|
|||||||
|
|
||||||
export const enableCoverage = !!process.env.CI || !!process.env.COVERAGE;
|
export const enableCoverage = !!process.env.CI || !!process.env.COVERAGE;
|
||||||
|
|
||||||
export const test = baseTest.extend({
|
type CurrentWorkspace = {
|
||||||
|
id: string;
|
||||||
|
flavour: string;
|
||||||
|
blockSuiteWorkspace: Workspace;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const test = baseTest.extend<{
|
||||||
|
workspace: {
|
||||||
|
current: () => Promise<CurrentWorkspace>;
|
||||||
|
};
|
||||||
|
}>({
|
||||||
|
workspace: async ({ page }, use) => {
|
||||||
|
await use({
|
||||||
|
current: async () => {
|
||||||
|
return await page.evaluate(async () => {
|
||||||
|
return (globalThis as any).currentWorkspace;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
context: async ({ context }, use) => {
|
context: async ({ context }, use) => {
|
||||||
if (enableCoverage) {
|
if (enableCoverage) {
|
||||||
await context.addInitScript(() =>
|
await context.addInitScript(() =>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
import { expect } from '@playwright/test';
|
|
||||||
|
|
||||||
import { clickCollaborationPanel } from './setting';
|
|
||||||
import { clickSideBarSettingButton } from './sidebar';
|
|
||||||
|
|
||||||
interface CreateWorkspaceParams {
|
interface CreateWorkspaceParams {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -29,23 +25,3 @@ export async function createWorkspace(
|
|||||||
// click create button
|
// click create button
|
||||||
return page.getByRole('button', { name: 'Create' }).click();
|
return page.getByRole('button', { name: 'Create' }).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function assertCurrentWorkspaceFlavour(
|
|
||||||
flavour: 'affine' | 'local',
|
|
||||||
page: Page
|
|
||||||
) {
|
|
||||||
// @ts-expect-error
|
|
||||||
const actual = await page.evaluate(() => globalThis.currentWorkspace.flavour);
|
|
||||||
expect(actual).toBe(flavour);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function enableAffineCloudWorkspace(page: Page) {
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user