[Test Improver] Add unit tests for shell/utils/auth.js utility functions - #132
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[Test Improver] Add unit tests for shell/utils/auth.js utility functions#132github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Test parseAuthProvidersInfo, canViewResource, notLoggedIn, and checkPermissions with 24 test cases covering all logical branches: - parseAuthProvidersInfo: empty rows, local filtering, single enabled provider, oidc exclusion from supportedNonLocal, multiple enabled providers (null enabledLocation), disabled providers - canViewResource: falsy inStore, missing schemaFor, schema found, virtual resource fallback, no schema and not virtual - notLoggedIn: auth/hasAuth commit, setAuthRedirect conditional, index vs non-index redirect targets - checkPermissions: empty types, missing schema, schemaValidator, resourceMethods all-present/one-missing, collectionMethods, schema-only default Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Test Improver, an automated AI assistant focused on improving test coverage.
Goal and Rationale
shell/utils/auth.jsis a critical utility module used in authentication flows across Rancher Dashboard. It had zero test coverage. This module contains several functions with genuine branching logic that benefit from tests:parseAuthProvidersInfo— filters and categorises auth providers; determines the "enabled location" for the single active provider. Multiple filter branches and a null-vs-object decision forenabledLocation.canViewResource— guards resource views based on store schemas and virtual-resource checks. 5 distinct return paths.notLoggedIn— commits auth state and conditionally commits a redirect target, then picks between two redirect destinations.checkPermissions— async function that builds a permissions hash by walking types and checking schemas againstschemaValidator,resourceMethods, orcollectionMethodsmatchers.Approach
parseAuthProvidersInfotested with pure data fixtures — no store required.canViewResourceandnotLoggedIntested with minimaljest.fn()mocks.checkPermissionstested end-to-end (awaiting the resolved Promise) covering all 5 execution paths.it.eachwith named-object entries for table-driven variants.toStrictEqual,toHaveBeenCalledWith.Coverage Impact
Test Status
Lint: ✅ No warnings (
eslint --max-warnings 0)Reproducibility
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
download.cypress.ioSee Network Configuration for more information.