feat: bump blocksuite (#5194)

Co-authored-by: AyushAgrawal-A2 <ayushagl06@gmail.com>
This commit is contained in:
Yifeng Wang
2023-12-06 18:15:03 +08:00
committed by GitHub
parent 2dcb5a3030
commit 6cbf5b2a92
37 changed files with 292 additions and 430 deletions

View File

@@ -6,7 +6,6 @@ import {
enableCloudWorkspaceFromShareButton,
loginUser,
} from '@affine-test/kit/utils/cloud';
import { dropFile } from '@affine-test/kit/utils/drop-file';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import {
clickNewPageButton,
@@ -17,6 +16,7 @@ import { clickUserInfoCard } from '@affine-test/kit/utils/setting';
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
import { resolve } from 'path';
let user: {
id: string;
@@ -226,12 +226,45 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
await clickNewPageButton(page);
await waitForEditorLoad(page);
// drop an svg file
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<rect x="0" y="0" width="200" height="200" fill="red" />
</svg>`;
// upload local svg
await dropFile(page, 'affine-paragraph', svg, 'test.svg', 'image/svg+xml');
const slashMenu = page.locator(`.slash-menu`);
const image = page.locator('affine-image');
page.evaluate(async () => {
window.showOpenFilePicker = undefined;
});
const title = getBlockSuiteEditorTitle(page);
await title.pressSequentially('TEST TITLE', {
delay: 50,
});
await page.keyboard.press('Enter', { delay: 50 });
await page.waitForTimeout(100);
await page.keyboard.type('/', { delay: 50 });
await expect(slashMenu).toBeVisible();
await page.keyboard.type('image', { delay: 100 });
await expect(slashMenu).toBeVisible();
await page.keyboard.press('Enter', { delay: 50 });
await page.setInputFiles(
"input[type='file']",
resolve(__dirname, 'logo.svg')
);
await expect(image).toBeVisible();
// the user should see the svg
// get the image src under "affine-image img"
const src1 = await page.locator('affine-image img').getAttribute('src');
expect(src1).not.toBeNull();
// fetch the actual src1 resource in the browser
const svg1 = await page.evaluate(
src =>
fetch(src!)
.then(res => res.blob())
.then(blob => blob.text()),
src1
);
{
const context = await browser.newContext();
@@ -239,20 +272,20 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
await loginUser(page2, user.email);
await page2.goto(page.url());
// the user should see the svg
// second user should see the svg
// get the image src under "affine-image img"
const src = await page2.locator('affine-image img').getAttribute('src');
const src2 = await page2.locator('affine-image img').getAttribute('src');
expect(src2).not.toBeNull();
expect(src).not.toBeNull();
// fetch the actual src2 resource in the browser
const svg2 = await page2.evaluate(
src =>
fetch(src!)
.then(res => res.blob())
.then(blob => blob.text()),
src2
);
// fetch the src resource in the browser
const svg2 = await page2.evaluate(src => {
return fetch(src!)
.then(res => res.blob())
.then(blob => blob.text());
}, src);
// turn the blob into string and check if it contains the svg
expect(svg2).toContain(svg);
expect(svg2).toEqual(svg1);
}
});

View File

@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><defs><style>.cls-1{fill:#000000;}</style></defs><g id="_20230202-pull_request"><path class="cls-1" d="m512,133.82L342.5,0,0,67.88v310.26l169.56,133.86,342.44-67.88V133.82Zm-203.39-84.81v89.67l51.84-10.27v-56.25l74.87,59.09-249.93,49.53-108.71-85.8,231.93-45.96ZM51.84,133.32l99.71,78.7v93.92l51.84-10.27v-76.15l256.78-50.89v210.06l-99.71-78.7v-93.92l-51.84,10.27v76.16l-256.78,50.89v-210.06Zm151.55,329.67v-89.67l-51.84,10.27v56.25l-74.87-59.09,249.93-49.53,108.71,85.8-231.93,45.96Z"/></g></svg>

After

Width:  |  Height:  |  Size: 608 B

View File

@@ -6,7 +6,7 @@ import type {
const config: PlaywrightTestConfig = {
testDir: './e2e',
fullyParallel: !process.env.CI,
timeout: process.env.CI ? 120_000 : 30_000,
timeout: 120_000,
use: {
baseURL: 'http://localhost:8081/',
browserName:

View File

@@ -9,10 +9,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@playwright/test": "^1.39.0",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",

View File

@@ -9,10 +9,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@playwright/test": "^1.39.0",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",

View File

@@ -9,10 +9,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@playwright/test": "^1.39.0",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",

View File

@@ -9,10 +9,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@playwright/test": "^1.39.0",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",

View File

@@ -1,10 +0,0 @@
import { test } from '@affine-test/kit/playwright';
import { checkBlockHub } from '@affine-test/kit/utils/editor';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
test('block-hub should work', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await checkBlockHub(page);
});

View File

@@ -2,7 +2,6 @@ import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
clickPageMoreActions,
getBlockSuiteEditorTitle,
getPageOperationButton,
waitForEditorLoad,
@@ -41,21 +40,3 @@ test('New a page , then delete it in all pages, finally find it in trash', async
expect(currentWorkspace.flavour).toContain('local');
});
test('New a page , then delete it in page, blockHub and option menu will not appear ', async ({
page,
}) => {
await openHomePage(page);
await waitForEditorLoad(page);
await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page);
await title.pressSequentially('test');
await clickPageMoreActions(page);
await page.getByTestId('editor-option-menu-delete').click();
await page.getByTestId('confirm-delete-page').click();
await expect(page.getByTestId('header-dropDownButton')).not.toBeVisible();
await expect(page.getByTestId('block-hub')).not.toBeVisible();
await page.getByTestId('page-restore-button').click();
await expect(page.getByTestId('header-dropDownButton')).toBeVisible();
await expect(page.getByTestId('block-hub')).toBeVisible();
});

View File

@@ -93,7 +93,7 @@ test('v3 to v4, surface migration', async ({ page }) => {
// check edgeless mode is correct
await clickEdgelessModeButton(page);
await expect(page.locator('edgeless-toolbar')).toBeVisible();
await expect(page.locator('.edgeless-toolbar-container')).toBeVisible();
await expect(page.locator('affine-edgeless-page')).toBeVisible();
});
@@ -123,6 +123,6 @@ test('v0 to v4, subdoc migration', async ({ page }) => {
// check edgeless mode is correct
await clickEdgelessModeButton(page);
await expect(page.locator('edgeless-toolbar')).toBeVisible();
await expect(page.locator('.edgeless-toolbar-container')).toBeVisible();
await expect(page.locator('affine-edgeless-page')).toBeVisible();
});

View File

@@ -7,10 +7,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@playwright/test": "^1.39.0"
},
"version": "0.10.3-canary.2"

View File

@@ -1,15 +1,4 @@
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
export async function checkBlockHub(page: Page) {
const box = await page.locator('affine-block-hub').boundingBox();
if (!box) throw new Error('block-hub not found');
await page.getByTestId('block-hub').click();
await page.waitForTimeout(500);
const box2 = await page.locator('affine-block-hub').boundingBox();
if (!box2) throw new Error('block-hub not found');
expect(box2.height).toBeGreaterThan(box.height);
}
export async function clickEdgelessModeButton(page: Page) {
await page.getByTestId('switch-edgeless-mode-button').click({

View File

@@ -31,14 +31,14 @@
"wait-on": "^7.2.0"
},
"devDependencies": {
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/block-std": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/blocks": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/global": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/icons": "2.1.36",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/virgo": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/lit": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/presets": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/store": "0.0.0-20231205045113-03964196-nightly",
"@blocksuite/virgo": "0.0.0-20231205045113-03964196-nightly",
"@dnd-kit/sortable": "^8.0.0",
"@tomfreudenberg/next-auth-mock": "^0.5.6",
"chromatic": "^9.1.0",
@@ -51,9 +51,9 @@
},
"peerDependencies": {
"@blocksuite/blocks": "*",
"@blocksuite/editor": "*",
"@blocksuite/global": "*",
"@blocksuite/icons": "2.1.34",
"@blocksuite/presets": "*",
"@blocksuite/store": "*"
},
"version": "0.10.3-canary.2"

View File

@@ -1,4 +1,3 @@
import { RootBlockHub } from '@affine/component/block-hub';
import { BlockSuiteEditor } from '@affine/component/block-suite-editor';
import { WorkspaceFlavour } from '@affine/env/workspace';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
@@ -44,21 +43,18 @@ fetch(new URL('@affine-test/fixtures/large-image.png', import.meta.url))
export const Default = () => {
return (
<>
<div
style={{
height: '100vh',
width: '100vw',
overflow: 'auto',
}}
>
<BlockSuiteEditor mode="page" page={page} />
{createPortal(
<ImagePreviewModal pageId={page.id} workspace={page.workspace} />,
document.body
)}
</div>
<RootBlockHub />
</>
<div
style={{
height: '100vh',
width: '100vw',
overflow: 'auto',
}}
>
<BlockSuiteEditor mode="page" page={page} />
{createPortal(
<ImagePreviewModal pageId={page.id} workspace={page.workspace} />,
document.body
)}
</div>
);
};