Loading
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,
submitOnboardingResponseinapi/users.ts. No component calls axios. - The
submit_onboarding_responserequest spec posts JSON like the browser.openapi.yamlandtypes.gen.tsare regenerated withbin/generate_api_types: the request body isapplication/jsonwith a requireddata, and the 422 no longer declares atext/htmlbody the controller never sends (head :unprocessable_content). HomePagerenames its booleans for the naming rule (isSignedIn,isTeamMember,isApprovedCommunityMember,hasStartedOnboarding) and callsrouter.replacewithvoid.HomePagereadsreferrerfrom the query only when it is a string. ThedecodeURIComponentstays:ManageIssuePageandManageMergeRequestPageencode the URL before passing it to the router, which encodes it again.StartOnboardingModaltypesreferreras an optional string, defaultundefined, and its form with the generated request type.- Specs mock the client and build
vueDatawithcreateVueData(). A newHomePagetest checks that the modal receives the decoded referrer, which had no coverage. - The
runningHackathonmock inHomePage.specdid not compile: it was missing theterms_versionandidfields of the generated type, so the test now usesmockCalendar.
Behaviour changes
- A repeated
referrerquery parameter (?referrer=a&referrer=b) counts as missing. Before, the modal receiveda,b. But no page builds such a URL.
Validation steps
From contributors/:
- Type check:
npm run typecheck - Lint:
npm run lint - Frontend tests, once and in UTC:
TZ=UTC npm run test -- --run - Request spec:
bundle exec rspec spec/requests/api/v1/users_controller_spec.rb - API contract:
bin/generate_api_types, thengit diffshows no change
Edited by Salim Zidane