export default class App extends React.PureComponent<Props, State> {
mounted: boolean;
+ timer?: NodeJS.Timer;
static contextTypes = {
router: PropTypes.object.isRequired
editionStatus => {
if (this.mounted) {
this.updateEditionStatus(editionStatus);
- setTimeout(this.fetchEditionStatus, 5000);
}
},
() => {}
);
};
- updateEditionStatus = (editionStatus: EditionStatus) =>
+ updateEditionStatus = (editionStatus: EditionStatus) => {
this.setState({ editionStatus: editionStatus });
+ if (this.timer) {
+ global.clearTimeout(this.timer);
+ this.timer = undefined;
+ }
+ if (editionStatus.installationStatus === 'AUTOMATIC_IN_PROGRESS') {
+ this.timer = global.setTimeout(() => {
+ this.fetchEditionStatus();
+ this.timer = undefined;
+ }, 2000);
+ }
+ };
updateQuery = (newQuery: Partial<Query>) => {
const query = serializeQuery({ ...parseQuery(this.props.location.query), ...newQuery });
expect(wrapper).toMatchSnapshot();
});
-it('should display an error notification', () => {
- const wrapper = shallow(
- <EditionsStatusNotif
- editionStatus={{ installationStatus: 'AUTOMATIC_FAILURE' }}
- updateEditionStatus={jest.fn()}
- />
- );
- expect(wrapper).toMatchSnapshot();
-});
-
it('should display a ready notification', () => {
const wrapper = shallow(
<EditionsStatusNotif