Skip to content

Commit b62b38e

Browse files
regexowlkingsleyzissou
authored andcommitted
vitest: Replace .blur with tabWithWait
This replaces the original `.blur` method with `tabWithWait` to make the user interaction clearer and remove the `waitFor`.
1 parent 0eb460e commit b62b38e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/Components/CreateImageWizard/steps/ImageOutput/components/Aws/tests/AwsTarget.test.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { mapRequestFromState } from '@/Components/CreateImageWizard/utilities/re
55
import { serviceMiddleware, serviceReducer } from '@/store';
66
import { CreateBlueprintRequest, ImageRequest } from '@/store/api/backend';
77
import { initialState } from '@/store/slices/wizard';
8-
import { clickWithWait, createUser, typeWithWait } from '@/test/testUtils';
8+
import {
9+
clickWithWait,
10+
createUser,
11+
tabWithWait,
12+
typeWithWait,
13+
} from '@/test/testUtils';
914

1015
import {
1116
checkAccountIdValue,
@@ -82,7 +87,7 @@ describe('AWS Component', () => {
8287
name: /aws account id/i,
8388
});
8489
await typeWithWait(user, accountIdInput, '12345');
85-
await waitFor(() => accountIdInput.blur());
90+
await tabWithWait(user);
8691

8792
await waitFor(() => {
8893
expect(
@@ -99,7 +104,7 @@ describe('AWS Component', () => {
99104
name: /aws account id/i,
100105
});
101106
await typeWithWait(user, accountIdInput, 'abc123456789');
102-
await waitFor(() => accountIdInput.blur());
107+
await tabWithWait(user);
103108

104109
await waitFor(() => {
105110
expect(
@@ -110,12 +115,13 @@ describe('AWS Component', () => {
110115

111116
test('displays error when field is focused then blurred without input', async () => {
112117
renderAwsStep();
118+
const user = createUser();
113119

114120
const accountIdInput = await screen.findByRole('textbox', {
115121
name: /aws account id/i,
116122
});
117123
accountIdInput.focus();
118-
await waitFor(() => accountIdInput.blur());
124+
await tabWithWait(user);
119125

120126
await waitFor(() => {
121127
expect(
@@ -138,11 +144,7 @@ describe('AWS Component', () => {
138144
name: /clear/i,
139145
});
140146
await clickWithWait(user, clearButton);
141-
142-
const accountIdInput = await screen.findByRole('textbox', {
143-
name: /aws account id/i,
144-
});
145-
await waitFor(() => accountIdInput.blur());
147+
await tabWithWait(user);
146148

147149
await waitFor(() => {
148150
expect(

0 commit comments

Comments
 (0)