ci(react): add browser-based integration testing to a2ui_explorer#1607
ci(react): add browser-based integration testing to a2ui_explorer#1607ditman wants to merge 14 commits into
Conversation
…e, and a simple test. Add changes to the app so it can be used for testing
…start the demo app. Remove unused deps.
|
I forgot to split the testing for react in unit vs integration in the github workflow! |
There was a problem hiding this comment.
Code Review
This pull request refactors the React explorer application to statically generate and map specification examples instead of using Vite's dynamic import.meta.glob, enabling integration testing with Karma and Jasmine. It introduces a static generation script, configures Karma, adds a robust integration test suite, and refactors the main application component to support testing properties. The reviewer feedback highlights two key improvements: adding tsconfig.spec.json to the test:base wireit task files to ensure proper cache invalidation, and safely validating the initialExampleId in App.tsx to avoid potential runtime crashes from non-null assertions.
|
(This commit was a little bit weird: 52d4975) |
|
Here's the "integration" test run for react: |
|
/gemini review again |
There was a problem hiding this comment.
Code Review
This pull request refactors the React Explorer to support integration testing with Karma and esbuild by replacing Vite-specific dynamic imports with a statically generated examples mapping. It also introduces new integration tests and test utilities. Feedback on the changes highlights a potential runtime crash in App.tsx if an invalid initialExampleId is provided, as the non-null assertion could lead to a TypeError when accessing selectedItem.messages. A fallback to the first demo item is suggested to prevent this issue.
| const [selectedExampleId, setSelectedExampleId] = useState(initialExampleId ?? demoItems[0].id); | ||
| const selectedItem = demoItems.find(e => e.id === selectedExampleId)!; |
There was a problem hiding this comment.
If initialExampleId is invalid or not found in demoItems, demoItems.find will return undefined. The non-null assertion ! will bypass TypeScript compilation checks, but at runtime, accessing selectedItem.messages will throw a TypeError: Cannot read properties of undefined (reading 'messages') and crash the application.
To prevent this, we should safely fall back to the first demo item (demoItems[0]) if the specified ID is not found, and use optional chaining for the initial state.
| const [selectedExampleId, setSelectedExampleId] = useState(initialExampleId ?? demoItems[0].id); | |
| const selectedItem = demoItems.find(e => e.id === selectedExampleId)!; | |
| const [selectedExampleId, setSelectedExampleId] = useState(initialExampleId ?? demoItems[0]?.id); | |
| const selectedItem = demoItems.find(e => e.id === selectedExampleId) ?? demoItems[0]; |
Description
This PR adds a karma + jasmine + headless chrome integration test harness to the React
a2ui_explorertest app, similar to what we did with Lit here:Key changes
a2ui_explorerreact app a stand-alone package, so we can customize its dependencies (and tests) separately from the react renderer itselfPre-launch Checklist
If you need help, consider asking for advice on the discussion board.