Skip to content

Commit eb764d6

Browse files
Copilothotlong
andcommitted
Optimize test timeout and use Promise.all for concurrent checks
- Reduce initial timeout from 15s to 10s - Use Promise.all to check all field labels concurrently instead of sequentially - Improves test execution time while maintaining reliability Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 604145a commit eb764d6

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

apps/console/src/__tests__/BrowserSimulation.test.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,10 @@ describe('Console Application Simulation', () => {
170170
});
171171

172172
// 4. Verify Field Inputs
173-
// Wait for form to finish loading and fields to appear
174-
// Note: Increased timeout to account for async schema fetching and form generation
173+
// Wait for form to finish loading and first field to appear
175174
await waitFor(() => {
176175
expect(screen.getByText(/Text \(Name\)/i)).toBeInTheDocument();
177-
}, { timeout: 15000 });
176+
}, { timeout: 10000 });
178177

179178
const fieldLabels = [
180179
'Text (Name)',
@@ -185,15 +184,17 @@ describe('Console Application Simulation', () => {
185184
'Boolean (Switch)',
186185
];
187186

188-
// Check each label exists - use waitFor for each to handle async rendering
189-
for (const label of fieldLabels) {
190-
await waitFor(() => {
191-
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
192-
const regex = new RegExp(escaped, 'i');
193-
const elements = screen.queryAllByText(regex);
194-
expect(elements.length).toBeGreaterThan(0);
195-
}, { timeout: 5000 });
196-
}
187+
// Check all labels exist concurrently using Promise.all for faster execution
188+
await Promise.all(
189+
fieldLabels.map(label =>
190+
waitFor(() => {
191+
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
192+
const regex = new RegExp(escaped, 'i');
193+
const elements = screen.queryAllByText(regex);
194+
expect(elements.length).toBeGreaterThan(0);
195+
}, { timeout: 5000 })
196+
)
197+
);
197198

198199
// 5. Test specific interaction (e.g. typing in name)
199200
// Note: Shadcn/Form labels might be associated via ID, so getByLabelText is safer usually,

0 commit comments

Comments
 (0)