Fix bug with umwarranted error messages

This commit is contained in:
Nathan Barber
2021-12-13 20:36:00 -05:00
parent 3893fb6d2c
commit 4704217dc5
4 changed files with 34 additions and 30 deletions

View File

@@ -110,13 +110,21 @@ const GroupEdit = (props) => {
Promise.all(promiseQueue)
.then((data) => {
data.status < 300
// ensure status of all requests are < 300
let allPassed =
data.map((e) => e.status).filter((e) => e >= 300).length ==
0;
allPassed
? updateGroups(0, limit)
.then((data) => dispatchPageUpdate(data, 0))
.then(() => history.push("/groups"))
: setErrorAlert(`Failed to edit group.`);
})
.catch(() => setErrorAlert(`Failed to edit group.`));
.catch(() => {
console.log("outer");
setErrorAlert(`Failed to edit group.`);
});
}}
>
Apply

View File

@@ -242,17 +242,17 @@ const ServerDashboard = (props) => {
onClick={() =>
stopServer(e.name)
.then((res) => {
data < 300
? updateUsers(...slice)
if (res.status < 300) {
updateUsers(...slice)
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch(() =>
setErrorAlert(
`Failed to update users list.`
)
)
: setErrorAlert(`Failed to stop server`);
setErrorAlert(`Failed to update users list.`)
);
} else {
setErrorAlert(`Failed to stop server.`);
}
return res;
})
.catch(() => setErrorAlert(`Failed to stop server.`))
@@ -267,17 +267,17 @@ const ServerDashboard = (props) => {
onClick={() =>
startServer(e.name)
.then((res) => {
data < 300
? updateUsers(...slice)
if (res.status < 300) {
updateUsers(...slice)
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch(() =>
setErrorAlert(
`Failed to update users list.`
)
)
: setErrorAlert(`Failed to start server`);
setErrorAlert(`Failed to update users list.`)
);
} else {
setErrorAlert(`Failed to start server.`);
}
return res;
})
.catch(() => {

View File

@@ -33,11 +33,7 @@ var serverDashboardJsx = (spy) => (
);
var mockAsync = (data) =>
jest
.fn()
.mockImplementation(() =>
Promise.resolve({ json: () => Promise.resolve(data ? data : { k: "v" }) })
);
jest.fn().mockImplementation(() => Promise.resolve(data ? data : { k: "v" }));
var mockAsyncRejection = () =>
jest.fn().mockImplementation(() => Promise.reject());

File diff suppressed because one or more lines are too long