|
|
|
@@ -44,15 +44,15 @@ test('image preview should be shown', async ({ page }) => {
|
|
|
|
|
await openHomePage(page);
|
|
|
|
|
await waitForEditorLoad(page);
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
|
|
|
|
await page.locator('img').first().dblclick();
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
await closeImagePreviewModal(page);
|
|
|
|
|
expect(await locator.isVisible()).toBeFalsy();
|
|
|
|
|
await expect(locator).not.toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('image go left and right', async ({ page }) => {
|
|
|
|
@@ -61,7 +61,7 @@ test('image go left and right', async ({ page }) => {
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
|
|
|
@@ -75,7 +75,7 @@ test('image go left and right', async ({ page }) => {
|
|
|
|
|
await closeImagePreviewModal(page);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// zooom in
|
|
|
|
|
// zoom in
|
|
|
|
|
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.waitForTimeout(1000);
|
|
|
|
|
let imageBoundary = await locator.boundingBox();
|
|
|
|
|
let imageWidth = await imageBoundary?.width;
|
|
|
|
|
let imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('0.54');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// zooom in
|
|
|
|
|
// zoom in
|
|
|
|
|
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.waitForTimeout(1000);
|
|
|
|
|
imageBoundary = await locator.boundingBox();
|
|
|
|
|
imageWidth = await imageBoundary?.width;
|
|
|
|
|
imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-content');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
const naturalWidth = await locator.evaluate(
|
|
|
|
|
(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);
|
|
|
|
|
let imageBoundary = await locator.boundingBox();
|
|
|
|
|
let imageWidth = await imageBoundary?.width;
|
|
|
|
|
let imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
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
|
|
|
|
|
await page.getByTestId('zoom-out-button').dblclick();
|
|
|
|
|
imageBoundary = await locator.boundingBox();
|
|
|
|
|
imageWidth = await imageBoundary?.width;
|
|
|
|
|
imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await page.locator('img').first().dblclick();
|
|
|
|
|
// ensure the new image was imported
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
{
|
|
|
|
|
const newBlobId = (await locator
|
|
|
|
|
.getByTestId('image-content')
|
|
|
|
@@ -261,7 +259,7 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-content');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
const naturalWidth = await locator.evaluate(
|
|
|
|
|
(img: HTMLImageElement) => img.naturalWidth
|
|
|
|
|
);
|
|
|
|
@@ -289,7 +287,7 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|
|
|
|
}
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
let imageBoundary = await locator.boundingBox();
|
|
|
|
|
let imageWidth = await imageBoundary?.width;
|
|
|
|
|
let imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
|
|
|
|
} else {
|
|
|
|
@@ -302,8 +300,8 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|
|
|
|
await locator.getByTestId('fit-to-screen-button').click();
|
|
|
|
|
}
|
|
|
|
|
imageBoundary = await locator.boundingBox();
|
|
|
|
|
imageWidth = await imageBoundary?.width;
|
|
|
|
|
const imageHeight = await imageBoundary?.height;
|
|
|
|
|
imageWidth = imageBoundary?.width;
|
|
|
|
|
const imageHeight = imageBoundary?.height;
|
|
|
|
|
if (imageWidth && imageHeight) {
|
|
|
|
|
expect(imageWidth).toBeLessThan(viewportWidth);
|
|
|
|
|
expect(imageHeight).toBeLessThan(viewportHeight);
|
|
|
|
@@ -318,7 +316,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-content');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
const naturalWidth = await locator.evaluate(
|
|
|
|
|
(img: HTMLImageElement) => img.naturalWidth
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
// zooom in
|
|
|
|
|
// zoom in
|
|
|
|
|
{
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
await locator.getByTestId('zoom-in-button').dblclick();
|
|
|
|
|
}
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
let imageBoundary = await locator.boundingBox();
|
|
|
|
|
let imageWidth = await imageBoundary?.width;
|
|
|
|
|
let imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.04');
|
|
|
|
|
} else {
|
|
|
|
@@ -357,7 +355,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|
|
|
|
await locator.getByTestId('reset-scale-button').click();
|
|
|
|
|
}
|
|
|
|
|
imageBoundary = await locator.boundingBox();
|
|
|
|
|
imageWidth = await imageBoundary?.width;
|
|
|
|
|
imageWidth = imageBoundary?.width;
|
|
|
|
|
if (imageWidth) {
|
|
|
|
|
expect((imageWidth / naturalWidth).toFixed(2)).toBe('1.00');
|
|
|
|
|
} else {
|
|
|
|
@@ -371,7 +369,7 @@ test('image able to copy to clipboard', async ({ page }) => {
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
await locator.getByTestId('copy-to-clipboard-button').click();
|
|
|
|
|
await page.on('console', message => {
|
|
|
|
|
expect(message.text()).toBe('Image copied to clipboard');
|
|
|
|
|
await new Promise<void>(resolve => {
|
|
|
|
|
page.on('console', message => {
|
|
|
|
|
expect(message.text()).toBe('Image copied to clipboard');
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@@ -398,7 +398,7 @@ test('image able to download', async ({ page }) => {
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
|
|
|
@@ -411,7 +411,7 @@ test('image able to download', async ({ page }) => {
|
|
|
|
|
expect(blobId).toBeTruthy();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
const downloadPromise = page.waitForEvent('download');
|
|
|
|
|
await locator.getByTestId('download-button').click();
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-content');
|
|
|
|
|
expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
const { width, height } = await page.evaluate(() => ({
|
|
|
|
|
width: window.innerWidth,
|
|
|
|
|
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();
|
|
|
|
|
const initialXPos = imageBoundary?.x;
|
|
|
|
|
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');
|
|
|
|
|
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(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');
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
|
|
|
|
}
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
await expect(locator.isVisible()).toBeTruthy();
|
|
|
|
|
await page.locator('img').first().dblclick();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
// ensure the new image was imported
|
|
|
|
|
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;
|
|
|
|
|
expect(newBlobId).toBe(blobId);
|
|
|
|
|
await closeImagePreviewModal(page);
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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);
|
|
|
|
|
let blobId: string;
|
|
|
|
|
{
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const previousImageTooltip = await element.getByText('Previous').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const nextImageTooltip = await element.getByText('Next').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const fitToScreenToolTip = await element.getByText('Fit to Screen').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const zoomOutToolTip = await element.getByText('Zoom out').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const resetScaleTooltip = await element.getByText('Reset Scale').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const zoominToolTip = await element.getByText('Zoom in').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const downloadTooltip = await element.getByText('Download').count();
|
|
|
|
|
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 page.waitForTimeout(1000);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const downloadTooltip = await element
|
|
|
|
|
.getByText('Copy to clipboard')
|
|
|
|
|
.count();
|
|
|
|
@@ -643,7 +643,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|
|
|
|
await locator.getByTestId('delete-button').hover();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
{
|
|
|
|
|
const element = await page.getByRole('tooltip');
|
|
|
|
|
const element = page.getByRole('tooltip');
|
|
|
|
|
const downloadTooltip = await element.getByText('Delete').count();
|
|
|
|
|
expect(downloadTooltip).toBe(1);
|
|
|
|
|
}
|
|
|
|
@@ -653,7 +653,7 @@ test('keypress esc should close the modal', async ({ page }) => {
|
|
|
|
|
await openHomePage(page);
|
|
|
|
|
await waitForEditorLoad(page);
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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 waitForEditorLoad(page);
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
|
|
|
|
await page.locator('img').first().dblclick();
|
|
|
|
|
const locator = page.getByTestId('image-preview-modal');
|
|
|
|
|
expect(await locator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(locator).toBeVisible();
|
|
|
|
|
// animation delay
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
await page.mouse.click(10, 10);
|
|
|
|
|
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 ({
|
|
|
|
@@ -692,7 +692,7 @@ test('caption should be visible and different styles were applied if image zoome
|
|
|
|
|
await openHomePage(page);
|
|
|
|
|
await waitForEditorLoad(page);
|
|
|
|
|
await clickNewPageButton(page);
|
|
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
|
await title.click();
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
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();
|
|
|
|
|
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
|
|
|
|
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');
|
|
|
|
|
expect(await captionLocator.isVisible()).toBeTruthy();
|
|
|
|
|
await expect(captionLocator).toBeVisible();
|
|
|
|
|
expect(await captionLocator.innerText()).toBe(sampleCaption);
|
|
|
|
|
});
|
|
|
|
|