-
-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move 2 table tests from cypress to rtl (#6984)
- Loading branch information
Showing
3 changed files
with
60 additions
and
95 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
60 changes: 60 additions & 0 deletions
60
...c/component/project/Project/PaginatedProjectFeatureToggles/ProjectFeatureToggles.test.tsx
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,60 @@ | ||
import { render } from 'utils/testRenderer'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { ProjectFeatureToggles } from './ProjectFeatureToggles'; | ||
import { testServerRoute, testServerSetup } from 'utils/testServer'; | ||
import { screen } from '@testing-library/react'; | ||
import { BATCH_SELECTED_COUNT } from 'utils/testIds'; | ||
|
||
const server = testServerSetup(); | ||
|
||
const setupApi = () => { | ||
const features = [{ name: 'featureA' }, { name: 'featureB' }]; | ||
testServerRoute(server, '/api/admin/search/features', { | ||
features, | ||
total: features.length, | ||
}); | ||
testServerRoute(server, '/api/admin/ui-config', {}); | ||
}; | ||
|
||
test('selects project features', async () => { | ||
setupApi(); | ||
render( | ||
<Routes> | ||
<Route | ||
path={'/projects/:projectId'} | ||
element={ | ||
<ProjectFeatureToggles | ||
environments={['development', 'production']} | ||
/> | ||
} | ||
/> | ||
</Routes>, | ||
{ | ||
route: '/projects/default', | ||
}, | ||
); | ||
await screen.findByText('featureA'); | ||
await screen.findByText('featureB'); | ||
await screen.findByText('Feature toggles (2)'); | ||
|
||
const [selectAll, selectFeatureA, selectFeatureB] = | ||
screen.queryAllByRole('checkbox'); | ||
|
||
// batch select | ||
selectAll.click(); | ||
let selectedCount = screen.getByTestId(BATCH_SELECTED_COUNT); | ||
expect(selectedCount.textContent).toBe('2'); | ||
|
||
// batch deselect | ||
selectAll.click(); | ||
expect(screen.queryByTestId(BATCH_SELECTED_COUNT)).not.toBeInTheDocument(); | ||
|
||
// select a single item | ||
selectFeatureA.click(); | ||
selectedCount = screen.getByTestId(BATCH_SELECTED_COUNT); | ||
expect(selectedCount.textContent).toBe('1'); | ||
|
||
// deselect a single item | ||
selectFeatureA.click(); | ||
expect(screen.queryByTestId(BATCH_SELECTED_COUNT)).not.toBeInTheDocument(); | ||
}); |
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