Skip to content

Commit

Permalink
fix the e2es
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Dec 18, 2024
1 parent 9758a93 commit d242c76
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
10 changes: 4 additions & 6 deletions app/pages/system/inventory/SledsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ const staticCols = [
header: 'Provisionable',
cell: (info) => {
const policy: SledPolicy = info.getValue()
if (policy.kind === 'expunged') return <Close12Icon />
return policy.provisionPolicy === 'provisionable' ? (
<Checkmark12Icon className="text-accent" />
) : (
<Close12Icon />
)
const yes = <Checkmark12Icon className="text-accent" aria-label="Yes" />
const no = <Close12Icon aria-label="No" />
if (policy.kind === 'expunged') return no
return policy.provisionPolicy === 'provisionable' ? yes : no
},
}),
],
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/instance-create.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,13 @@ test('attaches a floating IP; disables button when no IPs available', async ({ p
await page.getByRole('tab', { name: 'Networking' }).click()

// ensure External IPs table has rows for the Ephemeral IP and the Floating IP
await expectRowVisible(page.getByRole('table'), {
const ipsTable = page.getByRole('table', { name: 'External IPs' })
await expectRowVisible(ipsTable, {
ip: '123.4.56.0',
Kind: 'ephemeral',
name: '—',
})
await expectRowVisible(page.getByRole('table'), {
await expectRowVisible(ipsTable, {
ip: floatingIp.ip,
Kind: 'floating',
name: floatingIp.name,
Expand Down
14 changes: 10 additions & 4 deletions test/e2e/inventory.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,34 @@ test('Sled inventory page', async ({ page }) => {
await expect(sledsTab).toHaveClass(/is-selected/)

const sledsTable = page.getByRole('table')
// expectRowVisible currently only looks at the last header row in case of
// grouping, hence the slightly weird column names
await expectRowVisible(sledsTable, {
id: sleds[0].id,
'serial number': sleds[0].baseboard.serial,
policy: 'In serviceProvisionable',
Kind: 'In service',
// Provisionable: 'Yes',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[1].id,
'serial number': sleds[1].baseboard.serial,
policy: 'In serviceNot provisionable',
Kind: 'In service',
// Provisionable: 'No',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[2].id,
'serial number': sleds[2].baseboard.serial,
policy: 'Expunged',
Kind: 'Expunged',
// Provisionable: 'No',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[3].id,
'serial number': sleds[3].baseboard.serial,
policy: 'Expunged',
Kind: 'Expunged',
// Provisionable: 'No',
state: 'decommissioned',
})

Expand Down
9 changes: 6 additions & 3 deletions test/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export async function expectRowVisible(
) {
// wait for header and rows to avoid flake town
const headerLoc = table.locator('thead >> role=cell')
await headerLoc.locator('nth=0').waitFor() // nth=0 bc error if there's more than 1
await headerLoc.first().waitFor() // nth=0 bc error if there's more than 1

const rowLoc = table.locator('tbody >> role=row')
await rowLoc.locator('nth=0').waitFor()
await rowLoc.first().waitFor()

async function getRows() {
// need to pull header keys every time because the whole page can change
Expand All @@ -81,7 +81,10 @@ export async function expectRowVisible(
// filter out data-test-ignore is specifically for making the header cells
// match up with the contents on the double-header utilization table
const headerKeys = await table
.locator('thead >> th:not([data-test-ignore])')
.locator('thead')
.getByRole('row')
.last()
.locator('th:not([data-test-ignore])')
.allTextContents()

const rows = await map(table.locator('tbody >> role=row'), async (row) => {
Expand Down

0 comments on commit d242c76

Please sign in to comment.