Skip to content

Commit

Permalink
feat: [PROD-10520] Add DataIngestionInProgress state
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Ardouin-Murat committed Jan 18, 2023
1 parent 5a66d4d commit 24b3b50
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/charts/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const Dashboard = (props) => {
// Handle optional status property
const noRun = scenarioState === 'Created' || scenarioState === null;
const runInProgress = scenarioState === 'Running';
const dataInTransfer = scenarioState === 'DataIngestionInProgress';
const hasError = scenarioState === 'Failed';
const isReady = (scenarioState === undefined || scenarioState === 'Successful') && !noScenario;

Expand All @@ -52,6 +53,13 @@ export const Dashboard = (props) => {
icon={<AccessTimeIcon color="primary" fontSize="large" />}
/>
)}
{dataInTransfer && (
<DashboardPlaceholder
label={labels.dataInTransfer.label}
title={labels.dataInTransfer.title}
icon={<AccessTimeIcon color="primary" fontSize="large" />}
/>
)}
{hasError && (
<DashboardPlaceholder
label={labels.hasErrors.label}
Expand Down Expand Up @@ -151,6 +159,10 @@ Dashboard.propTypes = {
title: PropTypes.string,
label: PropTypes.string.isRequired,
}).isRequired,
dataInTransfer: PropTypes.shape({
title: PropTypes.string,
label: PropTypes.string.isRequired,
}).isRequired,
hasErrors: PropTypes.shape({
title: PropTypes.string,
label: PropTypes.string.isRequired,
Expand Down Expand Up @@ -178,6 +190,10 @@ Dashboard.defaultProps = {
title: '',
label: 'Scenario run in progress...',
},
dataInTransfer: {
title: '',
label: 'Scenario results transfer in progress...',
},
hasErrors: {
title: '',
label: 'An error occured during the scenario run',
Expand Down
17 changes: 17 additions & 0 deletions src/charts/SimplePowerBIReportEmbed/SimplePowerBIReportEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const SimplePowerBIReportEmbed = ({
const scenarioState = noScenario ? 'Created' : scenarioDTO.state;
const noRun = scenarioState === 'Created' || scenarioState === null;
const runInProgress = scenarioState === 'Running';
const dataInTransfer = scenarioState === 'DataIngestionInProgress';
const hasError = scenarioState === 'Failed';
const hasUnknownStatus = scenarioState === 'Unknown';
const noDashboardConfigured = reportConfiguration[index] === undefined;
Expand All @@ -145,6 +146,15 @@ export const SimplePowerBIReportEmbed = ({
icon={<AccessTimeIcon color="primary" fontSize="large" />}
/>
);
if (dataInTransfer) {
return (
<DashboardPlaceholder
label={labels.dataInTransfer.label}
title={labels.dataInTransfer.title}
icon={<AccessTimeIcon color="primary" fontSize="large" />}
/>
);
}
if (hasError)
return (
<DashboardPlaceholder
Expand Down Expand Up @@ -360,6 +370,10 @@ SimplePowerBIReportEmbed.propTypes = {
title: PropTypes.string,
label: PropTypes.string.isRequired,
}).isRequired,
dataInTransfer: PropTypes.shape({
title: PropTypes.string,
label: PropTypes.string.isRequired,
}).isRequired,
hasErrors: PropTypes.shape({
title: PropTypes.string,
label: PropTypes.string.isRequired,
Expand Down Expand Up @@ -397,6 +411,9 @@ SimplePowerBIReportEmbed.defaultProps = {
inProgress: {
label: 'Scenario run in progress...',
},
dataInTransfer: {
label: 'Scenario results transfer in progress...',
},
hasErrors: {
label: 'An error occured during the scenario run',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import { render } from '@testing-library/react';

import { TypographyTesting } from '../../../tests/MuiComponentsTesting';

import { SimplePowerBIReportEmbed } from '.';
import { LABELS, DEFAULT_SCENARIO, SCENARIO_STATES } from '../../../tests/samples/DashboardSample';

const defaultProps = {
index: 0,
refreshTimeout: 15000,
alwaysShowReports: false,
useAAD: false,
lang: 'en',
reports: {},
reportConfiguration: [],
refreshable: true,
scenario: { ...DEFAULT_SCENARIO },
labels: LABELS,
};

const TypographyPlaceholderLabel = new TypographyTesting({ dataCy: 'dashboard-placeholder' });

const setUp = (props) => {
render(<SimplePowerBIReportEmbed {...props} />);
};

describe('SimplePowerBiReportEmbed', () => {
describe('PlaceHolder', () => {
const setUpWithScenarioState = (scenarioState) => {
const props = {
...defaultProps,
scenario: {
...defaultProps.scenario,
state: scenarioState,
},
};

setUp(props);
};

test.each([
{ scenarioState: SCENARIO_STATES.noRun, placeHolderLabel: LABELS.noRun.label },
{ scenarioState: SCENARIO_STATES.dataInTransfer, placeHolderLabel: LABELS.dataInTransfer.label },
{ scenarioState: SCENARIO_STATES.hasError, placeHolderLabel: LABELS.hasErrors.label },
{ scenarioState: SCENARIO_STATES.runInProgress, placeHolderLabel: LABELS.inProgress.label },
{ scenarioState: SCENARIO_STATES.unknown, placeHolderLabel: LABELS.hasUnknownStatus.label },
])(
'$scenarioState Scenario state display placeholder with label $placeHolderLabel',
({ scenarioState, placeHolderLabel }) => {
setUpWithScenarioState(scenarioState);
expect(TypographyPlaceholderLabel.text).toEqual(placeHolderLabel);
}
);
});
});
52 changes: 52 additions & 0 deletions tests/samples/DashboardSample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Cosmo Tech.
// Licensed under the MIT license.

export const LABELS = {
noScenario: {
title: 'ut_noScenario_title',
label: 'ut_noScenario_label',
},
noDashboard: {
label: 'ut_noDashboard_label',
},
noRun: {
label: 'ut_noRun_label',
},
inProgress: {
label: 'ut_inProgress_label',
},
dataInTransfer: {
label: 'ut_dataInTransfer_label',
},
hasErrors: {
label: 'ut_hasErrors_label',
},
hasUnknownStatus: {
label: 'ut_hasUnknownStatus_label',
},
downloadButton: 'ut_downloadButton_label',
refreshTooltip: 'ut_refreshTooltip_label',
errors: {
unknown: 'ut_unknownErrors_label',
details: 'ut_errorsDetails_label',
},
};

export const SCENARIO_STATES = {
noRun: 'Created',
runInProgress: 'Running',
dataInTransfer: 'DataIngestionInProgress',
hasError: 'Failed',
success: 'Successful',
unknown: 'Unknown',
};

export const DEFAULT_SCENARIO = {
id: 'ut_sc_id',
name: 'ut_sc_name',
state: SCENARIO_STATES.noRun,
rootId: 'ut_sc_rootId',
parentId: 'ut_sc_parentId',
ownerId: 'ut_sc_ownerId',
solutionId: 'ut_sc_solutionId',
};

0 comments on commit 24b3b50

Please sign in to comment.