Skip to content

Commit aeb5cae

Browse files
committed
- allowing success dialog to be dismissed on enter keypress
- tests [AD-571]
1 parent 687598c commit aeb5cae

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/modules/Pages/Admin/TestTag/Inspection/components/Inspection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ const Inspection = ({
289289
isOpen={isSaveSuccessOpen}
290290
locale={successDialog}
291291
noMinContentWidth
292+
autoFocusPrimaryButton
292293
/>
293294
<EventPanel
294295
id={componentId}

src/modules/Pages/Admin/TestTag/Inspection/components/Inspection.test.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React from 'react';
22
import Inspection from './Inspection';
3-
import { rtlRender, WithRouter, act, fireEvent, WithReduxStore, waitFor } from 'test-utils';
3+
import { rtlRender, WithRouter, act, fireEvent, WithReduxStore, waitFor, userEvent } from 'test-utils';
44
import Immutable from 'immutable';
5-
import {
6-
mockAllIsIntersecting,
7-
// mockIsIntersecting,
8-
// intersectionMockInstance,
9-
} from 'react-intersection-observer/test-utils';
5+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';
106

117
import configData from '../../../../../../data/mock/data/testing/testAndTag/testTagOnLoadInspection';
128
import userData from '../../../../../../data/mock/data/testing/testAndTag/testTagUser';
@@ -262,6 +258,32 @@ describe('Inspection component', () => {
262258
await waitFor(() => expect(queryByRole('dialog')).not.toBeInTheDocument());
263259
});
264260

261+
it('should dismiss dialog on `enter` keypress', async () => {
262+
const mockFn = jest.fn();
263+
const loadConfigFn = jest.fn();
264+
const clearSaveInspectionFn = jest.fn();
265+
const clearAssetsFn = jest.fn();
266+
267+
const { getByRole, queryByRole } = setup({
268+
actions: {
269+
loadAssetTypes: mockFn,
270+
loadInspectionConfig: loadConfigFn,
271+
clearSaveInspection: clearSaveInspectionFn,
272+
clearAssets: clearAssetsFn,
273+
},
274+
saveInspectionSuccess: {
275+
asset_status: 'CURRENT',
276+
asset_id_displayed: 'UQL000705',
277+
user_licence_number: 'NOT LICENCED',
278+
action_date: '2022-12-12',
279+
asset_next_test_due_date: '2023Dec12',
280+
},
281+
});
282+
await waitFor(() => expect(getByRole('dialog')).toBeInTheDocument());
283+
await userEvent.keyboard('{Enter}');
284+
await waitFor(() => expect(queryByRole('dialog')).not.toBeInTheDocument());
285+
});
286+
265287
it('should show a save success for FAILED asset dialog panel', async () => {
266288
const mockFn = jest.fn();
267289
const loadConfigFn = jest.fn();

0 commit comments

Comments
 (0)