Skip to content

MSW: migrate login handlers - #1184

Open
deer-wmde wants to merge 9 commits into
mainfrom
ui_msw_login
Open

MSW: migrate login handlers#1184
deer-wmde wants to merge 9 commits into
mainfrom
ui_msw_login

Conversation

@deer-wmde

@deer-wmde deer-wmde commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

continuation of #1114

contains some fixes to the prior work and adjustments to the current codebase


This patch starts the migration from the broken 1.x MSW configuration to a 2.x one.

It adjusts our browser mocks to use the new msw/browser using the Fetch API (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

In the new handlers it moves over just login functionality as well as the querying for user wikis and missing policies, leaving the remaining handler migration to future work.

Co-authored-by: rosalieper 15235452+rosalieper@users.noreply.github.com
Co-authored-by: outdooracorn 43674967+outdooracorn@users.noreply.github.com
Co-authored-by: tarrow 7353563+tarrow@users.noreply.github.com

https://phabricator.wikimedia.org/T436360

@github-actions

Copy link
Copy Markdown

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

@dati18 dati18 left a comment

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 you did a good job on this. But I want to point out a few inconsistencies (a bit nitpicking)

MSW v2 has HttpResponse helpers, and I believe it was designed around them. For example:

  • HttpResponse.json()
  • new HttpResponse(null, { status: 204 })

Official v2 doc: https://mswjs.io/docs/api/http

Comment thread src/backend/mocks/default_handlers.js
Comment thread src/backend/mocks/default_handlers.js Outdated
Comment thread src/backend/mocks/default_handlers.js
@deer-wmde

Copy link
Copy Markdown
Contributor Author

I think you did a good job on this. But I want to point out a few inconsistencies (a bit nitpicking)

MSW v2 has HttpResponse helpers, and I believe it was designed around them. For example:

* `HttpResponse.json()`

* `new HttpResponse(null, { status: 204 })`

Official v2 doc: https://mswjs.io/docs/api/http

Thanks! Yes, I'm aware of the msw's HttpResponse - I went with the Response the standard API implementation (docs) because I didn't see much worth yet of using theirs: currently the docs mention mostly cookie response mocking (which I think we are still able to do as seen in this PR) and some shorthand methods. Given this refactoring was mostly needed because previously they used some custom implementation I thought it'd be a good call to stick to standards as close as possible, even if their extension is minimal so far and they pinky promise that it stays that way. Still I could be convinced to use it instead if devs prefer it. Good thing to bring up, thanks!

@deer-wmde
deer-wmde requested a review from dati18 September 8, 2026 04:53

@rosalieper rosalieper left a comment

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.

Looks good to me !!!

Comment thread src/backend/mocks/default_handlers.js
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