1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-16 13:46:16 +02:00

Display actual error within the form.

This commit is contained in:
Maciej Lenartowicz
2020-01-20 16:54:42 +01:00
parent a0a775996e
commit ee33d33738
30 changed files with 165 additions and 156 deletions

View File

@ -27,7 +27,6 @@ export default function ResetWiFiSettings({ ws, endpoint }) {
const module = "wifi";
ws.subscribe(module)
.bind(module, "reset", () => {
setIsLoading(true);
// eslint-disable-next-line no-restricted-globals
setTimeout(() => location.reload(), 1000);
});
@ -45,6 +44,7 @@ export default function ResetWiFiSettings({ ws, endpoint }) {
function onReset() {
dismissAlert();
setIsLoading(true);
postReset();
}

View File

@ -39,9 +39,10 @@ describe("<WiFiSettings/>", () => {
it("should handle error", async () => {
const webSockets = new WebSockets();
const { getByText } = render(<WiFiSettings ws={webSockets} ws={webSockets} endpoint={endpoint} resetEndpoint="foo" />);
mockJSONError();
const errorMessage = "An API error occurred.";
mockJSONError(errorMessage);
await wait(() => {
expect(getByText("An error occurred while fetching data.")).toBeTruthy();
expect(getByText(errorMessage)).toBeTruthy();
});
});