-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display connection rejection errors passed to client (#6101)
Co-authored-by: sp.wack <[email protected]>
- Loading branch information
Showing
5 changed files
with
64 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import * as ChatSlice from "#/state/chat-slice"; | ||
import { | ||
updateStatusWhenErrorMessagePresent, | ||
} from "#/context/ws-client-provider"; | ||
|
||
describe("Propagate error message", () => { | ||
it("should do nothing when no message was passed from server", () => { | ||
const addErrorMessageSpy = vi.spyOn(ChatSlice, "addErrorMessage"); | ||
updateStatusWhenErrorMessagePresent(null) | ||
updateStatusWhenErrorMessagePresent(undefined) | ||
updateStatusWhenErrorMessagePresent({}) | ||
updateStatusWhenErrorMessagePresent({message: null}) | ||
|
||
expect(addErrorMessageSpy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should display error to user when present", () => { | ||
const message = "We have a problem!" | ||
const addErrorMessageSpy = vi.spyOn(ChatSlice, "addErrorMessage") | ||
updateStatusWhenErrorMessagePresent({message}) | ||
|
||
expect(addErrorMessageSpy).toHaveBeenCalledWith({ | ||
message, | ||
status_update: true, | ||
type: 'error' | ||
}); | ||
}); | ||
}); |
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
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
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
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