Skip to content

Commit a945667

Browse files
author
me
committed
Add test to ensure a TR element with no TD child element exists.
1 parent 06280aa commit a945667

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/sortable-test-base.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,27 @@ export const createSortableTests = () => {
383383
expect(firstCell).toBe('J')
384384
})
385385

386+
defineTest('ensures allTables[8] has a TR with no TD', async ({ page }) => {
387+
const allTables = await page.$$('table.sortable')
388+
const table = allTables[8]
389+
const nameHeader = await table.$('th[aria-label*="Letters"]')
390+
391+
// Sort empty TR to the bottom of table.
392+
await nameHeader?.click()
393+
await waitForSort(page)
394+
395+
// Sort empty TR to top of table.
396+
await nameHeader?.click()
397+
await waitForSort(page)
398+
399+
try {
400+
firstCell = await table.$eval('tbody tr:first-child td:nth-child(1)', (el) => el.textContent)
401+
test.fail("Expected 'td:nth-child(1)' to not exist, but it does exist")
402+
} catch (err) {
403+
expect(err.message).toEqual('elementHandle.$eval: Failed to find element matching selector "tbody tr:first-child td:nth-child(1)"')
404+
}
405+
})
406+
386407
defineTest('sorts a table with missing TD elements', async ({ page }) => {
387408
const allTables = await page.$$('table.sortable')
388409
const table = allTables[8]

0 commit comments

Comments
 (0)