Skip to content

Unit tests#17

Merged
Ciscode-M merged 18 commits intomasterfrom
unit-tests
Feb 4, 2026
Merged

Unit tests#17
Ciscode-M merged 18 commits intomasterfrom
unit-tests

Conversation

@a-elkhiraooui-ciscode
Copy link
Copy Markdown
Contributor

@a-elkhiraooui-ciscode a-elkhiraooui-ciscode commented Feb 4, 2026

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

@a-elkhiraooui-ciscode a-elkhiraooui-ciscode requested review from a team and Copilot February 4, 2026 09:07
Copy link
Copy Markdown

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

This PR introduces comprehensive unit testing infrastructure to the authentication kit module using Vitest and React Testing Library, along with minor updates to the ProfilePage component to split name handling into separate first name, last name, and username fields.

Changes:

  • Adds Vitest configuration with jsdom environment and centralized test setup
  • Implements unit tests for utilities (JWT helpers, color helpers, auth interceptor), hooks (useAbility), contexts (AuthState, AuthConfig, Rbac), and components (SessionExpiredModal, RequirePermissions, InputField, InlineError)
  • Adds comprehensive test infrastructure including required dependencies and npm scripts
  • Updates ProfilePage to handle structured name fields (fname, lname, username) instead of a single name field

Reviewed changes

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

Show a summary per file
File Description
vitest.config.ts Configures Vitest with jsdom environment and test file patterns
tests/setup.ts Sets up React Testing Library with jest-dom matchers and cleanup
tests/utils/jwtHelpers.test.ts Tests JWT token decoding with field mapping and defaults
tests/utils/colorHelpers.test.ts Tests Tailwind color class conversion utility
tests/utils/attachAuthInterceptor.test.ts Tests auth interceptor with token refresh and logout behavior
tests/providers/AuthProvider.test.tsx Tests AuthProvider routing and authentication state
tests/hooks/useAbility.test.tsx Tests role, module, and permission checking hooks
tests/context/RbacContext.test.tsx Tests RBAC grant logic with permissions and roles
tests/context/AuthStateContext.test.tsx Tests auth state context provider and consumer behavior
tests/context/AuthConfigContext.test.tsx Tests auth config context provider and consumer behavior
tests/components/SessionExpiredModal.test.tsx Tests modal rendering and body style management
tests/components/RequirePermissions.test.tsx Tests permission-based access control component
tests/components/InputField.test.tsx Tests input field rendering and change handling
tests/components/InlineError.test.tsx Tests error display with auto-dismiss and manual dismiss
src/components/ProfilePage.tsx Splits name into fname, lname, and username fields
package.json Adds test dependencies and scripts, bumps version to 1.0.12
README.md Documents testing approach and commands

Comment thread tests/components/RequirePermissions.test.tsx
Comment thread tests/components/RequirePermissions.test.tsx
@Ciscode-M Ciscode-M merged commit 1be41bc into master Feb 4, 2026
1 check passed
@Ciscode-M Ciscode-M deleted the unit-tests branch February 4, 2026 09:17
saadmoumou added a commit that referenced this pull request Apr 17, 2026
* Updated workflows  (#10)

* ops: updated release pipeline to run only on version changes, and created ci workflow

* 1.0.8

* docs(workflow): add Git Flow and npm version requirements (#11)

- Add Git Flow branching strategy (develop/master)
- Document npm version command before push
- Add prepublishOnly hook recommendation
- Update workflow with proper branch management
- Clear warnings about PR targeting

Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>

* docs: added different documentations

* 1.0.9

* ops: updated publishing trigger

* Fix/verify email UI (#13)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* Unit tests (#17)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* 1.0.12

* Error handling (#18)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* added error handling to forgot password, reset password and signin/up page

* 1.0.13

* feat(auth): add dynamic signup fields and custom endpoints

* refactor(ui): cleanup imports and formatting in auth pages

* fix(auth): remove accessToken from bootstrap useEffect deps to prevent logout bounce-back

* fix: resolve lint errors, test failures and add eslint + prettier devDependencies

* chore: bump version to 1.0.15

---------

Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>
Co-authored-by: Ciscode-Admin <info@ciscod.com>
Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Co-authored-by: a-elkhiraooui-ciscode <a.elkhiraoui@ciscod.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
saadmoumou added a commit that referenced this pull request Apr 20, 2026
* Updated workflows  (#10)

* ops: updated release pipeline to run only on version changes, and created ci workflow

* 1.0.8

* docs(workflow): add Git Flow and npm version requirements (#11)

- Add Git Flow branching strategy (develop/master)
- Document npm version command before push
- Add prepublishOnly hook recommendation
- Update workflow with proper branch management
- Clear warnings about PR targeting

Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>

* docs: added different documentations

* 1.0.9

* ops: updated publishing trigger

* Fix/verify email UI (#13)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* Unit tests (#17)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* 1.0.12

* Error handling (#18)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* added error handling to forgot password, reset password and signin/up page

* 1.0.13

* feat(auth): add dynamic signup fields and custom endpoints

* refactor(ui): cleanup imports and formatting in auth pages

* fix(auth): remove accessToken from bootstrap useEffect deps to prevent logout bounce-back

* fix: resolve lint errors, test failures and add eslint + prettier devDependencies

* chore: bump version to 1.0.15

* test: enhance coverage for AuthKit-UI + fix typecheck and test:cov script

- Fix typecheck: add paths aliases to resolve @types/react dual-version conflict
- Fix test:cov script: use 'vitest run --coverage' (was watch mode)
- Add vitest coverage config: include src/**, exclude models/assets
- Add tests/utils/errorHelpers.test.ts: 9 tests covering extractHttpErrorMessage
- Add tests/components/SocialButton.test.tsx: 3 tests for SocialButton render
- Add tests/components/ProfilePage.test.tsx: 7 tests (load, edit, save, cancel, error toast)
- Add tests/pages/auth/authPages.test.tsx: tests for ForgotPassword, ResetPassword, VerifyEmail, GoogleCallback, SignIn, SignUp pages
- Add tests/exports.test.ts: smoke test for src/main/app re-exports

Coverage: 28.81%% -> 85%% statements

* fix: replace deprecated JSX.Element with React.ReactElement in AuthProvider

* fix: upgrade @types/react-dom to ^19 to fix npm ci lock file mismatch

---------

Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>
Co-authored-by: Ciscode-Admin <info@ciscod.com>
Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Co-authored-by: a-elkhiraooui-ciscode <a.elkhiraoui@ciscod.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
Zaiidmo added a commit that referenced this pull request Apr 20, 2026
* chore: standardize package workflows and ci/cd configuration

- Replace non-standard ci.yml with standardized release-check.yml and pr-validation.yml
- Create dependabot.yml for automated dependency management (weekly, 5 PR limit)
- Add sonarqube_mcp.instructions.md for SonarQube MCP server guidance
- Ensure consistent GitHub Actions versions (v4 for checkout and setup-node)
- Configure standardized Node versions (v22 for release, v20 for validation/publish)
- Pin SonarQube actions to commit SHA for security hardening
- Standardize branch triggers ([master, main] for release, [develop] for validation)

This aligns AuthKit-UI with the standardized CI/CD pattern used across all @ciscode/* packages.

* ops: added sonarqube_mcp-instructions

* chore: standardize npm scripts (lint, format, typecheck, test, build, clean, verify, prepublishOnly)

* chore: Standardize ESLint and Prettier configs with best practices

* chore: added comprehensive changesets for release automation

* docs: add standardized instruction files structure

- Add comprehensive instruction files in .github/instructions/
- Includes copilot, testing, bugfix, features, general guidelines
- Standardize documentation across all repositories

* refactor: move instruction files to .github/instructions/

- Remove deprecated instruction files from .github/ root
- Consolidate all docs in .github/instructions/ directory
- Improve documentation organization

* ops: UPDATED publish workflow and dependabot PR limits

* ops (ci): standardize publish validation and dependabot across all packages

- Replace git tag --list strategy with package.json-driven tag validation
  in all 16 publish workflows; use git rev-parse to verify the exact tag
  exists rather than guessing the latest repo-wide tag
- Update error guidance to reflect feat/** → develop → master flow
- Standardize dependabot to npm-only, grouped, monthly cadence across
  all 16 packages; remove github-actions ecosystem updates
- Add missing dependabot.yml to AuthKit-UI, ChartKit-UI, HealthKit,
  HooksKit, paymentkit, StorageKit

* security: added CODEOWNER file for branches security

* ops: updated relese check workflow#

* ci: update release check workflow

* ops: updated release check jobs ]

* Bugfix/fix auth bootstrap bounce (#19)

* Updated workflows  (#10)

* ops: updated release pipeline to run only on version changes, and created ci workflow

* 1.0.8

* docs(workflow): add Git Flow and npm version requirements (#11)

- Add Git Flow branching strategy (develop/master)
- Document npm version command before push
- Add prepublishOnly hook recommendation
- Update workflow with proper branch management
- Clear warnings about PR targeting

Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>

* docs: added different documentations

* 1.0.9

* ops: updated publishing trigger

* Fix/verify email UI (#13)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* Unit tests (#17)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* 1.0.12

* Error handling (#18)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* added error handling to forgot password, reset password and signin/up page

* 1.0.13

* feat(auth): add dynamic signup fields and custom endpoints

* refactor(ui): cleanup imports and formatting in auth pages

* fix(auth): remove accessToken from bootstrap useEffect deps to prevent logout bounce-back

* fix: resolve lint errors, test failures and add eslint + prettier devDependencies

* chore: bump version to 1.0.15

---------

Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>
Co-authored-by: Ciscode-Admin <info@ciscod.com>
Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Co-authored-by: a-elkhiraooui-ciscode <a.elkhiraoui@ciscod.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>

* Bugfix/fix auth bootstrap bounce (#22)

* Updated workflows  (#10)

* ops: updated release pipeline to run only on version changes, and created ci workflow

* 1.0.8

* docs(workflow): add Git Flow and npm version requirements (#11)

- Add Git Flow branching strategy (develop/master)
- Document npm version command before push
- Add prepublishOnly hook recommendation
- Update workflow with proper branch management
- Clear warnings about PR targeting

Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>

* docs: added different documentations

* 1.0.9

* ops: updated publishing trigger

* Fix/verify email UI (#13)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* Unit tests (#17)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* 1.0.12

* Error handling (#18)

* parents translate, components receive plain strings

* 1.0.3

* tested in local, bug fixed

* 1.0.4

* forgot and reset password done

* 1.0.6

* verify email page done

* merged

* 1.0.10

* updated endpoints

* show profile updated to match new response

* added unit tests

* added error handling to forgot password, reset password and signin/up page

* 1.0.13

* feat(auth): add dynamic signup fields and custom endpoints

* refactor(ui): cleanup imports and formatting in auth pages

* fix(auth): remove accessToken from bootstrap useEffect deps to prevent logout bounce-back

* fix: resolve lint errors, test failures and add eslint + prettier devDependencies

* chore: bump version to 1.0.15

* test: enhance coverage for AuthKit-UI + fix typecheck and test:cov script

- Fix typecheck: add paths aliases to resolve @types/react dual-version conflict
- Fix test:cov script: use 'vitest run --coverage' (was watch mode)
- Add vitest coverage config: include src/**, exclude models/assets
- Add tests/utils/errorHelpers.test.ts: 9 tests covering extractHttpErrorMessage
- Add tests/components/SocialButton.test.tsx: 3 tests for SocialButton render
- Add tests/components/ProfilePage.test.tsx: 7 tests (load, edit, save, cancel, error toast)
- Add tests/pages/auth/authPages.test.tsx: tests for ForgotPassword, ResetPassword, VerifyEmail, GoogleCallback, SignIn, SignUp pages
- Add tests/exports.test.ts: smoke test for src/main/app re-exports

Coverage: 28.81%% -> 85%% statements

* fix: replace deprecated JSX.Element with React.ReactElement in AuthProvider

* fix: upgrade @types/react-dom to ^19 to fix npm ci lock file mismatch

---------

Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>
Co-authored-by: Ciscode-Admin <info@ciscod.com>
Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Co-authored-by: a-elkhiraooui-ciscode <a.elkhiraoui@ciscod.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>

* fix(security): upgrade axios >=1.14.1 and override follow-redirects >=1.15.12 to fix CVEs

* style: apply prettier formatting to all files

* fix(ci): correct sonar.tests path from 'test' to 'tests' and add .tsx inclusions

* fix(ci): gate SonarCloud job to workflow_dispatch only, matching WidgetKit-UI pattern

* added release check

* style: prettier format release-check.yml

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Co-authored-by: Zaiid Moumni <141942826+Zaiidmo@users.noreply.github.com>
Co-authored-by: Ciscode-Admin <info@ciscod.com>
Co-authored-by: Reda Channa <r.channa@ciscod.com>
Co-authored-by: a-elkhiraooui-ciscode <a.elkhiraoui@ciscod.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants