Skip to content

Commit 210b295

Browse files
authored
Merge pull request #373 from objectstack-ai/copilot/fix-ci-pipeline-error-another-one
2 parents f88605a + d774271 commit 210b295

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const mocks = vi.hoisted(() => {
3030
}
3131
return { data: [] };
3232
}
33+
async findOne(objectName: string, id: string) {
34+
if (objectName === 'kitchen_sink') {
35+
return { id, name: 'Test Sink', amount: 100 };
36+
}
37+
return null;
38+
}
3339
async getObjectSchema(name: string) {
3440
if (name === 'kitchen_sink') {
3541
return {
@@ -147,6 +153,14 @@ describe('Console Application Simulation', () => {
147153
});
148154

149155
it('Scenario 4: Object Create Form (All Field Types)', async () => {
156+
// Helper function to check if a label exists in the form
157+
const expectLabelToExist = (label: string) => {
158+
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
159+
const regex = new RegExp(escaped, 'i');
160+
const elements = screen.queryAllByText(regex);
161+
expect(elements.length).toBeGreaterThan(0);
162+
};
163+
150164
renderApp('/kitchen_sink');
151165

152166
// 1. Wait for Object View
@@ -164,10 +178,10 @@ describe('Console Application Simulation', () => {
164178
});
165179

166180
// 4. Verify Field Inputs
167-
// Wait for at least one field to appear to ensure form is loaded
181+
// Wait for form to finish loading and first field to appear
168182
await waitFor(() => {
169183
expect(screen.getByText(/Text \(Name\)/i)).toBeInTheDocument();
170-
}, { timeout: 5000 });
184+
}, { timeout: 10000 });
171185

172186
const fieldLabels = [
173187
'Text (Name)',
@@ -178,17 +192,12 @@ describe('Console Application Simulation', () => {
178192
'Boolean (Switch)',
179193
];
180194

181-
// Check each label exists
182-
for (const label of fieldLabels) {
183-
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
184-
const regex = new RegExp(escaped, 'i');
185-
const elements = screen.queryAllByText(regex);
186-
if (elements.length === 0) {
187-
console.log(`Failed to find label: ${label}`);
188-
// console.log(document.body.innerHTML); // Too large, but useful if localized
189-
}
190-
expect(elements.length).toBeGreaterThan(0);
191-
}
195+
// Check all labels exist concurrently using Promise.all for faster execution
196+
await Promise.all(
197+
fieldLabels.map(label =>
198+
waitFor(() => expectLabelToExist(label), { timeout: 5000 })
199+
)
200+
);
192201

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

0 commit comments

Comments
 (0)