From 896720e90f29c6bd6eaacf2eda97013e8687b4bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 08:32:45 +0000 Subject: [PATCH 1/4] Initial plan From 604145aedf4fbd8183883291a2bb3076d84c257f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 08:59:14 +0000 Subject: [PATCH 2/4] Fix BrowserSimulation test timeout issues - Add findOne method to MockDataSource - Increase timeout for form field loading to 15 seconds - Wrap each field label check in waitFor to handle async rendering - Fixes "expected 0 to be greater than 0" assertion error for Date field Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- .../src/__tests__/BrowserSimulation.test.tsx | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/console/src/__tests__/BrowserSimulation.test.tsx b/apps/console/src/__tests__/BrowserSimulation.test.tsx index d9cd6f8a2..cb43cdebf 100644 --- a/apps/console/src/__tests__/BrowserSimulation.test.tsx +++ b/apps/console/src/__tests__/BrowserSimulation.test.tsx @@ -30,6 +30,12 @@ const mocks = vi.hoisted(() => { } return { data: [] }; } + async findOne(objectName: string, id: string) { + if (objectName === 'kitchen_sink') { + return { id, name: 'Test Sink', amount: 100 }; + } + return null; + } async getObjectSchema(name: string) { if (name === 'kitchen_sink') { return { @@ -164,10 +170,11 @@ describe('Console Application Simulation', () => { }); // 4. Verify Field Inputs - // Wait for at least one field to appear to ensure form is loaded + // Wait for form to finish loading and fields to appear + // Note: Increased timeout to account for async schema fetching and form generation await waitFor(() => { expect(screen.getByText(/Text \(Name\)/i)).toBeInTheDocument(); - }, { timeout: 5000 }); + }, { timeout: 15000 }); const fieldLabels = [ 'Text (Name)', @@ -178,16 +185,14 @@ describe('Console Application Simulation', () => { 'Boolean (Switch)', ]; - // Check each label exists + // Check each label exists - use waitFor for each to handle async rendering for (const label of fieldLabels) { - const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const regex = new RegExp(escaped, 'i'); - const elements = screen.queryAllByText(regex); - if (elements.length === 0) { - console.log(`Failed to find label: ${label}`); - // console.log(document.body.innerHTML); // Too large, but useful if localized - } - expect(elements.length).toBeGreaterThan(0); + await waitFor(() => { + const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const regex = new RegExp(escaped, 'i'); + const elements = screen.queryAllByText(regex); + expect(elements.length).toBeGreaterThan(0); + }, { timeout: 5000 }); } // 5. Test specific interaction (e.g. typing in name) From eb764d63f78868109636b3e79bf6407d6834ab80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:01:41 +0000 Subject: [PATCH 3/4] 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> --- .../src/__tests__/BrowserSimulation.test.tsx | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/console/src/__tests__/BrowserSimulation.test.tsx b/apps/console/src/__tests__/BrowserSimulation.test.tsx index cb43cdebf..bfc588b55 100644 --- a/apps/console/src/__tests__/BrowserSimulation.test.tsx +++ b/apps/console/src/__tests__/BrowserSimulation.test.tsx @@ -170,11 +170,10 @@ describe('Console Application Simulation', () => { }); // 4. Verify Field Inputs - // Wait for form to finish loading and fields to appear - // Note: Increased timeout to account for async schema fetching and form generation + // Wait for form to finish loading and first field to appear await waitFor(() => { expect(screen.getByText(/Text \(Name\)/i)).toBeInTheDocument(); - }, { timeout: 15000 }); + }, { timeout: 10000 }); const fieldLabels = [ 'Text (Name)', @@ -185,15 +184,17 @@ describe('Console Application Simulation', () => { 'Boolean (Switch)', ]; - // Check each label exists - use waitFor for each to handle async rendering - for (const label of fieldLabels) { - await waitFor(() => { - const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const regex = new RegExp(escaped, 'i'); - const elements = screen.queryAllByText(regex); - expect(elements.length).toBeGreaterThan(0); - }, { timeout: 5000 }); - } + // Check all labels exist concurrently using Promise.all for faster execution + await Promise.all( + fieldLabels.map(label => + waitFor(() => { + const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const regex = new RegExp(escaped, 'i'); + const elements = screen.queryAllByText(regex); + expect(elements.length).toBeGreaterThan(0); + }, { timeout: 5000 }) + ) + ); // 5. Test specific interaction (e.g. typing in name) // Note: Shadcn/Form labels might be associated via ID, so getByLabelText is safer usually, From d774271a199cdd047cc80ed0c04e8a402b412238 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:08:06 +0000 Subject: [PATCH 4/4] Refactor: Extract helper function for label validation - Add expectLabelToExist helper function to reduce code duplication - Improves readability and maintainability - All tests still passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- .../src/__tests__/BrowserSimulation.test.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/console/src/__tests__/BrowserSimulation.test.tsx b/apps/console/src/__tests__/BrowserSimulation.test.tsx index bfc588b55..ef1becef9 100644 --- a/apps/console/src/__tests__/BrowserSimulation.test.tsx +++ b/apps/console/src/__tests__/BrowserSimulation.test.tsx @@ -153,6 +153,14 @@ describe('Console Application Simulation', () => { }); it('Scenario 4: Object Create Form (All Field Types)', async () => { + // Helper function to check if a label exists in the form + const expectLabelToExist = (label: string) => { + const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const regex = new RegExp(escaped, 'i'); + const elements = screen.queryAllByText(regex); + expect(elements.length).toBeGreaterThan(0); + }; + renderApp('/kitchen_sink'); // 1. Wait for Object View @@ -187,12 +195,7 @@ describe('Console Application Simulation', () => { // Check all labels exist concurrently using Promise.all for faster execution await Promise.all( fieldLabels.map(label => - waitFor(() => { - const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const regex = new RegExp(escaped, 'i'); - const elements = screen.queryAllByText(regex); - expect(elements.length).toBeGreaterThan(0); - }, { timeout: 5000 }) + waitFor(() => expectLabelToExist(label), { timeout: 5000 }) ) );