Skip to content

frontend: add tests and stories for AuthToken Component#4761

Open
aravind4799 wants to merge 1 commit intokubernetes-sigs:mainfrom
aravind4799:Authtoken-fix
Open

frontend: add tests and stories for AuthToken Component#4761
aravind4799 wants to merge 1 commit intokubernetes-sigs:mainfrom
aravind4799:Authtoken-fix

Conversation

@aravind4799
Copy link
Contributor

Summary

Add Storybook stories for the Auth.tsx component to improve coverage and document UI states.

Related Issue

Fixes #4684

Changes

  • New file: frontend/src/components/account/Auth.test.tsx
  • New file: frontend/src/components/account/AuthToken.stories.tsx
AuthToken-test

Notes for the Reviewer

  • The tests require vi.mock chains for K8s classes (Deployment, Pod, ReplicaSet) to prevent a circular dependency during import when vitest loads Auth.tsx, the k8s module graph triggers class ReplicaSet extends KubeObject before KubeObject finishes loading. The mocks break this chain by providing stub classes.
  • Additionally, useNavBarMode is mocked because TestContext does not provide a MUI ThemeProvider, so theme.palette.navbar is undefined.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aravind4799
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 22, 2026
@illume illume requested a review from Copilot February 22, 2026 17:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automated tests and Storybook coverage for the AuthToken / PureAuthToken auth-token dialog to improve UI-state documentation and component test coverage (per #4684).

Changes:

  • Adds a new Vitest test suite covering key PureAuthToken render states and basic AuthToken failure behavior.
  • Adds new Storybook stories for common PureAuthToken states plus “stateful” AuthToken stories driven by MSW handlers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
frontend/src/components/account/AuthToken.stories.tsx Adds presentational + MSW-backed stateful stories and interaction plays for AuthToken UI states.
frontend/src/components/account/Auth.test.tsx Adds unit tests for PureAuthToken rendering/callbacks and basic stateful error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Tests use vi.mock to prevent k8s circular dependency during import
- Mock useNavBarMode since TestContext lacks MUI ThemeProvider
- Coverage for Auth.tsx improved from 18% to ~79%
- fixed: canvasElement.ownerDocument.body -> canvasElement
@aravind4799
Copy link
Contributor Author

resolved co-pilot suggestions and rebased, PTAL @illume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

3 participants