Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
146 lines
5.0 KiB
TypeScript
146 lines
5.0 KiB
TypeScript
import './utils/declare-test-window.js';
|
|
|
|
import {
|
|
enterPlaygroundRoom,
|
|
initEmptyCodeBlockState,
|
|
} from './utils/actions/index.js';
|
|
import { assertBlockChildrenIds, assertBlockFlavour } from './utils/asserts.js';
|
|
import { scoped, test } from './utils/playwright.js';
|
|
|
|
const bookMarkUrl = 'http://localhost';
|
|
const embedUrl = 'https://github.com/toeverything/blocksuite/pull/7217';
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.route(
|
|
'https://affine-worker.toeverything.workers.dev/api/worker/link-preview',
|
|
async route => {
|
|
await route.fulfill({
|
|
json: {},
|
|
});
|
|
}
|
|
);
|
|
});
|
|
|
|
test(
|
|
scoped`create a paragraph-block while clicking zero-width of code-block which is the last block of page`,
|
|
async ({ page }) => {
|
|
await enterPlaygroundRoom(page);
|
|
await initEmptyCodeBlockState(page);
|
|
const codeComponent = page.locator('affine-code');
|
|
const rect = await codeComponent.boundingBox();
|
|
if (!rect) {
|
|
throw new Error('code-block not found');
|
|
}
|
|
// click the zero width
|
|
await page.mouse.click(rect.x + 20, rect.y + rect.height + 8);
|
|
await assertBlockFlavour(page, '3', 'affine:paragraph');
|
|
}
|
|
);
|
|
|
|
test(
|
|
scoped`don't create a paragraph-block while clicking zero-width of code-block before a paragraph-block`,
|
|
async ({ page }) => {
|
|
await enterPlaygroundRoom(page);
|
|
await page.evaluate(() => {
|
|
const { doc } = window;
|
|
const rootId = doc.addBlock('affine:page', {
|
|
title: new window.$blocksuite.store.Text(),
|
|
});
|
|
const note = doc.addBlock('affine:note', {}, rootId);
|
|
doc.addBlock('affine:code', {}, note);
|
|
doc.addBlock('affine:paragraph', {}, note);
|
|
});
|
|
const codeComponent = page.locator('affine-code');
|
|
const codeComponentrect = await codeComponent.boundingBox();
|
|
if (!codeComponentrect) {
|
|
throw new Error('code-block not found');
|
|
}
|
|
await page.mouse.click(
|
|
codeComponentrect.x + 20,
|
|
codeComponentrect.y + codeComponentrect.height + 8
|
|
);
|
|
await assertBlockChildrenIds(page, '1', ['2', '3']);
|
|
}
|
|
);
|
|
|
|
test(
|
|
scoped`create a paragraph-block while clicking between two non-paragraph-block`,
|
|
async ({ page }) => {
|
|
await enterPlaygroundRoom(page);
|
|
await page.evaluate(
|
|
async ({ bookMarkUrl, embedUrl }) => {
|
|
const { doc } = window;
|
|
const rootId = doc.addBlock('affine:page', {
|
|
title: new window.$blocksuite.store.Text(),
|
|
});
|
|
const note = doc.addBlock('affine:note', {}, rootId);
|
|
doc.addBlock('affine:code', {}, note);
|
|
doc.addBlock('affine:divider', {}, note);
|
|
doc.addBlock('affine:bookmark', { url: bookMarkUrl }, note);
|
|
await new Promise(res => setTimeout(res, 200));
|
|
const pageRoot = document.querySelector('affine-page-root');
|
|
if (!pageRoot) throw new Error('Cannot find doc page');
|
|
const imageBlob = await fetch(
|
|
`${location.origin}/test-card-1.png`
|
|
).then(response => response.blob());
|
|
const storage = doc.blobSync;
|
|
const sourceId = await storage.set(imageBlob);
|
|
doc.addBlock('affine:image', { sourceId }, note);
|
|
doc.addBlock('affine:embed-github', { url: embedUrl }, note);
|
|
},
|
|
{ bookMarkUrl, embedUrl }
|
|
);
|
|
const codeComponent = page.locator('affine-code');
|
|
const codeComponentrect = await codeComponent.boundingBox();
|
|
if (!codeComponentrect) {
|
|
throw new Error('code-block not found');
|
|
}
|
|
await page.mouse.click(
|
|
codeComponentrect.x + 20,
|
|
codeComponentrect.y + codeComponentrect.height + 8
|
|
);
|
|
await assertBlockFlavour(page, '7', 'affine:paragraph');
|
|
|
|
const dividerComponent = page.locator('affine-divider');
|
|
const dividerComponentRect = await dividerComponent.boundingBox();
|
|
if (!dividerComponentRect) {
|
|
throw new Error('divider-block not found');
|
|
}
|
|
await page.mouse.click(
|
|
dividerComponentRect.x + 20,
|
|
dividerComponentRect.y + dividerComponentRect.height + 8
|
|
);
|
|
await assertBlockFlavour(page, '8', 'affine:paragraph');
|
|
|
|
const bookmarkComponent = page.locator('affine-bookmark');
|
|
const bookmarkComponentRect = await bookmarkComponent.boundingBox();
|
|
if (!bookmarkComponentRect) {
|
|
throw new Error('bookmark-block not found');
|
|
}
|
|
await page.mouse.click(
|
|
bookmarkComponentRect.x + 20,
|
|
bookmarkComponentRect.y + bookmarkComponentRect.height + 8
|
|
);
|
|
await assertBlockFlavour(page, '9', 'affine:paragraph');
|
|
|
|
await page.evaluate(() => {
|
|
const viewport = document.querySelector('.affine-page-viewport');
|
|
if (!viewport) {
|
|
throw new Error();
|
|
}
|
|
viewport.scrollTo(0, 600);
|
|
});
|
|
|
|
const imageComponent = page.locator('affine-image');
|
|
const imageComponentRect = await imageComponent.boundingBox();
|
|
if (!imageComponentRect) {
|
|
throw new Error('image-block not found');
|
|
}
|
|
await page.mouse.click(
|
|
imageComponentRect.x + 20,
|
|
imageComponentRect.y + imageComponentRect.height + 8
|
|
);
|
|
await assertBlockFlavour(page, '10', 'affine:paragraph');
|
|
}
|
|
);
|