chore: prohibit unnecessary await (#4586)
This commit is contained in:
@@ -132,6 +132,7 @@ const config = {
|
|||||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
'@typescript-eslint/no-empty-function': 'off',
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
|
'@typescript-eslint/await-thenable': 'error',
|
||||||
'@typescript-eslint/no-unused-vars': [
|
'@typescript-eslint/no-unused-vars': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@@ -202,6 +203,7 @@ const config = {
|
|||||||
ignore: ['^\\[[a-zA-Z0-9-_]+\\]\\.tsx$'],
|
ignore: ['^\\[[a-zA-Z0-9-_]+\\]\\.tsx$'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'unicorn/no-unnecessary-await': 'error',
|
||||||
'sonarjs/no-all-duplicated-branches': 'error',
|
'sonarjs/no-all-duplicated-branches': 'error',
|
||||||
'sonarjs/no-element-overwrite': 'error',
|
'sonarjs/no-element-overwrite': 'error',
|
||||||
'sonarjs/no-empty-collection': 'error',
|
'sonarjs/no-empty-collection': 'error',
|
||||||
|
|||||||
@@ -358,9 +358,7 @@ function createSetupImpl(rootStore: ReturnType<typeof createStore>) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
navigator: {
|
navigator: globalThis.navigator,
|
||||||
userAgent: navigator.userAgent,
|
|
||||||
},
|
|
||||||
|
|
||||||
MouseEvent: globalThis.MouseEvent,
|
MouseEvent: globalThis.MouseEvent,
|
||||||
KeyboardEvent: globalThis.KeyboardEvent,
|
KeyboardEvent: globalThis.KeyboardEvent,
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ export interface PageDetailEditorProps {
|
|||||||
isPublic?: boolean;
|
isPublic?: boolean;
|
||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
pageId: string;
|
pageId: string;
|
||||||
onInit: (page: Page, editor: Readonly<EditorContainer>) => void;
|
onInit: (
|
||||||
|
page: Page,
|
||||||
|
editor: Readonly<EditorContainer>
|
||||||
|
) => Promise<void> | void;
|
||||||
onLoad?: OnLoadEditor;
|
onLoad?: OnLoadEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export function useAppHelper() {
|
|||||||
targetWorkspace
|
targetWorkspace
|
||||||
);
|
);
|
||||||
// delete workspace from jotai storage
|
// delete workspace from jotai storage
|
||||||
await set(workspaces => workspaces.filter(ws => ws.id !== workspaceId));
|
set(workspaces => workspaces.filter(ws => ws.id !== workspaceId));
|
||||||
},
|
},
|
||||||
[jotaiWorkspaces, set]
|
[jotaiWorkspaces, set]
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export const Component = (): ReactElement => {
|
|||||||
isPublic
|
isPublic
|
||||||
workspace={page.workspace}
|
workspace={page.workspace}
|
||||||
pageId={page.id}
|
pageId={page.id}
|
||||||
onInit={useCallback(() => noop, [])}
|
onInit={noop}
|
||||||
onLoad={useCallback(() => noop, [])}
|
onLoad={useCallback(() => noop, [])}
|
||||||
/>
|
/>
|
||||||
</MainContainer>
|
</MainContainer>
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ test.afterEach.always(async () => {
|
|||||||
|
|
||||||
test('should be able to increment counter', async t => {
|
test('should be able to increment counter', async t => {
|
||||||
metrics.socketIOEventCounter(1, { event: 'client-handshake' });
|
metrics.socketIOEventCounter(1, { event: 'client-handshake' });
|
||||||
const socketIOCounterMetric =
|
const socketIOCounterMetric = register.getSingleMetric('socket_io_counter');
|
||||||
await register.getSingleMetric('socket_io_counter');
|
|
||||||
t.truthy(socketIOCounterMetric);
|
t.truthy(socketIOCounterMetric);
|
||||||
|
|
||||||
t.truthy(
|
t.truthy(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function useBlockSuiteWorkspaceAvatarUrl(
|
|||||||
const { data: avatar, mutate } = useSWR(url, {
|
const { data: avatar, mutate } = useSWR(url, {
|
||||||
fetcher: async avatar => {
|
fetcher: async avatar => {
|
||||||
assertExists(blockSuiteWorkspace);
|
assertExists(blockSuiteWorkspace);
|
||||||
const blobs = await blockSuiteWorkspace.blobs;
|
const blobs = blockSuiteWorkspace.blobs;
|
||||||
const blob = await blobs.get(avatar);
|
const blob = await blobs.get(avatar);
|
||||||
if (blob) {
|
if (blob) {
|
||||||
return URL.createObjectURL(blob);
|
return URL.createObjectURL(blob);
|
||||||
@@ -31,7 +31,7 @@ export function useBlockSuiteWorkspaceAvatarUrl(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const blob = new Blob([file], { type: file.type });
|
const blob = new Blob([file], { type: file.type });
|
||||||
const blobs = await blockSuiteWorkspace.blobs;
|
const blobs = blockSuiteWorkspace.blobs;
|
||||||
const blobId = await blobs.set(blob);
|
const blobId = await blobs.set(blob);
|
||||||
blockSuiteWorkspace.meta.setAvatar(blobId);
|
blockSuiteWorkspace.meta.setAvatar(blobId);
|
||||||
await mutate(blobId);
|
await mutate(blobId);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { runCli } from '@magic-works/i18n-codegen';
|
import { runCli } from '@magic-works/i18n-codegen';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
await runCli(
|
runCli(
|
||||||
{
|
{
|
||||||
config: fileURLToPath(new URL('../../.i18n-codegen.json', import.meta.url)),
|
config: fileURLToPath(new URL('../../.i18n-codegen.json', import.meta.url)),
|
||||||
watch: false,
|
watch: false,
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ const ImagePreviewModalImpl = (
|
|||||||
if (typeof blockId === 'string') {
|
if (typeof blockId === 'string') {
|
||||||
const block = page.getBlockById(blockId) as ImageBlockModel;
|
const block = page.getBlockById(blockId) as ImageBlockModel;
|
||||||
assertExists(block);
|
assertExists(block);
|
||||||
const store = await block.page.blobs;
|
const store = block.page.blobs;
|
||||||
const url = store?.get(block.sourceId);
|
const url = store?.get(block.sourceId);
|
||||||
const img = await url;
|
const img = await url;
|
||||||
if (!img) {
|
if (!img) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { runCli } from '@magic-works/i18n-codegen';
|
|||||||
import { beforeAll } from 'vitest';
|
import { beforeAll } from 'vitest';
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await runCli(
|
runCli(
|
||||||
{
|
{
|
||||||
watch: false,
|
watch: false,
|
||||||
cwd: join(fileURLToPath(import.meta.url), '../../../.i18n-codegen.json'),
|
cwd: join(fileURLToPath(import.meta.url), '../../../.i18n-codegen.json'),
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ test('allow creation of filters by favorite', async ({ page }) => {
|
|||||||
.locator('[data-testid="filter-arg"]', { hasText: 'true' })
|
.locator('[data-testid="filter-arg"]', { hasText: 'true' })
|
||||||
.locator('div')
|
.locator('div')
|
||||||
.click();
|
.click();
|
||||||
await expect(
|
expect(await page.locator('[data-testid="filter-arg"]').textContent()).toBe(
|
||||||
await page.locator('[data-testid="filter-arg"]').textContent()
|
'false'
|
||||||
).toBe('false');
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('allow creation of filters by created time', async ({ page }) => {
|
test('allow creation of filters by created time', async ({ page }) => {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
const btn = await page.getByTestId('switch-edgeless-mode-button');
|
const btn = page.getByTestId('switch-edgeless-mode-button');
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
globalThis.__toastCount = 0;
|
globalThis.__toastCount = 0;
|
||||||
@@ -31,7 +31,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
|||||||
expect(count).toBe(1);
|
expect(count).toBe(1);
|
||||||
}
|
}
|
||||||
const edgeless = page.locator('affine-edgeless-page');
|
const edgeless = page.locator('affine-edgeless-page');
|
||||||
expect(await edgeless.isVisible()).toBe(true);
|
await expect(edgeless).toBeVisible();
|
||||||
|
|
||||||
const editorWrapperPadding = await page
|
const editorWrapperPadding = await page
|
||||||
.locator('.editor-wrapper.edgeless-mode')
|
.locator('.editor-wrapper.edgeless-mode')
|
||||||
@@ -60,15 +60,15 @@ test('Convert to edgeless by editor header items', async ({ page }) => {
|
|||||||
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
|
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
|
||||||
await menusEdgelessItem.click({ delay: 100 });
|
await menusEdgelessItem.click({ delay: 100 });
|
||||||
const edgeless = page.locator('affine-edgeless-page');
|
const edgeless = page.locator('affine-edgeless-page');
|
||||||
expect(await edgeless.isVisible()).toBe(true);
|
await expect(edgeless).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Able to insert the title of an untitled page', async ({ page }) => {
|
test('Able to insert the title of an untitled page', async ({ page }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
const titleBarTextContent = await page.getByTestId('title-edit-button');
|
const titleBarTextContent = page.getByTestId('title-edit-button');
|
||||||
await titleBarTextContent.dblclick({ delay: 100 });
|
await titleBarTextContent.dblclick({ delay: 100 });
|
||||||
const titleContent = await page.getByTestId('title-content');
|
const titleContent = page.getByTestId('title-content');
|
||||||
await titleContent.fill('test');
|
await titleContent.fill('test');
|
||||||
await titleContent.blur();
|
await titleContent.blur();
|
||||||
expect(await titleBarTextContent.textContent()).toBe('test');
|
expect(await titleBarTextContent.textContent()).toBe('test');
|
||||||
@@ -77,9 +77,9 @@ test('Able to insert the title of an untitled page', async ({ page }) => {
|
|||||||
test('Able to edit the title of an existing page', async ({ page }) => {
|
test('Able to edit the title of an existing page', async ({ page }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
const titleBarTextContent = await page.getByTestId('title-edit-button');
|
const titleBarTextContent = page.getByTestId('title-edit-button');
|
||||||
await titleBarTextContent.dblclick({ delay: 100 });
|
await titleBarTextContent.dblclick({ delay: 100 });
|
||||||
const titleContent = await page.getByTestId('title-content');
|
const titleContent = page.getByTestId('title-content');
|
||||||
await titleContent.fill('test');
|
await titleContent.fill('test');
|
||||||
await titleContent.blur();
|
await titleContent.blur();
|
||||||
expect(await titleBarTextContent.textContent()).toBe('test');
|
expect(await titleBarTextContent.textContent()).toBe('test');
|
||||||
@@ -94,9 +94,9 @@ test('Clearing out the title bar will remove the page title', async ({
|
|||||||
}) => {
|
}) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
const titleBarTextContent = await page.getByTestId('title-edit-button');
|
const titleBarTextContent = page.getByTestId('title-edit-button');
|
||||||
await titleBarTextContent.dblclick({ delay: 100 });
|
await titleBarTextContent.dblclick({ delay: 100 });
|
||||||
const titleContent = await page.getByTestId('title-content');
|
const titleContent = page.getByTestId('title-content');
|
||||||
await titleContent.fill('test');
|
await titleContent.fill('test');
|
||||||
await titleContent.blur();
|
await titleContent.blur();
|
||||||
expect(await titleBarTextContent.textContent()).toBe('test');
|
expect(await titleBarTextContent.textContent()).toBe('test');
|
||||||
|
|||||||
@@ -7,13 +7,11 @@ test('Click right-bottom corner contact icon', async ({ page }) => {
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await page.locator('[data-testid=help-island]').click();
|
await page.locator('[data-testid=help-island]').click();
|
||||||
const rightBottomContactUs = page.locator(
|
const rightBottomContactUs = page.getByTestId('right-bottom-contact-us-icon');
|
||||||
'[data-testid=right-bottom-contact-us-icon]'
|
await expect(rightBottomContactUs).toBeVisible();
|
||||||
);
|
|
||||||
expect(await rightBottomContactUs.isVisible()).toEqual(true);
|
|
||||||
|
|
||||||
await rightBottomContactUs.click();
|
await rightBottomContactUs.click();
|
||||||
|
|
||||||
const title = await page.getByTestId('about-title');
|
const title = page.getByTestId('about-title');
|
||||||
await expect(title).toBeVisible();
|
await expect(title).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { test } from '@affine-test/kit/playwright';
|
import { test } from '@affine-test/kit/playwright';
|
||||||
|
import { open404Page } from '@affine-test/kit/utils/load-page';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('visit 404 page', async ({ page }) => {
|
test('visit 404 page', async ({ page }) => {
|
||||||
await page.goto('http://localhost:8080/404');
|
await open404Page(page);
|
||||||
const notFoundTip = page.getByTestId('not-found');
|
const notFoundTip = page.getByTestId('not-found');
|
||||||
await expect(notFoundTip).toBeVisible();
|
await expect(notFoundTip).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,15 +44,15 @@ test('image preview should be shown', async ({ page }) => {
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('img').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
expect(await locator.isVisible()).toBeFalsy();
|
await expect(locator).not.toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('image go left and right', async ({ page }) => {
|
test('image go left and right', async ({ page }) => {
|
||||||
@@ -61,7 +61,7 @@ test('image go left and right', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -75,7 +75,7 @@ test('image go left and right', async ({ page }) => {
|
|||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
@@ -108,7 +108,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -130,26 +130,26 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
|
|||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// zooom in
|
// zoom in
|
||||||
await page.mouse.move(width / 2, height / 2);
|
await page.mouse.move(width / 2, height / 2);
|
||||||
await page.mouse.wheel(0, 100);
|
await page.mouse.wheel(0, 100);
|
||||||
await page.mouse.wheel(0, 100);
|
await page.mouse.wheel(0, 100);
|
||||||
await page.mouse.wheel(0, 100);
|
await page.mouse.wheel(0, 100);
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
let imageBoundary = await locator.boundingBox();
|
let imageBoundary = await locator.boundingBox();
|
||||||
let imageWidth = await imageBoundary?.width;
|
let imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.54');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.54');
|
||||||
}
|
}
|
||||||
|
|
||||||
// zooom in
|
// zoom in
|
||||||
await page.mouse.move(width / 2, height / 2);
|
await page.mouse.move(width / 2, height / 2);
|
||||||
await page.mouse.wheel(0, -100);
|
await page.mouse.wheel(0, -100);
|
||||||
await page.mouse.wheel(0, -100);
|
await page.mouse.wheel(0, -100);
|
||||||
await page.mouse.wheel(0, -100);
|
await page.mouse.wheel(0, -100);
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
imageBoundary = await locator.boundingBox();
|
imageBoundary = await locator.boundingBox();
|
||||||
imageWidth = await imageBoundary?.width;
|
imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.84');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.84');
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -174,7 +174,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-content');
|
const locator = page.getByTestId('image-content');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
const naturalWidth = await locator.evaluate(
|
const naturalWidth = await locator.evaluate(
|
||||||
(img: HTMLImageElement) => img.naturalWidth
|
(img: HTMLImageElement) => img.naturalWidth
|
||||||
);
|
);
|
||||||
@@ -187,7 +187,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
let imageBoundary = await locator.boundingBox();
|
let imageBoundary = await locator.boundingBox();
|
||||||
let imageWidth = await imageBoundary?.width;
|
let imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
|
|||||||
// zooom out
|
// zooom out
|
||||||
await page.getByTestId('zoom-out-button').dblclick();
|
await page.getByTestId('zoom-out-button').dblclick();
|
||||||
imageBoundary = await locator.boundingBox();
|
imageBoundary = await locator.boundingBox();
|
||||||
imageWidth = await imageBoundary?.width;
|
imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.84');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.84');
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ test('image should able to go left and right by buttons', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -221,16 +221,14 @@ test('image should able to go left and right by buttons', async ({ page }) => {
|
|||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('img').first().dblclick();
|
||||||
// ensure the new image was imported
|
await expect(locator).toBeVisible();
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
{
|
{
|
||||||
const newBlobId = (await locator
|
const newBlobId = (await locator
|
||||||
.getByTestId('image-content')
|
.getByTestId('image-content')
|
||||||
@@ -261,7 +259,7 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -274,7 +272,7 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-content');
|
const locator = page.getByTestId('image-content');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
const naturalWidth = await locator.evaluate(
|
const naturalWidth = await locator.evaluate(
|
||||||
(img: HTMLImageElement) => img.naturalWidth
|
(img: HTMLImageElement) => img.naturalWidth
|
||||||
);
|
);
|
||||||
@@ -289,7 +287,7 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
let imageBoundary = await locator.boundingBox();
|
let imageBoundary = await locator.boundingBox();
|
||||||
let imageWidth = await imageBoundary?.width;
|
let imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
||||||
} else {
|
} else {
|
||||||
@@ -302,8 +300,8 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|||||||
await locator.getByTestId('fit-to-screen-button').click();
|
await locator.getByTestId('fit-to-screen-button').click();
|
||||||
}
|
}
|
||||||
imageBoundary = await locator.boundingBox();
|
imageBoundary = await locator.boundingBox();
|
||||||
imageWidth = await imageBoundary?.width;
|
imageWidth = imageBoundary?.width;
|
||||||
const imageHeight = await imageBoundary?.height;
|
const imageHeight = imageBoundary?.height;
|
||||||
if (imageWidth && imageHeight) {
|
if (imageWidth && imageHeight) {
|
||||||
expect(imageWidth).toBeLessThan(viewportWidth);
|
expect(imageWidth).toBeLessThan(viewportWidth);
|
||||||
expect(imageHeight).toBeLessThan(viewportHeight);
|
expect(imageHeight).toBeLessThan(viewportHeight);
|
||||||
@@ -318,7 +316,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -331,20 +329,20 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-content');
|
const locator = page.getByTestId('image-content');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
const naturalWidth = await locator.evaluate(
|
const naturalWidth = await locator.evaluate(
|
||||||
(img: HTMLImageElement) => img.naturalWidth
|
(img: HTMLImageElement) => img.naturalWidth
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
// zooom in
|
// zoom in
|
||||||
{
|
{
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await locator.getByTestId('zoom-in-button').dblclick();
|
await locator.getByTestId('zoom-in-button').dblclick();
|
||||||
}
|
}
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
let imageBoundary = await locator.boundingBox();
|
let imageBoundary = await locator.boundingBox();
|
||||||
let imageWidth = await imageBoundary?.width;
|
let imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
||||||
} else {
|
} else {
|
||||||
@@ -357,7 +355,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|||||||
await locator.getByTestId('reset-scale-button').click();
|
await locator.getByTestId('reset-scale-button').click();
|
||||||
}
|
}
|
||||||
imageBoundary = await locator.boundingBox();
|
imageBoundary = await locator.boundingBox();
|
||||||
imageWidth = await imageBoundary?.width;
|
imageWidth = imageBoundary?.width;
|
||||||
if (imageWidth) {
|
if (imageWidth) {
|
||||||
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.00');
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.00');
|
||||||
} else {
|
} else {
|
||||||
@@ -371,7 +369,7 @@ test('image able to copy to clipboard', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -384,11 +382,13 @@ test('image able to copy to clipboard', async ({ page }) => {
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await locator.getByTestId('copy-to-clipboard-button').click();
|
await locator.getByTestId('copy-to-clipboard-button').click();
|
||||||
await page.on('console', message => {
|
await new Promise<void>(resolve => {
|
||||||
|
page.on('console', message => {
|
||||||
expect(message.text()).toBe('Image copied to clipboard');
|
expect(message.text()).toBe('Image copied to clipboard');
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ test('image able to download', async ({ page }) => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -411,7 +411,7 @@ test('image able to download', async ({ page }) => {
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
const downloadPromise = page.waitForEvent('download');
|
const downloadPromise = page.waitForEvent('download');
|
||||||
await locator.getByTestId('download-button').click();
|
await locator.getByTestId('download-button').click();
|
||||||
const download = await downloadPromise;
|
const download = await downloadPromise;
|
||||||
@@ -428,7 +428,7 @@ test('image should only able to move when image is larger than viewport', async
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -441,7 +441,7 @@ test('image should only able to move when image is larger than viewport', async
|
|||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-content');
|
const locator = page.getByTestId('image-content');
|
||||||
expect(locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
const { width, height } = await page.evaluate(() => ({
|
const { width, height } = await page.evaluate(() => ({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
@@ -449,7 +449,7 @@ test('image should only able to move when image is larger than viewport', async
|
|||||||
let imageBoundary = await locator.boundingBox();
|
let imageBoundary = await locator.boundingBox();
|
||||||
const initialXPos = imageBoundary?.x;
|
const initialXPos = imageBoundary?.x;
|
||||||
const initialYPos = imageBoundary?.y;
|
const initialYPos = imageBoundary?.y;
|
||||||
// check will it able to move when zoomed in
|
// check will it be able to move when zoomed in
|
||||||
{
|
{
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await locator.getByTestId('zoom-in-button').dblclick();
|
await locator.getByTestId('zoom-in-button').dblclick();
|
||||||
@@ -463,7 +463,7 @@ test('image should only able to move when image is larger than viewport', async
|
|||||||
expect(initialXPos).not.toBe(imageBoundary?.x);
|
expect(initialXPos).not.toBe(imageBoundary?.x);
|
||||||
expect(initialYPos).not.toBe(imageBoundary?.y);
|
expect(initialYPos).not.toBe(imageBoundary?.y);
|
||||||
|
|
||||||
// check will it able to move when zoomed out
|
// check will it be able to move when zoomed out
|
||||||
{
|
{
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await locator.getByTestId('fit-to-screen-button').click();
|
await locator.getByTestId('fit-to-screen-button').click();
|
||||||
@@ -485,7 +485,7 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -499,14 +499,14 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator.isVisible()).toBeTruthy();
|
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('img').first().dblclick();
|
||||||
|
await expect(locator).toBeVisible();
|
||||||
// ensure the new image was imported
|
// ensure the new image was imported
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
@@ -523,7 +523,7 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(newBlobId).toBe(blobId);
|
expect(newBlobId).toBe(blobId);
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
@@ -560,7 +560,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
let blobId: string;
|
let blobId: string;
|
||||||
{
|
{
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -577,7 +577,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('previous-image-button').hover();
|
await locator.getByTestId('previous-image-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const previousImageTooltip = await element.getByText('Previous').count();
|
const previousImageTooltip = await element.getByText('Previous').count();
|
||||||
expect(previousImageTooltip).toBe(1);
|
expect(previousImageTooltip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -585,7 +585,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('next-image-button').hover();
|
await locator.getByTestId('next-image-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const nextImageTooltip = await element.getByText('Next').count();
|
const nextImageTooltip = await element.getByText('Next').count();
|
||||||
expect(nextImageTooltip).toBe(1);
|
expect(nextImageTooltip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -593,7 +593,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('fit-to-screen-button').hover();
|
await locator.getByTestId('fit-to-screen-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const fitToScreenToolTip = await element.getByText('Fit to Screen').count();
|
const fitToScreenToolTip = await element.getByText('Fit to Screen').count();
|
||||||
expect(fitToScreenToolTip).toBe(1);
|
expect(fitToScreenToolTip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -601,7 +601,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('zoom-out-button').hover();
|
await locator.getByTestId('zoom-out-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const zoomOutToolTip = await element.getByText('Zoom out').count();
|
const zoomOutToolTip = await element.getByText('Zoom out').count();
|
||||||
expect(zoomOutToolTip).toBe(1);
|
expect(zoomOutToolTip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -609,7 +609,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('reset-scale-button').hover();
|
await locator.getByTestId('reset-scale-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const resetScaleTooltip = await element.getByText('Reset Scale').count();
|
const resetScaleTooltip = await element.getByText('Reset Scale').count();
|
||||||
expect(resetScaleTooltip).toBe(1);
|
expect(resetScaleTooltip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -617,7 +617,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('zoom-in-button').hover();
|
await locator.getByTestId('zoom-in-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const zoominToolTip = await element.getByText('Zoom in').count();
|
const zoominToolTip = await element.getByText('Zoom in').count();
|
||||||
expect(zoominToolTip).toBe(1);
|
expect(zoominToolTip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -625,7 +625,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('download-button').hover();
|
await locator.getByTestId('download-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const downloadTooltip = await element.getByText('Download').count();
|
const downloadTooltip = await element.getByText('Download').count();
|
||||||
expect(downloadTooltip).toBe(1);
|
expect(downloadTooltip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -633,7 +633,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('copy-to-clipboard-button').hover();
|
await locator.getByTestId('copy-to-clipboard-button').hover();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const downloadTooltip = await element
|
const downloadTooltip = await element
|
||||||
.getByText('Copy to clipboard')
|
.getByText('Copy to clipboard')
|
||||||
.count();
|
.count();
|
||||||
@@ -643,7 +643,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await locator.getByTestId('delete-button').hover();
|
await locator.getByTestId('delete-button').hover();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
{
|
{
|
||||||
const element = await page.getByRole('tooltip');
|
const element = page.getByRole('tooltip');
|
||||||
const downloadTooltip = await element.getByText('Delete').count();
|
const downloadTooltip = await element.getByText('Delete').count();
|
||||||
expect(downloadTooltip).toBe(1);
|
expect(downloadTooltip).toBe(1);
|
||||||
}
|
}
|
||||||
@@ -653,7 +653,7 @@ test('keypress esc should close the modal', async ({ page }) => {
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -671,18 +671,18 @@ test('when mouse moves outside, the modal should be closed', async ({
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('img').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
expect(await locator.isVisible()).toBeTruthy();
|
await expect(locator).toBeVisible();
|
||||||
// animation delay
|
// animation delay
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
await page.mouse.click(10, 10);
|
await page.mouse.click(10, 10);
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
expect(await locator.isVisible()).toBeFalsy();
|
await expect(locator).not.toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('caption should be visible and different styles were applied if image zoomed larger than viewport', async ({
|
test('caption should be visible and different styles were applied if image zoomed larger than viewport', async ({
|
||||||
@@ -692,7 +692,7 @@ test('caption should be visible and different styles were applied if image zoome
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
const title = await getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
@@ -711,8 +711,8 @@ test('caption should be visible and different styles were applied if image zoome
|
|||||||
await expect(captionLocator).toBeVisible();
|
await expect(captionLocator).toBeVisible();
|
||||||
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
||||||
await page.getByTestId('zoom-in-button').click({ clickCount: 4 });
|
await page.getByTestId('zoom-in-button').click({ clickCount: 4 });
|
||||||
expect(await captionLocator.isVisible()).not.toBeTruthy();
|
await expect(captionLocator).not.toBeVisible();
|
||||||
captionLocator = locator.getByTestId('image-caption-zoomedin');
|
captionLocator = locator.getByTestId('image-caption-zoomedin');
|
||||||
expect(await captionLocator.isVisible()).toBeTruthy();
|
await expect(captionLocator).toBeVisible();
|
||||||
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
|||||||
await openSettingModal(page);
|
await openSettingModal(page);
|
||||||
await openWorkspaceSettingPanel(page, 'Test Workspace');
|
await openWorkspaceSettingPanel(page, 'Test Workspace');
|
||||||
await page.getByTestId('delete-workspace-button').click();
|
await page.getByTestId('delete-workspace-button').click();
|
||||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
const workspaceNameDom = page.getByTestId('workspace-name');
|
||||||
const currentWorkspaceName = (await workspaceNameDom.evaluate(
|
const currentWorkspaceName = (await workspaceNameDom.evaluate(
|
||||||
node => node.textContent
|
node => node.textContent
|
||||||
)) as string;
|
)) as string;
|
||||||
@@ -51,7 +51,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
|||||||
test('Delete last workspace', async ({ page }) => {
|
test('Delete last workspace', async ({ page }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
const workspaceNameDom = page.getByTestId('workspace-name');
|
||||||
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
||||||
node => node.textContent
|
node => node.textContent
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { expect, type Page } from '@playwright/test';
|
|||||||
|
|
||||||
const openQuickSearchByShortcut = async (page: Page) => {
|
const openQuickSearchByShortcut = async (page: Page) => {
|
||||||
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
|
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const keyboardDownAndSelect = async (page: Page, label: string) => {
|
const keyboardDownAndSelect = async (page: Page, label: string) => {
|
||||||
@@ -151,6 +151,7 @@ test('Create a new page and search this page', async ({ page }) => {
|
|||||||
await page.waitForTimeout(300);
|
await page.waitForTimeout(300);
|
||||||
await assertTitle(page, 'test123456');
|
await assertTitle(page, 'test123456');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Navigate to the 404 page and try to open quick search', async ({
|
test('Navigate to the 404 page and try to open quick search', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -249,7 +250,6 @@ test('assert the recent browse pages are on the recent list', async ({
|
|||||||
await page.waitForTimeout(200);
|
await page.waitForTimeout(200);
|
||||||
|
|
||||||
await openQuickSearchByShortcut(page);
|
await openQuickSearchByShortcut(page);
|
||||||
await page.waitForTimeout(200);
|
|
||||||
{
|
{
|
||||||
// check does all 3 pages exists on recent page list
|
// check does all 3 pages exists on recent page list
|
||||||
const quickSearchItems = page.locator(
|
const quickSearchItems = page.locator(
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ test('Open settings modal', async ({ page }) => {
|
|||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await openSettingModal(page);
|
await openSettingModal(page);
|
||||||
|
|
||||||
const modal = await page.getByTestId('setting-modal');
|
const modal = page.getByTestId('setting-modal');
|
||||||
await expect(modal).toBeVisible();
|
await expect(modal).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ test('Change layout width', async ({ page }) => {
|
|||||||
|
|
||||||
await page.getByTestId('full-width-layout-trigger').click();
|
await page.getByTestId('full-width-layout-trigger').click();
|
||||||
|
|
||||||
const editorWrapper = await page.locator('.editor-wrapper');
|
const editorWrapper = page.locator('.editor-wrapper');
|
||||||
const className = await editorWrapper.getAttribute('class');
|
const className = await editorWrapper.getAttribute('class');
|
||||||
expect(className).toContain('full-screen');
|
expect(className).toContain('full-screen');
|
||||||
});
|
});
|
||||||
@@ -79,7 +79,7 @@ test('Open shortcuts panel', async ({ page }) => {
|
|||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await openSettingModal(page);
|
await openSettingModal(page);
|
||||||
await openShortcutsPanel(page);
|
await openShortcutsPanel(page);
|
||||||
const title = await page.getByTestId('keyboard-shortcuts-title');
|
const title = page.getByTestId('keyboard-shortcuts-title');
|
||||||
await expect(title).toBeVisible();
|
await expect(title).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ test('Open plugins panel', async ({ page }) => {
|
|||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await openSettingModal(page);
|
await openSettingModal(page);
|
||||||
await openPluginsPanel(page);
|
await openPluginsPanel(page);
|
||||||
const title = await page.getByTestId('plugins-title');
|
const title = page.getByTestId('plugins-title');
|
||||||
await expect(title).toBeVisible();
|
await expect(title).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ test('Open about panel', async ({ page }) => {
|
|||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await openSettingModal(page);
|
await openSettingModal(page);
|
||||||
await openAboutPanel(page);
|
await openAboutPanel(page);
|
||||||
const title = await page.getByTestId('about-title');
|
const title = page.getByTestId('about-title');
|
||||||
await expect(title).toBeVisible();
|
await expect(title).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
|
|
||||||
export const coreUrl = 'http://localhost:8080';
|
export const coreUrl = 'http://localhost:8080';
|
||||||
export const prototypeUrl = 'http://localhost:3003';
|
|
||||||
|
|
||||||
export async function openHomePage(page: Page) {
|
export async function openHomePage(page: Page) {
|
||||||
await page.goto(coreUrl);
|
await page.goto(coreUrl);
|
||||||
@@ -11,6 +10,6 @@ export async function openPluginPage(page: Page) {
|
|||||||
await page.goto(`${coreUrl}/_plugin/index.html`);
|
await page.goto(`${coreUrl}/_plugin/index.html`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openPrototypeProviderStatusPage(page: Page) {
|
export async function open404Page(page: Page) {
|
||||||
await page.goto(`${prototypeUrl}/suite/provider-status.html`);
|
await page.goto(`${coreUrl}/404`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user