test: write tests for user management (#1316)

* chore: add data-test attributes

* test: add github connection test, add applications modal

* test: write tests for user management
This commit is contained in:
QAComet
2023-10-26 07:12:37 -06:00
committed by GitHub
parent 86611453b5
commit 463e6908b1
17 changed files with 896 additions and 101 deletions

View File

@@ -52,6 +52,7 @@ export default function TablePaginationActions(
onClick={handleFirstPageButtonClick}
disabled={page === 0}
aria-label="first page"
data-test="first-page-button"
>
{theme.direction === 'rtl' ? <LastPageIcon /> : <FirstPageIcon />}
</IconButton>
@@ -59,6 +60,7 @@ export default function TablePaginationActions(
onClick={handleBackButtonClick}
disabled={page === 0}
aria-label="previous page"
data-test="previous-page-button"
>
{theme.direction === 'rtl' ? (
<KeyboardArrowRight />
@@ -70,6 +72,7 @@ export default function TablePaginationActions(
onClick={handleNextButtonClick}
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
aria-label="next page"
data-test="next-page-button"
>
{theme.direction === 'rtl' ? (
<KeyboardArrowLeft />
@@ -81,6 +84,7 @@ export default function TablePaginationActions(
onClick={handleLastPageButtonClick}
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
aria-label="last page"
data-test="last-page-button"
>
{theme.direction === 'rtl' ? <FirstPageIcon /> : <LastPageIcon />}
</IconButton>

View File

@@ -83,23 +83,34 @@ export default function UserList(): React.ReactElement {
</TableRow>
</TableHead>
<TableBody>
{loading && <ListLoader rowsNumber={3} columnsNumber={2} />}
{loading && <ListLoader
data-test="users-list-loader"
rowsNumber={3}
columnsNumber={2} />}
{!loading &&
users.map((user) => (
<TableRow
key={user.id}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
data-test="user-row"
>
<TableCell scope="row">
<Typography variant="subtitle2">{user.fullName}</Typography>
<Typography
variant="subtitle2"
data-test="user-full-name">{user.fullName}</Typography>
</TableCell>
<TableCell>
<Typography variant="subtitle2">{user.email}</Typography>
<Typography
variant="subtitle2"
data-test="user-email">{user.email}</Typography>
</TableCell>
<TableCell>
<Typography variant="subtitle2">
<Typography
variant="subtitle2"
data-test="user-role"
>
{user.role.name}
</Typography>
</TableCell>
@@ -110,11 +121,14 @@ export default function UserList(): React.ReactElement {
size="small"
component={Link}
to={URLS.USER(user.id)}
data-test="user-edit"
>
<EditIcon />
</IconButton>
<DeleteUserButton userId={user.id} />
<DeleteUserButton
data-test="user-delete"
userId={user.id} />
</Stack>
</TableCell>
</TableRow>
@@ -124,6 +138,8 @@ export default function UserList(): React.ReactElement {
<TableFooter>
<TableRow>
<TablePagination
data-total-count={totalCount}
data-rows-per-page={rowsPerPage}
rowsPerPageOptions={[10, 25, 50, 100]}
page={page}
count={totalCount}