Skip to content

Commit

Permalink
Fix test and check if selected
Browse files Browse the repository at this point in the history
  • Loading branch information
farmaazon committed Feb 2, 2024
1 parent ec10dfa commit ecf0807
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/gui2/e2e/componentBrowser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ test('Accepting suggestion', async ({ page }) => {
'.',
'read_text',
])
await customExpect.toBeSelected(locate.graphNode(page).last())

// Clicking at highlighted entry
nodeCount = await locate.graphNode(page).count()
await page.mouse.click(100, 100) // deselect node
await locate.addNewNodeButton(page).click()
await locate.componentBrowserSelectedEntry(page).first().click()
await expect(locate.componentBrowser(page)).not.toBeVisible()
Expand All @@ -85,9 +87,11 @@ test('Accepting suggestion', async ({ page }) => {
'.',
'read',
])
await customExpect.toBeSelected(locate.graphNode(page).last())

// Accepting with Enter
nodeCount = await locate.graphNode(page).count()
await page.mouse.click(100, 100) // deselect node
await locate.addNewNodeButton(page).click()
await page.keyboard.press('Enter')
await expect(locate.componentBrowser(page)).not.toBeVisible()
Expand All @@ -97,6 +101,7 @@ test('Accepting suggestion', async ({ page }) => {
'.',
'read',
])
await customExpect.toBeSelected(locate.graphNode(page).last())
})

test('Accepting any written input', async ({ page }) => {
Expand Down
4 changes: 4 additions & 0 deletions app/gui2/e2e/customExpect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export function toExist(locator: Locator) {
// https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible
return expect(locator.first()).toBeVisible()
}

export function toBeSelected(locator: Locator) {
return expect(locator).toHaveClass(/(?<=^| )selected(?=$| )/)
}

0 comments on commit ecf0807

Please sign in to comment.