refactor(core): onboarding using new transformer api (#5412)
Use new `transformer` to import onboarding json templates. The json files are generated via this gist https://gist.github.com/pengx17/ef92c305ac23123803a1a6a20e31f822 Not using the all-in-one `ZipTransformer` to import onboarding via a zip file. 1. The main concerns is that we still need to serve the blob resources via CDN to reduce user's blob usage. Otherwise the user will get the onboarding images being uploaded to cloud server every time he creates a new workspace. In this PR we extracted parts of the code from `ZipTransformer` in blocksuite and mute some code for uploading blobs. 2. it maybe not necessary to use zip for loading snapshots. This PR is a short term solution. whether or not to tune the transformer api design may need further discussions. fix TOV-264
This commit is contained in:
@@ -13,21 +13,33 @@ import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
const removeOnboardingPages = async (page: Page) => {
|
||||
await page.getByTestId('all-pages').click();
|
||||
await page.getByTestId('page-list-header-selection-checkbox').click();
|
||||
// click again to select all
|
||||
await page.getByTestId('page-list-header-selection-checkbox').click();
|
||||
await page.getByTestId('page-list-toolbar-delete').click();
|
||||
// confirm delete
|
||||
await page.getByTestId('confirm-delete-page').click();
|
||||
};
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
});
|
||||
|
||||
const createAndPinCollection = async (
|
||||
page: Page,
|
||||
options?: {
|
||||
collectionName?: string;
|
||||
skipInitialPage?: boolean;
|
||||
}
|
||||
) => {
|
||||
if (!options?.skipInitialPage) {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
}
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('test page');
|
||||
|
||||
await page.getByTestId('all-pages').click();
|
||||
|
||||
const cell = page.getByTestId('page-list-item-title').getByText('test page');
|
||||
await expect(cell).toBeVisible();
|
||||
await page.getByTestId('create-first-filter').click({
|
||||
@@ -50,6 +62,7 @@ const createAndPinCollection = async (
|
||||
};
|
||||
|
||||
test('Show collections items in sidebar', async ({ page }) => {
|
||||
await removeOnboardingPages(page);
|
||||
await createAndPinCollection(page);
|
||||
const collections = page.getByTestId('collections');
|
||||
const items = collections.getByTestId('collection-item');
|
||||
@@ -73,9 +86,7 @@ test('Show collections items in sidebar', async ({ page }) => {
|
||||
await deleteCollection.click();
|
||||
await page.waitForTimeout(50);
|
||||
expect(await items.count()).toBe(0);
|
||||
await createAndPinCollection(page, {
|
||||
skipInitialPage: true,
|
||||
});
|
||||
await createAndPinCollection(page);
|
||||
expect(await items.count()).toBe(1);
|
||||
await clickSideBarAllPageButton(page);
|
||||
await createLocalWorkspace(
|
||||
@@ -91,6 +102,7 @@ test('Show collections items in sidebar', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('edit collection', async ({ page }) => {
|
||||
await removeOnboardingPages(page);
|
||||
await createAndPinCollection(page);
|
||||
const collections = page.getByTestId('collections');
|
||||
const items = collections.getByTestId('collection-item');
|
||||
@@ -107,6 +119,7 @@ test('edit collection', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('edit collection and change filter date', async ({ page }) => {
|
||||
await removeOnboardingPages(page);
|
||||
await createAndPinCollection(page);
|
||||
const collections = page.getByTestId('collections');
|
||||
const items = collections.getByTestId('collection-item');
|
||||
@@ -125,8 +138,6 @@ test('edit collection and change filter date', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('create temporary filter by click tag', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('test page');
|
||||
@@ -148,8 +159,7 @@ test('create temporary filter by click tag', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('add collection from sidebar', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await removeOnboardingPages(page);
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('test page');
|
||||
|
||||
Reference in New Issue
Block a user