Convert HomePage and StartOnboardingModal to TypeScript

What does this MR do and why?

Converts HomePage and StartOnboardingModal to TypeScript, with their specs.

Closes #920 (closed)

Part of &33

What changed

  • Both components use <script setup lang="ts">, both specs are .spec.ts. The snapshot file is renamed with its spec.
  • The onboarding submission is in a new client, submitOnboardingResponse in api/users.ts. No component calls axios.
  • The submit_onboarding_response request spec posts JSON like the browser. openapi.yaml and types.gen.ts are regenerated with bin/generate_api_types: the request body is application/json with a required data, and the 422 no longer declares a text/html body the controller never sends (head :unprocessable_content).
  • HomePage renames its booleans for the naming rule (isSignedIn, isTeamMember, isApprovedCommunityMember, hasStartedOnboarding) and calls router.replace with void.
  • HomePage reads referrer from the query only when it is a string. The decodeURIComponent stays: ManageIssuePage and ManageMergeRequestPage encode the URL before passing it to the router, which encodes it again.
  • StartOnboardingModal types referrer as an optional string, default undefined, and its form with the generated request type.
  • Specs mock the client and build vueData with createVueData(). A new HomePage test checks that the modal receives the decoded referrer, which had no coverage.
  • The runningHackathon mock in HomePage.spec did not compile: it was missing the terms_version and id fields of the generated type, so the test now uses mockCalendar.

Behaviour changes

  • A repeated referrer query parameter (?referrer=a&referrer=b) counts as missing. Before, the modal received a,b. But no page builds such a URL.

Validation steps

From contributors/:

  1. Type check: npm run typecheck
  2. Lint: npm run lint
  3. Frontend tests, once and in UTC: TZ=UTC npm run test -- --run
  4. Request spec: bundle exec rspec spec/requests/api/v1/users_controller_spec.rb
  5. API contract: bin/generate_api_types, then git diff shows no change

/cc @leetickett-gitlab @dmeister93

Edited by Salim Zidane

Merge request reports

Loading
Loading