chore: add more tests and ids

pull/6573/head
Konstantinos Kaloutas 2022-09-05 13:24:04 +03:00
parent 8c3bc8ad29
commit 1e15062896
4 changed files with 37 additions and 5 deletions

View File

@ -12,7 +12,7 @@ test('enable whiteboards', async ({ page }) => {
test('create new whiteboard', async ({ page }) => {
await page.click('.nav-header .whiteboard')
await page.click('#main-content-container .dashboard-create-card')
await page.click('#tl-create-whiteboard')
await expect(page.locator('.logseq-tldraw')).toBeVisible()
})
@ -24,6 +24,38 @@ test('set whiteboard title', async ({ page }) => {
await expect(page.locator('.whiteboard-page-title .title')).toContainText(title);
})
test('select rectangle tool', async ({ page }) => {
await page.keyboard.press('R')
await expect(page.locator('.tl-geometry-tools-pane-anchor [title="Rectangle (r)"]')).toHaveAttribute('data-selected', 'true')
})
test('draw a rectangle', async ({ page }) => {
const canvas = await page.waitForSelector('.logseq-tldraw');
const bounds = (await canvas.boundingBox())!;
await page.keyboard.press('R')
await page.mouse.move(bounds.x, bounds.y);
await page.mouse.down();
await page.mouse.move(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
await page.mouse.up();
await page.keyboard.press('Escape')
await expect(page.locator('.logseq-tldraw .tl-positioned-svg rect')).toHaveCount(2);
})
test('zoom in', async ({ page }) => {
await page.click('#tl-zoom-in')
await expect(page.locator('#tl-zoom')).toContainText('125%');
})
test('zoom out', async ({ page }) => {
await page.click('#tl-zoom-out')
await expect(page.locator('#tl-zoom')).toContainText('100%');
})
test('open context menu', async ({ page }) => {
await page.locator('.logseq-tldraw').click({button: "right"})
await expect(page.locator('.tl-context-menu')).toBeVisible()

View File

@ -120,7 +120,7 @@
(rum/defc dashboard-create-card
[]
[:div.dashboard-card.dashboard-create-card.cursor-pointer
[:div.dashboard-card.dashboard-create-card.cursor-pointer#tl-create-whiteboard
{:on-click
(fn [e]
(util/stop e)

View File

@ -37,10 +37,10 @@ export const ActionBar = observer(function ActionBar(): JSX.Element {
</div>
<div className="tl-zoom-bar">
<button title="Zoom in" onClick={zoomIn}>
<button title="Zoom in" onClick={zoomIn} id="tl-zoom-in">
<TablerIcon name="plus" />
</button>
<button title="Zoom out" onClick={zoomOut}>
<button title="Zoom out" onClick={zoomOut} id="tl-zoom-out">
<TablerIcon name="minus" />
</button>
<ZoomMenu />

View File

@ -11,7 +11,7 @@ export const ZoomMenu = observer(function ZoomMenu(): JSX.Element {
return (
<DropdownMenuPrimitive.Root>
<DropdownMenuPrimitive.Trigger>
<DropdownMenuPrimitive.Trigger id="tl-zoom">
{(app.viewport.camera.zoom * 100).toFixed(0) + '%'}
</DropdownMenuPrimitive.Trigger>
<DropdownMenuPrimitive.Content