E2e tests for the toolbar (#2709)

This PR adds some e2e tests for the toolbar.

Fixtures have been set up for the toolbar and style panel, and are
fairly barebones at the moment. Eventually each menu should have a
fixture associated with it, and all tests will use the class defined in
the fixtures file.

### Change Type

- [x] `tests` — Changes to any test code only[^2]

### Release Notes

- Add e2e tests for the toolbar
This commit is contained in:
Taha 2024-02-16 14:15:00 +00:00 committed by GitHub
parent c039d44f72
commit 7e673b5e37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 216 additions and 48 deletions

View file

@ -1,5 +1,6 @@
import test, { Page, expect } from '@playwright/test'
import { getAllShapeTypes, setupPage } from '../shared-e2e'
import { expect } from '@playwright/test'
import { getAllShapeTypes, setup } from '../shared-e2e'
import test from './fixtures/fixtures'
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
@ -57,15 +58,9 @@ const draggableShapeCreators = [
const otherTools = [{ tool: 'select' }, { tool: 'eraser' }, { tool: 'laser' }]
let page: Page
test.describe('Shape Tools', () => {
test.beforeAll(async ({ browser }) => {
page = await browser.newPage()
await setupPage(page)
})
test('creates shapes with other tools', async () => {
test.beforeEach(setup)
test('creates shapes with other tools', async ({ toolbar, page }) => {
await page.keyboard.press('Control+a')
await page.keyboard.press('Backspace')
expect(await getAllShapeTypes(page)).toEqual([])
@ -73,17 +68,17 @@ test.describe('Shape Tools', () => {
for (const { tool } of otherTools) {
// Find and click the button
if (!(await page.getByTestId(`tools.${tool}`).isVisible())) {
if (!(await page.getByTestId(`tools.more`).isVisible())) {
if (!(await toolbar.moreToolsButton.isVisible())) {
throw Error(`Tool more is not visible`)
}
await page.getByTestId('tools.more').click()
await toolbar.moreToolsButton.click()
if (!(await page.getByTestId(`tools.more.${tool}`).isVisible())) {
throw Error(`Tool in more panel is not visible`)
}
await page.getByTestId(`tools.more.${tool}`).click()
await page.getByTestId(`tools.more`).click()
await toolbar.moreToolsButton.click()
}
if (!(await page.getByTestId(`tools.${tool}`).isVisible())) {
@ -102,7 +97,7 @@ test.describe('Shape Tools', () => {
}
})
test('creates shapes clickable tools', async () => {
test('creates shapes clickable tools', async ({ page, toolbar }) => {
await page.keyboard.press('v')
await page.keyboard.press('Control+a')
await page.keyboard.press('Backspace')
@ -111,9 +106,9 @@ test.describe('Shape Tools', () => {
for (const { tool, shape } of clickableShapeCreators) {
// Find and click the button
if (!(await page.getByTestId(`tools.${tool}`).isVisible())) {
await page.getByTestId('tools.more').click()
await toolbar.moreToolsButton.click()
await page.getByTestId(`tools.more.${tool}`).click()
await page.getByTestId('tools.more').click()
await toolbar.moreToolsButton.click()
}
await page.getByTestId(`tools.${tool}`).click()
@ -141,7 +136,7 @@ test.describe('Shape Tools', () => {
expect(await getAllShapeTypes(page)).toEqual([])
})
test('creates shapes with draggable tools', async () => {
test('creates shapes with draggable tools', async ({ page, toolbar }) => {
await page.keyboard.press('Control+a')
await page.keyboard.press('Backspace')
expect(await getAllShapeTypes(page)).toEqual([])
@ -149,9 +144,9 @@ test.describe('Shape Tools', () => {
for (const { tool, shape } of draggableShapeCreators) {
// Find and click the button
if (!(await page.getByTestId(`tools.${tool}`).isVisible())) {
await page.getByTestId('tools.more').click()
await toolbar.moreToolsButton.click()
await page.getByTestId(`tools.more.${tool}`).click()
await page.getByTestId('tools.more').click()
await toolbar.moreToolsButton.click()
}
await page.getByTestId(`tools.${tool}`).click()