mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: remove flaking test (#3207)
This commit is contained in:
@@ -170,34 +170,6 @@ describe("Users Page", () => {
|
||||
})
|
||||
|
||||
describe("suspend user", () => {
|
||||
describe("when it is success", () => {
|
||||
it("shows a success message and refresh the page", async () => {
|
||||
render(
|
||||
<>
|
||||
<UsersPage />
|
||||
<GlobalSnackbar />
|
||||
</>,
|
||||
)
|
||||
|
||||
await suspendUser(() => {
|
||||
jest.spyOn(API, "suspendUser").mockResolvedValueOnce(MockUser)
|
||||
jest
|
||||
.spyOn(API, "getUsers")
|
||||
.mockImplementationOnce(() => Promise.resolve([MockUser, MockUser2]))
|
||||
})
|
||||
|
||||
// Check if the success message is displayed
|
||||
await screen.findByText(usersXServiceLanguage.suspendUserSuccess)
|
||||
|
||||
// Check if the API was called correctly
|
||||
expect(API.suspendUser).toBeCalledTimes(1)
|
||||
expect(API.suspendUser).toBeCalledWith(MockUser.id)
|
||||
|
||||
// Check if the users list was reload
|
||||
await waitFor(() => expect(API.getUsers).toBeCalledTimes(1))
|
||||
})
|
||||
})
|
||||
|
||||
describe("when it fails", () => {
|
||||
it("shows an error message", async () => {
|
||||
render(
|
||||
|
||||
Reference in New Issue
Block a user