Skip to content

Commit 435b2de

Browse files
committed
Remove manual timeouts [ci]
Signed-off-by: fayi-da <fayimora.femibalogun@digitalasset.com>
1 parent 52d9d50 commit 435b2de

File tree

5 files changed

+319
-375
lines changed

5 files changed

+319
-375
lines changed

apps/common/frontend-test-vite-utils/src/vitest.common.conf.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ export const vitest_common_conf = {
33
disableConsoleIntercept: true,
44
environment: 'happy-dom',
55
exclude: ['../lib/**'],
6-
include: ['**/*.{test,spec}-d.?(c|m)[jt]s?(x)', '**/*.{test,spec}.?(c|m)[jt]s?(x)'],
76
silent: false,
87
testTimeout: 15000,
9-
typecheck: {},
8+
typecheck: {
9+
include: ['**/*.{test,spec}-d.?(c|m)[jt]s?(x)', '**/*.{test,spec}.?(c|m)[jt]s?(x)'],
10+
},
1011
},
1112
};

apps/sv/frontend/src/__tests__/governance/forms/pending-fields.test.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,11 @@ describe('Pending Fields', () => {
9696
</Wrapper>
9797
);
9898

99-
await waitFor(
100-
() => {
101-
expect(
102-
screen.queryByText('Some fields are disabled for editing due to pending votes.')
103-
).not.toBeNull();
104-
},
105-
{ timeout: 5000 }
106-
);
99+
await waitFor(() => {
100+
expect(
101+
screen.queryByText('Some fields are disabled for editing due to pending votes.')
102+
).not.toBeNull();
103+
});
107104

108105
const pendingLabels = screen.queryAllByTestId(/^config-pending-value-/);
109106
expect(pendingLabels.length).toBe(2);
@@ -144,14 +141,11 @@ describe('Pending Fields', () => {
144141
</Wrapper>
145142
);
146143

147-
await waitFor(
148-
() => {
149-
expect(
150-
screen.queryByText('Some fields are disabled for editing due to pending votes.')
151-
).not.toBeNull();
152-
},
153-
{ timeout: 5000 }
154-
);
144+
await waitFor(() => {
145+
expect(
146+
screen.queryByText('Some fields are disabled for editing due to pending votes.')
147+
).not.toBeNull();
148+
});
155149

156150
const pendingLabels = screen.queryAllByTestId(/^config-pending-value-/);
157151
expect(pendingLabels.length).toBe(7);

apps/sv/frontend/src/__tests__/governance/forms/set-amulet-rules-form.test.tsx

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('SV user can', () => {
3636
});
3737
});
3838

39-
describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
39+
describe('Set Amulet Config Rules Form', () => {
4040
test('should render all Set Amulet Config Rules Form components', () => {
4141
render(
4242
<Wrapper>
@@ -64,62 +64,55 @@ describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
6464
expect(urlInput.getAttribute('value')).toBe('');
6565

6666
// Amulet Rules has a lot of fields to process so this can get flakey if not given enough time
67-
waitFor(
68-
() => {
69-
const configLabels = screen.getAllByTestId('config-label', { exact: false });
70-
expect(configLabels.length).toBeGreaterThan(65);
71-
72-
const configFields = screen.getAllByTestId('config-field', { exact: false });
73-
expect(configFields.length).toBeGreaterThan(65);
74-
75-
// no changes have been made so we should not see any current values
76-
expect(() => screen.getAllByTestId('config-current-value', { exact: false })).toThrowError(
77-
/Unable to find an element/
78-
);
79-
},
80-
{ timeout: 1000 }
81-
);
82-
});
67+
waitFor(() => {
68+
const configLabels = screen.getAllByTestId('config-label', { exact: false });
69+
expect(configLabels.length).toBeGreaterThan(65);
8370

84-
test(
85-
'should render errors when submit button is clicked on new form',
86-
async () => {
87-
const user = userEvent.setup();
71+
const configFields = screen.getAllByTestId('config-field', { exact: false });
72+
expect(configFields.length).toBeGreaterThan(65);
8873

89-
render(
90-
<Wrapper>
91-
<SetAmuletConfigRulesForm />
92-
</Wrapper>
74+
// no changes have been made so we should not see any current values
75+
expect(() => screen.getAllByTestId('config-current-value', { exact: false })).toThrowError(
76+
/Unable to find an element/
9377
);
78+
});
79+
});
9480

95-
const actionInput = screen.getByTestId('set-amulet-config-rules-action');
96-
const submitButton = screen.getByTestId('submit-button');
97-
expect(submitButton).toBeDefined();
81+
test('should render errors when submit button is clicked on new form', async () => {
82+
const user = userEvent.setup();
9883

99-
await user.click(submitButton);
100-
expect(submitButton.getAttribute('disabled')).toBeDefined();
101-
await expect(async () => await user.click(submitButton)).rejects.toThrowError(
102-
/Unable to perform pointer interaction/
103-
);
84+
render(
85+
<Wrapper>
86+
<SetAmuletConfigRulesForm />
87+
</Wrapper>
88+
);
89+
90+
const actionInput = screen.getByTestId('set-amulet-config-rules-action');
91+
const submitButton = screen.getByTestId('submit-button');
92+
expect(submitButton).toBeDefined();
10493

105-
expect(screen.getByText('Summary is required')).toBeDefined();
106-
expect(screen.getByText('Invalid URL')).toBeDefined();
94+
await user.click(submitButton);
95+
expect(submitButton.getAttribute('disabled')).toBeDefined();
96+
await expect(async () => await user.click(submitButton)).rejects.toThrowError(
97+
/Unable to perform pointer interaction/
98+
);
10799

108-
// completing the form should reenable the submit button
109-
const summaryInput = screen.getByTestId('set-amulet-config-rules-summary');
110-
expect(summaryInput).toBeDefined();
111-
await user.type(summaryInput, 'Summary of the proposal');
100+
expect(screen.getByText('Summary is required')).toBeDefined();
101+
expect(screen.getByText('Invalid URL')).toBeDefined();
112102

113-
const urlInput = screen.getByTestId('set-amulet-config-rules-url');
114-
expect(urlInput).toBeDefined();
115-
await user.type(urlInput, 'https://example.com');
103+
// completing the form should reenable the submit button
104+
const summaryInput = screen.getByTestId('set-amulet-config-rules-summary');
105+
expect(summaryInput).toBeDefined();
106+
await user.type(summaryInput, 'Summary of the proposal');
116107

117-
await user.click(actionInput); // using this to trigger the onBlur event which triggers the validation
108+
const urlInput = screen.getByTestId('set-amulet-config-rules-url');
109+
expect(urlInput).toBeDefined();
110+
await user.type(urlInput, 'https://example.com');
118111

119-
expect(submitButton.getAttribute('disabled')).toBeNull();
120-
},
121-
{ timeout: 10000 }
122-
);
112+
await user.click(actionInput); // using this to trigger the onBlur event which triggers the validation
113+
114+
expect(submitButton.getAttribute('disabled')).toBeNull();
115+
});
123116

124117
test('expiry date must be in the future', async () => {
125118
const user = userEvent.setup();
@@ -240,7 +233,7 @@ describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
240233
expect(screen.getByText(PROPOSAL_SUMMARY_TITLE)).toBeDefined();
241234
});
242235

243-
test('should show error on form if submission fails', { timeout: 10000 }, async () => {
236+
test('should show error on form if submission fails', async () => {
244237
server.use(
245238
rest.post(`${svUrl}/v0/admin/sv/voterequest/create`, (_, res, ctx) => {
246239
return res(ctx.status(503), ctx.json({ error: 'Service Unavailable' }));

apps/sv/frontend/src/__tests__/sv.test.tsx

Lines changed: 87 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Expiration
122122
expect(await screen.findByText('Vote Requests')).toBeDefined();
123123
});
124124

125-
test('see proper time format in popup', { timeout: 10000 }, async () => {
125+
test('see proper time format in popup', async () => {
126126
const user = userEvent.setup();
127127
render(<AppWithConfig />);
128128

@@ -190,131 +190,119 @@ describe('An SetConfig request', () => {
190190
).toBe(true);
191191
});
192192

193-
test(
194-
'displays a warning when an SV tries to modify a DsoRules field already changed by another request',
195-
{ timeout: 10000 },
196-
async () => {
197-
const user = userEvent.setup();
198-
render(<AppWithConfig />);
193+
test('displays a warning when an SV tries to modify a DsoRules field already changed by another request', async () => {
194+
const user = userEvent.setup();
195+
render(<AppWithConfig />);
199196

200-
expect(await screen.findByText('Governance')).toBeDefined();
201-
await user.click(screen.getByText('Governance'));
197+
expect(await screen.findByText('Governance')).toBeDefined();
198+
await user.click(screen.getByText('Governance'));
202199

203-
expect(await screen.findByText('Vote Requests')).toBeDefined();
204-
expect(await screen.findByText('Governance')).toBeDefined();
200+
expect(await screen.findByText('Vote Requests')).toBeDefined();
201+
expect(await screen.findByText('Governance')).toBeDefined();
205202

206-
changeAction('SRARC_SetConfig');
203+
changeAction('SRARC_SetConfig');
207204

208-
const input = screen.getByTestId(
209-
'decentralizedSynchronizer.synchronizers.0.1.acsCommitmentReconciliationInterval-value'
210-
);
211-
await user.clear(input);
212-
await user.type(input, '481516');
213-
expect(await screen.findByDisplayValue('481516')).toBeDefined();
205+
const input = screen.getByTestId(
206+
'decentralizedSynchronizer.synchronizers.0.1.acsCommitmentReconciliationInterval-value'
207+
);
208+
await user.clear(input);
209+
await user.type(input, '481516');
210+
expect(await screen.findByDisplayValue('481516')).toBeDefined();
214211

215-
const summaryInput = screen.getByTestId('create-reason-summary');
216-
await user.type(summaryInput, 'summaryABC');
217-
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
212+
const summaryInput = screen.getByTestId('create-reason-summary');
213+
await user.type(summaryInput, 'summaryABC');
214+
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
218215

219-
const urlInput = screen.getByTestId('create-reason-url');
220-
await user.type(urlInput, 'https://vote-request.url');
216+
const urlInput = screen.getByTestId('create-reason-url');
217+
await user.type(urlInput, 'https://vote-request.url');
221218

222-
const warning = screen.getByTestId('voterequest-creation-alert');
223-
expect(warning).toBeDefined();
224-
expect(warning.textContent).toContain(
225-
'A Vote Request aiming to change similar fields already exists. ' +
226-
'You are therefore not allowed to modify the fields: decentralizedSynchronizer.synchronizers.acsCommitmentReconciliationInterval'
227-
);
219+
const warning = screen.getByTestId('voterequest-creation-alert');
220+
expect(warning).toBeDefined();
221+
expect(warning.textContent).toContain(
222+
'A Vote Request aiming to change similar fields already exists. ' +
223+
'You are therefore not allowed to modify the fields: decentralizedSynchronizer.synchronizers.acsCommitmentReconciliationInterval'
224+
);
228225

229-
const button = screen.getByRole('button', { name: 'Send Request to Super Validators' });
230-
expect(button.getAttribute('disabled')).toBeDefined();
231-
}
232-
);
226+
const button = screen.getByRole('button', { name: 'Send Request to Super Validators' });
227+
expect(button.getAttribute('disabled')).toBeDefined();
228+
});
233229

234-
test(
235-
'displays a warning when an SV tries to modify an AmuletRules field already changed by another request',
236-
{ timeout: 10000 },
237-
async () => {
238-
const user = userEvent.setup();
239-
render(<AppWithConfig />);
230+
test('displays a warning when an SV tries to modify an AmuletRules field already changed by another request', async () => {
231+
const user = userEvent.setup();
232+
render(<AppWithConfig />);
240233

241-
expect(await screen.findByText('Governance')).toBeDefined();
242-
await user.click(screen.getByText('Governance'));
234+
expect(await screen.findByText('Governance')).toBeDefined();
235+
await user.click(screen.getByText('Governance'));
243236

244-
expect(await screen.findByText('Vote Requests')).toBeDefined();
237+
expect(await screen.findByText('Vote Requests')).toBeDefined();
245238

246-
changeAction('CRARC_SetConfig');
239+
changeAction('CRARC_SetConfig');
247240

248-
const input = screen.getByTestId('transferConfig.createFee.fee-value');
249-
await user.clear(input);
250-
await user.type(input, '481516');
251-
expect(await screen.findByDisplayValue('481516')).toBeDefined();
241+
const input = screen.getByTestId('transferConfig.createFee.fee-value');
242+
await user.clear(input);
243+
await user.type(input, '481516');
244+
expect(await screen.findByDisplayValue('481516')).toBeDefined();
252245

253-
const input2 = screen.getByTestId('create-reason-summary');
254-
await user.type(input2, 'summaryABC');
255-
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
246+
const input2 = screen.getByTestId('create-reason-summary');
247+
await user.type(input2, 'summaryABC');
248+
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
256249

257-
const urlInput = screen.getByTestId('create-reason-url');
258-
await user.type(urlInput, 'https://vote-request.url');
250+
const urlInput = screen.getByTestId('create-reason-url');
251+
await user.type(urlInput, 'https://vote-request.url');
259252

260-
const warning = screen.getByTestId('voterequest-creation-alert');
261-
expect(warning).toBeDefined();
262-
expect(warning.textContent).toContain(
263-
'A Vote Request aiming to change similar fields already exists. ' +
264-
'You are therefore not allowed to modify the fields: transferConfig.createFee.fee'
265-
);
266-
const button = screen.getByTestId('create-voterequest-submit-button');
267-
expect(button.getAttribute('disabled')).toBeDefined();
268-
}
269-
);
253+
const warning = screen.getByTestId('voterequest-creation-alert');
254+
expect(warning).toBeDefined();
255+
expect(warning.textContent).toContain(
256+
'A Vote Request aiming to change similar fields already exists. ' +
257+
'You are therefore not allowed to modify the fields: transferConfig.createFee.fee'
258+
);
259+
const button = screen.getByTestId('create-voterequest-submit-button');
260+
expect(button.getAttribute('disabled')).toBeDefined();
261+
});
270262

271-
test(
272-
'disables the Proceed button in the confirmation dialog if a conflict arises after request creation',
273-
{ timeout: 10000 },
274-
async () => {
275-
server.use(
276-
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
277-
return res(ctx.json<ListDsoRulesVoteRequestsResponse>({ dso_rules_vote_requests: [] }));
278-
})
279-
);
263+
test('disables the Proceed button in the confirmation dialog if a conflict arises after request creation', async () => {
264+
server.use(
265+
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
266+
return res(ctx.json<ListDsoRulesVoteRequestsResponse>({ dso_rules_vote_requests: [] }));
267+
})
268+
);
280269

281-
const user = userEvent.setup();
282-
render(<AppWithConfig />);
270+
const user = userEvent.setup();
271+
render(<AppWithConfig />);
283272

284-
expect(await screen.findByText('Governance')).toBeDefined();
285-
await user.click(screen.getByText('Governance'));
273+
expect(await screen.findByText('Governance')).toBeDefined();
274+
await user.click(screen.getByText('Governance'));
286275

287-
expect(await screen.findByText('Vote Requests')).toBeDefined();
288-
expect(await screen.findByText('Governance')).toBeDefined();
276+
expect(await screen.findByText('Vote Requests')).toBeDefined();
277+
expect(await screen.findByText('Governance')).toBeDefined();
289278

290-
changeAction('CRARC_SetConfig');
279+
changeAction('CRARC_SetConfig');
291280

292-
const input = screen.getByTestId('transferConfig.createFee.fee-value');
293-
await user.clear(input);
294-
await user.type(input, '481516');
295-
expect(await screen.findByDisplayValue('481516')).toBeDefined();
281+
const input = screen.getByTestId('transferConfig.createFee.fee-value');
282+
await user.clear(input);
283+
await user.type(input, '481516');
284+
expect(await screen.findByDisplayValue('481516')).toBeDefined();
296285

297-
const input2 = screen.getByTestId('create-reason-summary');
298-
await user.type(input2, 'summaryABC');
299-
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
286+
const input2 = screen.getByTestId('create-reason-summary');
287+
await user.type(input2, 'summaryABC');
288+
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
300289

301-
const urlInput = screen.getByTestId('create-reason-url');
302-
await user.type(urlInput, 'https://vote-request.url');
303-
expect(await screen.findByDisplayValue('https://vote-request.url')).toBeDefined();
290+
const urlInput = screen.getByTestId('create-reason-url');
291+
await user.type(urlInput, 'https://vote-request.url');
292+
expect(await screen.findByDisplayValue('https://vote-request.url')).toBeDefined();
304293

305-
expect(await screen.findByText('Send Request to Super Validators')).toBeDefined();
306-
await user.click(screen.getByText('Send Request to Super Validators'));
294+
expect(await screen.findByText('Send Request to Super Validators')).toBeDefined();
295+
await user.click(screen.getByText('Send Request to Super Validators'));
307296

308-
server.use(
309-
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
310-
return res(ctx.json<ListDsoRulesVoteRequestsResponse>(voteRequests));
311-
})
312-
);
297+
server.use(
298+
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
299+
return res(ctx.json<ListDsoRulesVoteRequestsResponse>(voteRequests));
300+
})
301+
);
313302

314-
const button = screen.getByRole('button', { name: 'Proceed' });
315-
expect(button.getAttribute('disabled')).toBeDefined();
316-
}
317-
);
303+
const button = screen.getByRole('button', { name: 'Proceed' });
304+
expect(button.getAttribute('disabled')).toBeDefined();
305+
});
318306
});
319307

320308
describe('An AddFutureAmuletConfigSchedule request', () => {

0 commit comments

Comments
 (0)