Skip to content

Commit

Permalink
Merge pull request #705 from liam-hq/add_test_show_mode_on_desktop_to…
Browse files Browse the repository at this point in the history
…olbar

✅ Add E2E tests for Show Mode menu in desktop toolbar
  • Loading branch information
hoshinotsuyoshi authored Feb 10, 2025
2 parents 43cd9fa + 763e675 commit e163b46
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions frontend/packages/e2e/tests/e2e/toolbar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,58 @@ test.describe('Desktop Toolbar', () => {
Number.parseInt(zoomLevelAfter),
)
})

test.describe('Show Mode', () => {
type ShowModeTest = {
mode: string
expectedColumns: string[]
}

const showModeTests: ShowModeTest[] = [
{
mode: 'Table Name',
expectedColumns: [],
},
{
mode: 'Key Only',
expectedColumns: ['idbigserial', 'account_idbigint'],
},
{
mode: 'All Fields',
expectedColumns: [
'idbigserial',
'account_idbigint',
'titlevarchar',
'created_attimestamp',
'updated_attimestamp',
'replies_policyinteger',
'exclusiveboolean',
],
},
]

test.beforeEach(async ({ page }) => {
const showModeButton = page.getByRole('button', {
name: 'Show mode',
})
await showModeButton.click()
})

for (const { mode, expectedColumns } of showModeTests) {
test(`Show Mode: ${mode}`, async ({ page }) => {
const modeButton = page.getByRole('menuitemradio', {
name: mode,
})
await modeButton.click()

const tableNode = page.getByRole('button', {
name: 'lists table',
exact: true,
})

const columns = tableNode.getByRole('listitem')
await expect(columns).toHaveText(expectedColumns)
})
}
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ShowModeMenu: FC = () => {
size="sm"
variant="ghost-secondary"
rightIcon={<ChevronDown />}
aria-label="Show mode"
>
{OPTION_LIST.find((opt) => opt.value === showMode)?.label}
</Button>
Expand Down

0 comments on commit e163b46

Please sign in to comment.