feat: update timeout error UX (#10274)

This commit is contained in:
Erik Ritter
2020-07-20 15:32:17 -07:00
committed by GitHub
parent d92cb66f60
commit 5fa4680447
29 changed files with 557 additions and 65 deletions

View File

@@ -156,7 +156,7 @@ describe('chart actions', () => {
});
});
it('should CHART_UPDATE_TIMEOUT action upon query timeout', () => {
it('should dispatch CHART_UPDATE_FAILED action upon query timeout', () => {
const unresolvingPromise = new Promise(() => {});
fetchMock.post(MOCK_URL, () => unresolvingPromise, {
overwriteRoutes: true,
@@ -169,7 +169,7 @@ describe('chart actions', () => {
// chart update, trigger query, update form data, fail
expect(fetchMock.calls(MOCK_URL)).toHaveLength(1);
expect(dispatch.callCount).toBe(5);
expect(dispatch.args[4][0].type).toBe(actions.CHART_UPDATE_TIMEOUT);
expect(dispatch.args[4][0].type).toBe(actions.CHART_UPDATE_FAILED);
setupDefaultFetchMock();
});
});

View File

@@ -40,7 +40,21 @@ describe('chart reducers', () => {
it('should update endtime on timeout', () => {
const newState = chartReducer(
charts,
actions.chartUpdateTimeout('timeout', 60, chartKey),
actions.chartUpdateFailed(
{
statusText: 'timeout',
error: 'Request timed out',
errors: [
{
error_type: 'FRONTEND_TIMEOUT_ERROR',
extra: { timeout: 1 },
level: 'error',
message: 'Request timed out',
},
],
},
chartKey,
),
);
expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0);
expect(newState[chartKey].chartStatus).toEqual('failed');