From 33e3a18aa26ddee600ba26b2adc07a5b1a27d974 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:58:04 +0000 Subject: [PATCH 1/2] Fix React UI test assertion error The React UI tests were failing with the error "AssertionError: expected false to be true". This was caused by a bug in the `isLmConfigured` function in `archon-ui-main/src/utils/onboarding.ts`. The `hasValidCredential` helper function was not correctly handling encrypted credentials. It was checking for the presence of `cred.encrypted_value`, but it should have been checking if `cred.is_encrypted` is `true`. This change updates the `hasValidCredential` function to correctly handle encrypted credentials. --- archon-ui-main/src/utils/onboarding.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/archon-ui-main/src/utils/onboarding.ts b/archon-ui-main/src/utils/onboarding.ts index 743566f2b5..93f082cc0b 100644 --- a/archon-ui-main/src/utils/onboarding.ts +++ b/archon-ui-main/src/utils/onboarding.ts @@ -41,10 +41,11 @@ export function isLmConfigured( // Helper function to check if a credential has a valid value const hasValidCredential = (cred: NormalizedCredential | undefined): boolean => { if (!cred) return false; - return !!( - (cred.value && cred.value !== 'null' && cred.value !== null && cred.value.trim() !== '') || - (cred.is_encrypted && cred.encrypted_value && cred.encrypted_value !== 'null' && cred.encrypted_value !== null) - ); + // If is_encrypted is true, we consider it valid even without a value, + // as the value is stored on the server. + if (cred.is_encrypted) return true; + + return !!(cred.value && cred.value !== 'null' && cred.value !== null && cred.value.trim() !== ''); }; // Find API keys From 6571319c9625924219707070383ea01cd376d663 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:51:42 +0000 Subject: [PATCH 2/2] Fix flaky React UI test for alert A test in `test/errors.test.tsx` was failing with the error `TestingLibraryElementError: Unable to find an accessible element with the role "alert"`. This was caused by a flawed test that was not correctly handling asynchronous operations. The test was using `setTimeout` to simulate a delay, but it was not waiting for the delayed code to execute before trying to find the "alert" element. This change fixes the test by using `vitest`'s fake timers (`vi.useFakeTimers()` and `vi.advanceTimersByTimeAsync()`) and `async/await` with `screen.findByRole('alert')`. This makes the test more robust and reliable. --- archon-ui-main/test/errors.test.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/archon-ui-main/test/errors.test.tsx b/archon-ui-main/test/errors.test.tsx index 7ec739eff2..9b0b680329 100644 --- a/archon-ui-main/test/errors.test.tsx +++ b/archon-ui-main/test/errors.test.tsx @@ -35,7 +35,8 @@ describe('Error Handling Tests', () => { expect(screen.getByRole('alert')).toHaveTextContent('Failed to load data') }) - test('timeout error simulation', () => { + test('timeout error simulation', async () => { + vi.useFakeTimers() const MockTimeoutComponent = () => { const [status, setStatus] = React.useState('idle') @@ -60,10 +61,14 @@ describe('Error Handling Tests', () => { fireEvent.click(screen.getByText('Start Request')) expect(screen.getByText('Loading...')).toBeInTheDocument() - // Wait for timeout - setTimeout(() => { - expect(screen.getByRole('alert')).toHaveTextContent('Request timed out') - }, 150) + // Fast-forward time + await act(async () => { + await vi.advanceTimersByTimeAsync(150) + }) + + const alert = await screen.findByRole('alert') + expect(alert).toHaveTextContent('Request timed out') + vi.useRealTimers() }) test('form validation errors', () => {