Skip to content

Add test coverage for import-export feature UIs#2514

Merged
jeradrutnam merged 1 commit intoasgardeo:mainfrom
jeradrutnam:welcome-new
Apr 30, 2026
Merged

Add test coverage for import-export feature UIs#2514
jeradrutnam merged 1 commit intoasgardeo:mainfrom
jeradrutnam:welcome-new

Conversation

@jeradrutnam
Copy link
Copy Markdown
Contributor

@jeradrutnam jeradrutnam commented Apr 30, 2026

This pull request introduces comprehensive unit and integration tests for the import/export configuration features in the Thunder Console frontend. The new tests cover both API hooks and UI pages, ensuring robust validation of user interactions, error handling, and integration with navigation and logger utilities.

New test coverage for import/export configuration:

API Hook Tests:

  • Added tests for the useExportConfiguration hook, covering states such as idle, pending, success, error, and correct HTTP request/headers handling.
  • Added tests for the useImportConfiguration hook, validating idle, pending, success, error states, and ensuring correct request structure and headers.

Page Component Tests:

  • Added tests for ExportPage, verifying initial export trigger, loading, error, and success states, navigation actions, and correct rendering of child components.
  • Added tests for ImportConfigurationUploadPage, covering file selection, validation, error display, button enablement, and navigation after successful file upload.

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for import/export configuration functionality, including mutation hooks and UI components.
    • Added test suites for welcome and project creation pages to verify navigation and user interactions.
    • Enhanced test infrastructure for the Thunder Console application.

Co-authored-by: Copilot <copilot@github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

This PR adds comprehensive test suites for import-export API hooks (useExportConfiguration, useImportConfiguration) and page components (ExportPage, ImportConfigurationUploadPage, ImportConfigurationValidatePage, CreateProjectPage, WelcomePage), verifying state transitions, HTTP interactions, and navigation flows. Includes a minor TypeScript configuration update.

Changes

Cohort / File(s) Summary
Import-Export API Hooks
frontend/apps/thunder-console/src/features/import-export/api/__tests__/useExportConfiguration.test.ts, useImportConfiguration.test.ts
Tests for export/import configuration hooks; verify state transitions (idle → pending → success/error), HTTP POST requests to /export and /import endpoints, response handling, error surfacing, and Content-Type headers.
Import-Export Page Components
frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ExportPage.test.tsx, ImportConfigurationUploadPage.test.tsx, ImportConfigurationValidatePage.test.tsx
Tests for export and import workflow pages; verify component rendering, loading/error states, file upload validation, navigation flows, and state passing between pages.
Welcome Page Components
frontend/apps/thunder-console/src/features/welcome/pages/__tests__/CreateProjectPage.test.tsx, WelcomePage.test.tsx
Tests for welcome and create project pages; verify rendering, UI element presence, navigation triggers, sessionStorage interactions, and external link opening.
TypeScript Configuration
frontend/packages/thunder-contexts/tsconfig.lib.json
Adds compilerOptions.rootDir setting to specify source directory for compiler output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

skip-changelog, Type/Improvement

Suggested reviewers

  • DonOmalVindula
  • brionmario
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description fully addresses the Purpose and Approach sections with detailed coverage of new tests; however, the Checklist section is not filled out, which is a required component of the template. Complete the Checklist section by marking applicable items (Tests provided, Unit Tests, Integration Tests) and confirm security checks have been performed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add test coverage for import-export feature UIs' directly and clearly summarizes the main change—adding comprehensive test coverage for import/export feature components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@jeradrutnam jeradrutnam changed the title Add test coverage for import-export feature Add test coverage for import-export feature UIs Apr 30, 2026
@jeradrutnam jeradrutnam enabled auto-merge April 30, 2026 08:10
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationValidatePage.test.tsx (1)

97-104: ⚡ Quick win

Test name does not match what is asserted.

The case says it “navigates to /welcome on cancel,” but it actually verifies cancel is not rendered when there are no parse errors. Please rename it to reflect the real behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationValidatePage.test.tsx`
around lines 97 - 104, Rename the test's description string in the
ImportConfigurationValidatePage.test.tsx `it` block so it matches the assertion:
change the current "navigates to /welcome on cancel (no errors)" to something
like "does not render cancel when there are no parse errors" (the `it` that
renders <ImportConfigurationValidatePage /> and asserts the cancel button is not
in the document).
frontend/apps/thunder-console/src/features/welcome/pages/__tests__/WelcomePage.test.tsx (1)

29-31: ⚡ Quick win

Hardcoded brand name in test setup/assertion.

At Line 30 ('Thunder') and the brand-coupled assertion at Line 155, is this hardcoded brand name intentional?
If not, prefer deriving the value from config-driven test data (e.g., shared productName fixture) and asserting against that variable rather than a raw brand token.

As per coding guidelines: **/*.tsx: “Scan for hardcoded occurrences of the string literals `Thunder` or `ThunderID`... flag it and ask: Is this hardcoded brand name intentional?”.

Also applies to: 152-156

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/apps/thunder-console/src/features/welcome/pages/__tests__/WelcomePage.test.tsx`
around lines 29 - 31, The test hardcodes the brand name 'Thunder' in the
useConfig mock and corresponding assertion in WelcomePage.test.tsx; replace the
literal with a shared test variable (e.g., productName) used both when mocking
useConfig and when asserting the rendered output so the test derives the brand
from config-driven test data; update the useConfig mock call and the
assertion(s) that reference 'Thunder' (search for useConfig: () => ({ config:
{brand: {product_name: 'Thunder'}}}) and the expectation in the test) to
reference the shared productName fixture or local const instead of the raw
string.
frontend/packages/thunder-contexts/tsconfig.lib.json (1)

2-21: ⚡ Quick win

Verify emitted dist/ layout still matches the package exports paths.

This config affects how TS computes the relative paths for emitted declarations (via rootDir), and the build script emits declarations to dist/. Since dependent packages likely import via specific exports entries (e.g., ./dist/index.d.ts), it’s worth verifying that the new rootDir: "src" doesn’t change where index.d.ts and other declarations land under dist/.

After applying the change, run the package build for thunder-contexts and inspect dist/ to confirm index.d.ts ends up at the expected path(s) used by this package’s exports.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/thunder-contexts/tsconfig.lib.json` around lines 2 - 21,
The change set rootDir to "src" in tsconfig.lib.json may shift emitted .d.ts
locations and break package exports; rebuild the thunder-contexts package,
inspect dist/ to ensure index.d.ts and other declarations match the package.json
"exports" entries, and if they don't, either adjust tsconfig.lib.json (rootDir,
outDir, declarationDir, or include) so declarations land at the expected paths
or update package.json exports to the new paths; check the
compilerOptions.rootDir and compilerOptions.declarationDir specifically and
re-run the build until dist/ layout matches the exports consumers rely on.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ExportPage.test.tsx`:
- Around line 28-35: The shared mutable test fixture mockMutationState (a
Partial<UseMutationResult<JSONExportResponse, Error, ExportRequest>> with
mutate: mockMutate) is defined once and mutated across tests causing
order-dependent behavior; refactor by creating a factory or resetting it in a
beforeEach: introduce a createMutationState() helper (or move the
mockMutationState initialization into a beforeEach) that returns a fresh
Partial<UseMutationResult<...>> object with mutate: mockMutate, data: undefined,
isPending: false, isError: false, error: null, and update all tests to call that
factory (or read from the fresh variable) so each test gets an isolated mutation
state; apply the same change for other shared mutable fixtures referenced in the
file (lines ~90-173) to ensure test isolation.

In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationUploadPage.test.tsx`:
- Around line 160-171: Test "shows error when continue is clicked without env
file" in ImportConfigurationUploadPage.test.tsx currently only asserts the
Continue button is disabled after uploading a YAML file and does not click or
assert any error; either rename the test to reflect that it checks the
disabled-state (e.g., "disables continue when only yaml is uploaded") or
implement the intended error-flow by enabling the Continue button
programmatically (or simulating user actions that would enable it), then fire a
click on the button (query by role/name 'common:actions.continue') and assert
the expected validation error message appears (use screen.getByText or similar)
to verify the error path when no .env file is provided.

---

Nitpick comments:
In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationValidatePage.test.tsx`:
- Around line 97-104: Rename the test's description string in the
ImportConfigurationValidatePage.test.tsx `it` block so it matches the assertion:
change the current "navigates to /welcome on cancel (no errors)" to something
like "does not render cancel when there are no parse errors" (the `it` that
renders <ImportConfigurationValidatePage /> and asserts the cancel button is not
in the document).

In
`@frontend/apps/thunder-console/src/features/welcome/pages/__tests__/WelcomePage.test.tsx`:
- Around line 29-31: The test hardcodes the brand name 'Thunder' in the
useConfig mock and corresponding assertion in WelcomePage.test.tsx; replace the
literal with a shared test variable (e.g., productName) used both when mocking
useConfig and when asserting the rendered output so the test derives the brand
from config-driven test data; update the useConfig mock call and the
assertion(s) that reference 'Thunder' (search for useConfig: () => ({ config:
{brand: {product_name: 'Thunder'}}}) and the expectation in the test) to
reference the shared productName fixture or local const instead of the raw
string.

In `@frontend/packages/thunder-contexts/tsconfig.lib.json`:
- Around line 2-21: The change set rootDir to "src" in tsconfig.lib.json may
shift emitted .d.ts locations and break package exports; rebuild the
thunder-contexts package, inspect dist/ to ensure index.d.ts and other
declarations match the package.json "exports" entries, and if they don't, either
adjust tsconfig.lib.json (rootDir, outDir, declarationDir, or include) so
declarations land at the expected paths or update package.json exports to the
new paths; check the compilerOptions.rootDir and compilerOptions.declarationDir
specifically and re-run the build until dist/ layout matches the exports
consumers rely on.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 00b57b2b-3d67-45c8-a8f4-0ce0d02c2997

📥 Commits

Reviewing files that changed from the base of the PR and between f35fb3d and 68152d8.

📒 Files selected for processing (8)
  • frontend/apps/thunder-console/src/features/import-export/api/__tests__/useExportConfiguration.test.ts
  • frontend/apps/thunder-console/src/features/import-export/api/__tests__/useImportConfiguration.test.ts
  • frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ExportPage.test.tsx
  • frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationUploadPage.test.tsx
  • frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationValidatePage.test.tsx
  • frontend/apps/thunder-console/src/features/welcome/pages/__tests__/CreateProjectPage.test.tsx
  • frontend/apps/thunder-console/src/features/welcome/pages/__tests__/WelcomePage.test.tsx
  • frontend/packages/thunder-contexts/tsconfig.lib.json

Comment on lines +28 to +35
let mockMutationState: Partial<UseMutationResult<JSONExportResponse, Error, ExportRequest>> = {
mutate: mockMutate,
data: undefined,
isPending: false,
isError: false,
error: null,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reset mockMutationState per test to avoid order-dependent behavior.

Line 28 defines shared mutable state, and later blocks mutate it incrementally. This can make tests depend on execution order. Initialize a fresh base state in a beforeEach for the suite (or create a createMutationState() helper) so each test is isolated.

Also applies to: 90-173

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ExportPage.test.tsx`
around lines 28 - 35, The shared mutable test fixture mockMutationState (a
Partial<UseMutationResult<JSONExportResponse, Error, ExportRequest>> with
mutate: mockMutate) is defined once and mutated across tests causing
order-dependent behavior; refactor by creating a factory or resetting it in a
beforeEach: introduce a createMutationState() helper (or move the
mockMutationState initialization into a beforeEach) that returns a fresh
Partial<UseMutationResult<...>> object with mutate: mockMutate, data: undefined,
isPending: false, isError: false, error: null, and update all tests to call that
factory (or read from the fresh variable) so each test gets an isolated mutation
state; apply the same change for other shared mutable fixtures referenced in the
file (lines ~90-173) to ensure test isolation.

Comment on lines +160 to +171
it('shows error when continue is clicked without env file', async () => {
const user = userEvent.setup();
render(<ImportConfigurationUploadPage />);

// Only select yaml file
const yamlFile = new File(['key: value'], 'config.yaml', {type: 'text/yaml'});
await user.upload(document.getElementById('file-upload') as HTMLInputElement, yamlFile);

// Manually enable the button by patching disabled - instead verify error shows when submitting
// The button is disabled without envFile so this tests the validation guard
expect(screen.getByRole('button', {name: 'common:actions.continue'})).toBeDisabled();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

This test doesn’t validate the behavior described in its title.

Line 160 says it should verify an error when continue is clicked without .env, but the test never clicks continue and only asserts disabled state. Please either rename it to match current behavior or implement the intended error-path assertion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/apps/thunder-console/src/features/import-export/pages/__tests__/ImportConfigurationUploadPage.test.tsx`
around lines 160 - 171, Test "shows error when continue is clicked without env
file" in ImportConfigurationUploadPage.test.tsx currently only asserts the
Continue button is disabled after uploading a YAML file and does not click or
assert any error; either rename the test to reflect that it checks the
disabled-state (e.g., "disables continue when only yaml is uploaded") or
implement the intended error-flow by enabling the Continue button
programmatically (or simulating user actions that would enable it), then fire a
click on the button (query by role/name 'common:actions.continue') and assert
the expected validation error message appears (use screen.getByText or similar)
to verify the error path when no .env file is provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.59%. Comparing base (f35fb3d) to head (68152d8).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2514      +/-   ##
==========================================
+ Coverage   85.97%   86.59%   +0.61%     
==========================================
  Files         913      913              
  Lines       64543    64543              
==========================================
+ Hits        55492    55888     +396     
+ Misses       7046     6650     -396     
  Partials     2005     2005              
Flag Coverage Δ
backend-integration-postgres 51.59% <ø> (ø)
backend-integration-redis 51.18% <ø> (ø)
backend-integration-sqlite 52.11% <ø> (+0.01%) ⬆️
backend-unit 80.61% <ø> (+0.01%) ⬆️
frontend-apps-console-unit 85.72% <ø> (+2.44%) ⬆️
frontend-apps-gate-unit 97.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeradrutnam jeradrutnam added this pull request to the merge queue Apr 30, 2026
Merged via the queue into asgardeo:main with commit 3836f1b Apr 30, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants