Skip to content

msw: add mock handlers for policy endpoints - #1199

Open
deer-wmde wants to merge 30 commits into
mainfrom
de/msw-policies
Open

deer-wmde wants to merge 30 commits into
mainfrom
de/msw-policies

Conversation

@deer-wmde

@deer-wmde deer-wmde commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Adds basic version of missing policy mock handlers for viewing the current policies.

  • GET /api/v1/policies/terms-of-use
  • GET /api/v1/policies/terms-of-use/by_active_from/2022-01-01
  • GET /api/v1/policies/terms-of-use/current
  • GET /api/v1/policies/terms-of-use/upcoming
  • GET /api/v1/policies/hosting-policy
  • GET /api/v1/policies/hosting-policy/current
  • GET /api/v1/policies/hosting-policy/upcoming

Note: due to the current implementation these will need to be adjusted when we add new (current/upcoming) policies. I'm not sure if a more dynamic implementation is worth it.

Compared with the current Platform API routes, I noticed in general the coverage of the mocks is not including these endpoints (which is probably fine? as they need different means of testing)

  • /api/v1/policy_acceptances - requires ability of mocking different data scenarios
  • /api/wiki/profile - could be implemented for a successful store response but re-implementing persistence is not currently needed

These Platform API endpoints aren't relevant for the UI:

  • /api/wiki/deletedWikiMetrics
  • /api/wikiConversionData
  • /api/reusePrototype

Bug: T436954

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deployment previews on netlify for branch refs/pull/1199/merge will be at the following locations (when build is done):

@deer-wmde
deer-wmde marked this pull request as ready for review September 4, 2026 14:36
@deer-wmde
deer-wmde changed the base branch from main to ui_msw_login September 4, 2026 15:24
@deer-wmde
deer-wmde changed the base branch from ui_msw_login to main September 4, 2026 15:26
dati18
dati18 previously requested changes Sep 9, 2026
Comment thread src/backend/mocks/default_handlers.js Outdated
}),

http.post('/api/user/sendVerifyEmail', () => {
return new Response('Already verified')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at api.js:45. Under MSW, that makes alreadyVerified always returns false because there is a "!" difference between 2 strings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That mismatch is outside this mock file, but it means fixing the mock alone would still leave a real API/UI contract bug.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the mocked messages here

And added a fix in this PR wbstack/api#1288

Comment thread src/backend/mocks/default_handlers.js
Comment thread src/backend/mocks/default_handlers.js
Comment thread src/backend/mocks/default_handlers.js
Comment thread src/backend/mocks/default_handlers.js
Comment thread src/backend/mocks/default_handlers.js
@outdooracorn outdooracorn changed the title msw: add policy mock handlers msw: add mock handlers for policy endpoints Oct 6, 2026

return Response.json({ items })
}),

@rosalieper rosalieper Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think It will be beneficial to add a comment here about these requiring an update every time there are new policies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call!

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