Skip to content

test(portal): put the onboarding password generator through its paces #908

Description

@Mishael-2584

The small adventure

When an administrator welcomes a new Formulus user, Synkronus Portal can create
a strong handoff password. The generator intentionally avoids look-alike
characters and guarantees several character classes, but it currently has no
focused automated tests.

This is a friendly first mission: learn one Portal utility, add the missing test
plumbing, and make an important onboarding path less mysterious.

Where to start

  • synkronus-portal/src/utils/password.ts
  • synkronus-portal/package.json
  • synkronus-portal/AGENTS.md

What to change

  • Add the smallest test setup that fits the existing Vite + TypeScript project
    (Vitest is the natural choice unless the project has changed by the time this
    issue is picked up).
  • Add focused tests for generateStrongPassword covering:
    • default length;
    • the minimum length when a smaller value is requested;
    • a requested length above the minimum;
    • at least one uppercase letter, lowercase letter, digit, and symbol;
    • exclusion of the documented ambiguous characters 0, O, 1, l, and
      I.
  • Keep tests deterministic by stubbing crypto.getRandomValues; do not weaken
    or replace the production randomness.
  • Add a package script for running the tests.

Guardrails

  • Do not test that two random calls happen to return different passwords; that
    makes a flaky test, not a stronger one.
  • Do not mock generateStrongPassword itself.
  • Keep the scope on this utility and its test setup. A wider Portal test-suite
    migration is a separate project.

Done when

  • generateStrongPassword has deterministic tests for the behavior above.
  • The Portal has a documented pnpm test command in package.json.
  • Production password-generation behavior is unchanged unless a test
    uncovers a genuine bug, in which case describe it in the pull request.
  • Portal lint, formatting, tests, and build pass.

Verify it

From synkronus-portal/:

pnpm run lint
pnpm run format:check
pnpm test
pnpm run build

What you will meet along the way

Portal is an ordinary client of Synkronus's public API, not a secret admin
backdoor. This utility sits in the flow where an administrator creates a user
who will later collect and synchronize data with Formulus.

AI tools are welcome, not required

AI can help draft the Vitest configuration or enumerate edge cases. Please read
the generator first, choose assertions that test its public contract, and be
ready to explain why your randomness stub is deterministic. A generated pile of
tests is less useful than five tests you understand.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions