Skip to content

Commit

Permalink
test: add image-upload e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Janson1012 committed Sep 6, 2024
1 parent 89b7630 commit 2e93243
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/docs/fluent-editor/demos/image-upload.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'node:url';
// fluent-editor\packages\docs\fluent-editor\public\logo.png
const __filename = fileURLToPath(import.meta.url)
let currentDirectory = path.dirname(__filename);
const baseUrl = path.dirname(currentDirectory)
test('image-uplaod', async ({ page }) => {
await page.goto('http://localhost:5173/fluent-editor/docs/image-upload');
await page.getByLabel('image').click();
await page.locator('.ql-toolbar input').setInputFiles(path.join(baseUrl, "public", "logo.png"));
await expect(page.locator('#editor').getByRole('img')).toBeVisible();
await page.locator('#editor').getByRole('img').click();
await expect(page.locator('.blot-formatter__overlay')).toBeVisible();
const move_Distance = 100
const imageElement = page.locator('#editor').getByRole('img');
const oldBox = await imageElement.boundingBox() as { x: number, y: number, width: number; height: number; };
await page.mouse.move(oldBox.x, oldBox.y);
await page.mouse.down()
await page.mouse.move(oldBox.x + move_Distance, oldBox.y + move_Distance)
await page.mouse.up();
const newBox = await imageElement.boundingBox() as { x: number, y: number, width: number; height: number; };
expect(newBox.width + move_Distance).toEqual(oldBox.width)
expect(newBox.height + move_Distance).toEqual(oldBox.height)
await page.mouse.click(newBox.x + newBox.width + 2, newBox.y + newBox.height + 2);
await expect(page.locator('.blot-formatter__overlay')).not.toBeVisible();
});

0 comments on commit 2e93243

Please sign in to comment.