-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 12520-table-batch-actions-type
- Loading branch information
Showing
41 changed files
with
822 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,371 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2023 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { expect, test } = require('@playwright/test'); | ||
const { visitStory } = require('../../test-utils/storybook'); | ||
|
||
test.describe('DataTable @avt', () => { | ||
test.describe('basic', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-basic--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-basic--default' | ||
); | ||
}); | ||
test('xl with two lines has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-basic--xl-with-two-lines', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-basic--xl-with-two-lines' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('batch actions', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-batch-actions--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-batch-actions--default' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('dynamic', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-dynamic--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-dynamic--default' | ||
); | ||
}); | ||
|
||
test('default keyboard navigation sequence', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-dynamic--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
|
||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-dynamic--default' | ||
); | ||
|
||
// Start off by manually focusing the search input | ||
await page.getByRole('searchbox').focus(); | ||
await expect(page.getByRole('searchbox')).toBeFocused(); | ||
|
||
// Navigate to the gear/settings button | ||
await page.keyboard.press('Tab'); | ||
await expect( | ||
page.getByRole('button', { name: 'Settings' }) | ||
).toBeFocused(); | ||
|
||
// Navigate to the select all checkbox | ||
await page.keyboard.press('Tab'); | ||
await expect( | ||
page.getByRole('checkbox', { name: 'Select all rows' }) | ||
).toBeFocused(); | ||
|
||
// Pressing enter on the select all checkbox shouldn't do anything | ||
await page.keyboard.press('Enter'); | ||
await expect( | ||
page.getByRole('checkbox', { name: 'Select all rows' }) | ||
).not.toBeChecked(); | ||
|
||
// Pressing space should check the select all checkbox | ||
await page.keyboard.press('Space'); | ||
await expect( | ||
page.getByRole('checkbox', { name: 'Select all rows' }) | ||
).toBeChecked(); | ||
|
||
// Every checkbox should be checked | ||
for (const checkbox of await page.getByRole('checkbox').all()) { | ||
await expect(checkbox).toBeChecked(); | ||
} | ||
|
||
// Pressing space should uncheck the select all checkbox | ||
await page.keyboard.press('Space'); | ||
await expect( | ||
page.getByRole('checkbox', { name: 'Select all rows' }) | ||
).not.toBeChecked(); | ||
// Every checkbox should no longer be checked | ||
for (const checkbox of await page.getByRole('checkbox').all()) { | ||
await expect(checkbox).not.toBeChecked(); | ||
} | ||
|
||
// Navigate to the first expansion button | ||
await page.keyboard.press('Tab'); | ||
await expect( | ||
page.getByRole('button', { name: 'Expand current row' }).first() | ||
).toBeFocused(); | ||
// Expand the first row | ||
await page.keyboard.press('Space'); | ||
await expect( | ||
page.getByRole('heading', { name: 'Expandable row content' }).first() | ||
).toBeVisible(); | ||
|
||
// Navigate to the first row selection checkbox and check it | ||
await page.keyboard.press('Tab'); | ||
await page.keyboard.press('Space'); | ||
await expect(page.getByText('1 item selected')).toBeVisible(); | ||
|
||
// Navigate backwards up into the batch action bar | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
|
||
await page | ||
.getByRole('heading', { name: 'Expandable row content' }) | ||
.first() | ||
.hover(); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-dynamic--default---with-batch-actions-open-and-row-expanded' | ||
); | ||
await expect(page.getByRole('button', { name: 'Delete' })).toBeFocused(); | ||
|
||
// Navigate forwards through the batch action buttons | ||
await page.keyboard.press('Tab'); | ||
await expect(page.getByRole('button', { name: 'Save' })).toBeFocused(); | ||
await page.keyboard.press('Tab'); | ||
await expect( | ||
page.getByRole('button', { name: 'Download' }) | ||
).toBeFocused(); | ||
await page.keyboard.press('Tab'); | ||
await expect(page.getByRole('button', { name: 'Cancel' })).toBeFocused(); | ||
// Invoke the cancel button | ||
await page.keyboard.press('Space'); | ||
await expect(page.getByText('1 item selected')).not.toBeVisible(); | ||
// Every checkbox should no longer be checked | ||
for (const checkbox of await page.getByRole('checkbox').all()) { | ||
await expect(checkbox).not.toBeChecked(); | ||
} | ||
}); | ||
}); | ||
|
||
test.describe('expansion', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-expansion--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-expansion--default' | ||
); | ||
}); | ||
test('batch expansion has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-expansion--batch-expansion', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-expansion--batch-expansion' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('filtering', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-filtering--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-filtering--default' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('selection', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-selection--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-selection--default' | ||
); | ||
}); | ||
test('with-radio-expansion has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-selection--with-radio-expansion', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-selection--with-radio-expansion' | ||
); | ||
}); | ||
test('with-selection-and-sorting has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-selection--with-selection-and-sorting', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-selection--with-selection-and-sorting' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('skeleton', () => { | ||
test('skeleton has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-skeleton--skeleton', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-skeleton--skeleton' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('sorting', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-sorting--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-sorting--default' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('toolbar', () => { | ||
test('default has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-toolbar--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-toolbar--default' | ||
); | ||
}); | ||
test('persistent-toolbar has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-toolbar--persistent-toolbar', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-toolbar--persistent-toolbar' | ||
); | ||
}); | ||
test('small-persistent-toolbar has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-toolbar--small-persistent-toolbar', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-toolbar--small-persistent-toolbar' | ||
); | ||
}); | ||
test('with-overflow-menu has no accessibility-checker violations', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'DataTable', | ||
id: 'components-datatable-toolbar--with-overflow-menu', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations( | ||
'components-datatable-toolbar--with-overflow-menu' | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.