Skip to content

Commit 5238975

Browse files
committed
This test wasn't robust to delays, so now it auto-awaits
1 parent 5e1268b commit 5238975

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

e2e/playwright/debug-pane.spec.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ test.describe('Debug pane', { tag: '@desktop' }, () => {
5252
await page.keyboard.press('ArrowDown')
5353
}
5454
})
55+
let lastSegmentText = await segment.innerText()
5556
// TODO: if you type all the code at once without delay (or paste it in)
5657
// the initial segment artifact ID is different. This appears to be niche bug
5758
// that is being sidestepped in this test until https://github.com/KittyCAD/modeling-app/issues/9609 is addressed.
@@ -60,20 +61,24 @@ test.describe('Debug pane', { tag: '@desktop' }, () => {
6061
// Wait for keyboard input debounce and updated artifact graph.
6162
await page.waitForTimeout(1000)
6263
})
63-
// Extract the artifact IDs from the debug artifact graph.
64-
const initialSegmentIds = await segment.innerText({ timeout: 5_000 })
64+
await expect(segment).not.toHaveText(lastSegmentText)
6565
// The artifact ID should include a UUID.
66-
expect(initialSegmentIds).toMatch(
66+
const uuidRegexp =
6767
/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
68-
)
69-
await test.step('Enter a comment', async () => {
68+
await expect(segment).toHaveText(uuidRegexp)
69+
const uuid = (await segment.innerText()).match(uuidRegexp)!
70+
console.log('WHAT', await segment.innerText())
71+
72+
await test.step('Enter another line', async () => {
73+
lastSegmentText = await segment.innerText()
7074
await page.keyboard.type('\n|> line(end = [2, 2])', { delay: 10 })
7175
// Wait for keyboard input debounce and updated artifact graph.
7276
await page.waitForTimeout(1000)
7377
})
74-
const newSegmentIds = await segment.innerText()
75-
// Strip off the closing bracket.
76-
const initialIds = initialSegmentIds.slice(0, initialSegmentIds.length - 1)
77-
expect(newSegmentIds.slice(0, initialIds.length)).toEqual(initialIds)
78+
79+
// Expect the artifact IDs to be changed (by adding another),
80+
expect(segment).not.toHaveText(lastSegmentText)
81+
// but still contain the stable first ID.
82+
expect(segment).toContainText(uuid)
7883
})
7984
})

0 commit comments

Comments
 (0)