AI-native design editor. Open-source Figma alternative.
test(e2e): remove raw test id selectors
Danila Poyarkov1583181d3acd
diff --git a/tests/e2e/color-picker/basic.spec.ts b/tests/e2e/color-picker/basic.spec.tsindex a5f6c2d52..e5a7628ba 100644--- a/tests/e2e/color-picker/basic.spec.ts+++ b/tests/e2e/color-picker/basic.spec.ts@@ -43,7 +43,7 @@ async function chooseFormat(label: 'RGB' | 'HSL' | 'HSB' | 'OkHCL') {}async function dragSlider(testId: string, ratio: number) {- const slider = page.locator(`[data-test-id="${testId}"] input[type="range"]`)+ const slider = page.getByTestId(testId).locator('input[type="range"]')const box = await slider.boundingBox()if (!box) throw new Error(`Missing slider: ${testId}`)const y = box.y + box.height / 2diff --git a/tests/e2e/color-picker/demo-card.spec.ts b/tests/e2e/color-picker/demo-card.spec.tsindex f2889715a..af759f849 100644--- a/tests/e2e/color-picker/demo-card.spec.ts+++ b/tests/e2e/color-picker/demo-card.spec.ts@@ -8,7 +8,7 @@ async function dragSlider(testId: string,ratio: number) {- const slider = page.locator(`[data-test-id="${testId}"] input[type="range"]`)+ const slider = page.getByTestId(testId).locator('input[type="range"]')const box = await slider.boundingBox()if (!box) throw new Error(`Missing slider: ${testId}`)const y = box.y + box.height / 2diff --git a/tests/e2e/components/assets-panel.spec.ts b/tests/e2e/components/assets-panel.spec.tsindex 613edcf79..efaad3df8 100644--- a/tests/e2e/components/assets-panel.spec.ts+++ b/tests/e2e/components/assets-panel.spec.ts@@ -151,7 +151,7 @@ test('assets panel groups component sets and inserts the default variant', asyncawait page.getByTestId('assets-search').fill('card')await expect(assetItems).toHaveCount(1)await expect(assetsPanel).toContainText('Card')- await page.locator(`[data-asset-id="${ids.cardId}"] [data-test-id="asset-insert"]`).click()+ await page.locator(`[data-asset-id="${ids.cardId}"]`).getByTestId('asset-insert').click()await canvas.waitForRender()const cardInstance = await selectedNodeSnapshot(page)@@ -164,7 +164,7 @@ test('assets panel groups component sets and inserts the default variant', asyncawait page.getByTestId('assets-search').fill('button')await expect(assetItems).toHaveCount(1)- await page.locator(`[data-asset-id="${ids.setId}"] [data-test-id="asset-insert"]`).click()+ await page.locator(`[data-asset-id="${ids.setId}"]`).getByTestId('asset-insert').click()await canvas.waitForRender()const inserted = await selectedNodeSnapshot(page)@@ -177,7 +177,7 @@ test('assets panel groups component sets and inserts the default variant', asyncawait expect(page.getByTestId('variant-section')).toBeVisible()- await page.locator('[data-test-id="variant-section"] [data-test-id="app-select-trigger"]').click()+ await page.getByTestId('variant-section').getByTestId('app-select-trigger').click()await page.getByRole('option', { name: 'Primary' }).click()expectDefined(inserted?.id, 'inserted instance id')@@ -223,7 +223,7 @@ test('assets insertion accounts for entered container coordinates', async ({ pagawait canvas.waitForRender()await page.getByTestId('left-panel-assets-tab').click()- await page.locator(`[data-asset-id="${setup.componentId}"] [data-test-id="asset-insert"]`).click()+ await page.locator(`[data-asset-id="${setup.componentId}"]`).getByTestId('asset-insert').click()await canvas.waitForRender()const inserted = await page.evaluate(() => {diff --git a/tests/e2e/context-menu/basic.spec.ts b/tests/e2e/context-menu/basic.spec.tsindex 7ee324be1..2437bf72c 100644--- a/tests/e2e/context-menu/basic.spec.ts+++ b/tests/e2e/context-menu/basic.spec.ts@@ -51,7 +51,7 @@ function contextMenu() {}function contextItem(testId: string) {- return page.locator(`[data-test-id="${testId}"]`)+ return page.getByTestId(testId)}test('right-click on empty canvas shows context menu without selection items disabled', async () => {diff --git a/tests/e2e/editor/auto-layout/basic.spec.ts b/tests/e2e/editor/auto-layout/basic.spec.tsindex 3291cc332..a66b10de2 100644--- a/tests/e2e/editor/auto-layout/basic.spec.ts+++ b/tests/e2e/editor/auto-layout/basic.spec.ts@@ -83,7 +83,7 @@ test('gap menu sets auto space-between alignment', async () => {await canvas.waitForRender()let frame = await getNodeById(page, frameId)expect(expectDefined(frame, 'frame').primaryAxisAlign).toBe('SPACE_BETWEEN')- await expect(page.locator('[data-test-id="layout-alignment-grid"] button')).toHaveCount(9)+ await expect(page.getByTestId('layout-alignment-grid').locator('button')).toHaveCount(9)await page.getByTestId('layout-gap-menu').click()await page@@ -93,7 +93,7 @@ test('gap menu sets auto space-between alignment', async () => {frame = await getNodeById(page, frameId)expect(expectDefined(frame, 'frame').primaryAxisAlign).toBe('MIN')- await expect(page.locator('[data-test-id="layout-alignment-grid"] button')).toHaveCount(9)+ await expect(page.getByTestId('layout-alignment-grid').locator('button')).toHaveCount(9)canvas.assertNoErrors()})@@ -168,7 +168,7 @@ test('size dropdown adds and removes min width', async () => {test('alignment grid center sets CENTER alignment', async () => {await selectFrame()- const centerCell = page.locator('[data-test-id="layout-alignment-grid"] button').nth(4)+ const centerCell = page.getByTestId('layout-alignment-grid').locator('button').nth(4)await centerCell.click()await canvas.waitForRender()diff --git a/tests/e2e/export/basic.spec.ts b/tests/e2e/export/basic.spec.tsindex 4becea99f..efcbe0ae4 100644--- a/tests/e2e/export/basic.spec.ts+++ b/tests/e2e/export/basic.spec.ts@@ -79,7 +79,7 @@ test('preview toggle shows image with blob src', async () => {await page.getByTestId('export-preview-toggle').click()- const img = page.locator('[data-test-id="export-section"] img')+ const img = page.getByTestId('export-section').locator('img')await expect(img).toBeVisible({ timeout: 10000 })const src = await img.getAttribute('src')diff --git a/tests/e2e/layers/reorder.spec.ts b/tests/e2e/layers/reorder.spec.tsindex 592f8511e..e1731b350 100644--- a/tests/e2e/layers/reorder.spec.ts+++ b/tests/e2e/layers/reorder.spec.ts@@ -29,8 +29,8 @@ test('dragging layers reorders scene nodes', async ({ page }) => {})await canvas.waitForRender()- const source = page.locator(`[data-node-id="${ids.third}"] [data-test-id="layers-item"]`)- const target = page.locator(`[data-node-id="${ids.first}"] [data-test-id="layers-item"]`)+ const source = page.locator(`[data-node-id="${ids.third}"]`).getByTestId('layers-item')+ const target = page.locator(`[data-node-id="${ids.first}"]`).getByTestId('layers-item')await source.dragTo(target, { targetPosition: { x: 20, y: 2 } })await canvas.waitForRender()@@ -70,12 +70,12 @@ test('dragging a layer into a container expands it and shows the child', async (})await canvas.waitForRender()- const source = page.locator(`[data-node-id="${ids.rect}"] [data-test-id="layers-item"]`)- const target = page.locator(`[data-node-id="${ids.frame}"] [data-test-id="layers-item"]`)+ const source = page.locator(`[data-node-id="${ids.rect}"]`).getByTestId('layers-item')+ const target = page.locator(`[data-node-id="${ids.frame}"]`).getByTestId('layers-item')await source.dragTo(target, { targetPosition: { x: 70, y: 12 } })await canvas.waitForRender()- await expect(page.locator(`[data-node-id="${ids.rect}"] [data-test-id="layers-item"]`)).toBeVisible()+ await expect(page.locator(`[data-node-id="${ids.rect}"]`).getByTestId('layers-item')).toBeVisible()expect(await layerOrder(page, ids.frame)).toEqual([ids.rect])canvas.assertNoErrors()})diff --git a/tests/e2e/properties/corner-stroke-toggles.spec.ts b/tests/e2e/properties/corner-stroke-toggles.spec.tsindex a6ac6ce2d..9e4b7a173 100644--- a/tests/e2e/properties/corner-stroke-toggles.spec.ts+++ b/tests/e2e/properties/corner-stroke-toggles.spec.ts@@ -78,14 +78,14 @@ test('stroke sides toggle shows per-side weight inputs', async () => {await expect(toggle).toBeVisible({ timeout: 5000 })const sectionInputsBefore = await page- .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')+ .getByTestId('stroke-section').getByTestId('scrub-input').count()await toggle.click()await canvas.waitForRender()const sectionInputsAfter = await page- .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')+ .getByTestId('stroke-section').getByTestId('scrub-input').count()expect(sectionInputsAfter).toBeGreaterThan(sectionInputsBefore)@@ -93,7 +93,7 @@ test('stroke sides toggle shows per-side weight inputs', async () => {await canvas.waitForRender()const sectionInputsFinal = await page- .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')+ .getByTestId('stroke-section').getByTestId('scrub-input').count()expect(sectionInputsFinal).toBe(sectionInputsBefore)})diff --git a/tests/e2e/properties/panel.spec.ts b/tests/e2e/properties/panel.spec.tsindex 316e0d3a8..aa51de05f 100644--- a/tests/e2e/properties/panel.spec.ts+++ b/tests/e2e/properties/panel.spec.ts@@ -27,7 +27,7 @@ test('ScrubInput drag changes X position', async () => {const initialX = expectDefined(before, 'selected rectangle before drag').xconst xScrub = page- .locator('[data-test-id="position-section"] [data-test-id="scrub-input"]')+ .getByTestId('position-section').getByTestId('scrub-input').first()await canvas.dragScrubInput(xScrub, 50)diff --git a/tests/e2e/stroke-picker/basic.spec.ts b/tests/e2e/stroke-picker/basic.spec.tsindex 6f48321a4..23d25b602 100644--- a/tests/e2e/stroke-picker/basic.spec.ts+++ b/tests/e2e/stroke-picker/basic.spec.ts@@ -3,7 +3,7 @@ import { expect, test, type Page } from '@playwright/test'import { CanvasHelper } from '#tests/helpers/canvas'async function dragSlider(page: Page, canvas: CanvasHelper, testId: string, ratio: number) {- const slider = page.locator(`[data-test-id="${testId}"] input[type="range"]`)+ const slider = page.getByTestId(testId).locator('input[type="range"]')const box = await slider.boundingBox()if (!box) throw new Error(`Missing slider: ${testId}`)const y = box.y + box.height / 2@@ -18,10 +18,11 @@ async function dragSlider(page: Page, canvas: CanvasHelper, testId: string, ratiasync function openStrokePicker(page: Page) {await page- .locator('[data-test-id="stroke-item"] [data-test-id="color-picker-popover"]')+ .getByTestId('stroke-item')+ .getByTestId('color-picker-popover').waitFor({ state: 'detached' }).catch(() => undefined)- await page.locator('[data-test-id="stroke-item"] button').first().click()+ await page.getByTestId('stroke-item').locator('button').first().click()await expect(page.getByTestId('color-picker-popover')).toBeVisible()}