From 3007e3b9a7ca58e2b05fea593287d5f7928055fd Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 1 Sep 2026 14:51:43 +0200 Subject: [PATCH 01/15] add verify email handlers --- src/backend/mocks/default_handlers.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index c0d1f2a8..ba4bee11 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -53,6 +53,14 @@ export const handlers = [ return new Response('Success') }), + http.post('/api/user/sendVerifyEmail', () => { + return new Response('Already verified') + }), + + http.post('/api/user/verifyEmail', () => { + return new Response('Already verified') + }), + http.post('/api/wiki/mine', () => { const data = { wikis: myWikis, count: myWikis.length, limit: false } return Response.json(data) From f6cc55798776d5a4e7a8eeebb03d030f329be534 Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 1 Sep 2026 15:46:49 +0200 Subject: [PATCH 02/15] add complaint and contact message handlers --- src/backend/mocks/default_handlers.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index ba4bee11..da77ce59 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -61,6 +61,20 @@ export const handlers = [ return new Response('Already verified') }), + http.post('/api/complaint/sendMessage', () => { + return new Response('Success') + }), + + http.post('/api/contact/sendMessage', async ({ request }) => { + const body = await request.json() + + if (body.name == '' || body.message == '' || body.subject == '') { + return new Response(null, { status: 400 }) + } + + return new Response('Success') + }), + http.post('/api/wiki/mine', () => { const data = { wikis: myWikis, count: myWikis.length, limit: false } return Response.json(data) From 6c7d012af703a3de97104989ef819956b9cc4444 Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 1 Sep 2026 17:31:59 +0200 Subject: [PATCH 03/15] migrate remaining old handlers --- src/backend/mocks/default_handlers.js | 181 ++++++++++++++++- src/backend/mocks/old.default_handlers.js | 226 ---------------------- 2 files changed, 180 insertions(+), 227 deletions(-) delete mode 100644 src/backend/mocks/old.default_handlers.js diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index da77ce59..3022a37e 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -4,7 +4,10 @@ import { http } from 'msw' // see old.default_handlers.js for reference // this note can get removed after migration -const myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] +let myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] +let lastWikiId = (myWikis.length && myWikis[myWikis.length - 1].id) || 0 +const user = makeUser() +let getEntityImportCalledTimes = 0 function makeUser (email = 'test@local') { return { @@ -16,6 +19,121 @@ function makeUser (email = 'test@local') { } } +const makeNewWiki = ({ domain, sitename }) => { + const newWiki = { + id: ++lastWikiId, + domain, + sitename, + deleted_at: null, + created_at: '2020-01-01', + updated_at: '2020-01-01', + pivot: { + user_id: user.id, + wiki_id: lastWikiId, + }, + wiki_managers: [{ + email: user.email, + pivot: { + user_id: user.id, + wiki_id: lastWikiId, + }, + }], + wiki_db_version: { + id: 101, + wiki_id: lastWikiId, + version: 'mw1.33-wbs1', + }, + public_settings: [], + } + + myWikis.push(newWiki) + localStorage.setItem('msw-myWikis', JSON.stringify(myWikis)) + + return newWiki +} + +const removeWiki = wikiIndex => { + myWikis = myWikis.splice(wikiIndex, 1) + localStorage.setItem('msw-myWikis', JSON.stringify(myWikis)) +} + +const wikiDiscovery = (referrer, params) => { + const pseudorandom = { + seed: 1, + next: function () { + const x = Math.sin(this.seed++) * 10000 + return x - Math.floor(x) + }, + } + + const names = [ + 'Wikibase Name', + 'A Very Long Wikibase Name', + ] + + let wikis = [...Array(75).keys()].map((id) => { + const wiki = { + id, + domain: id + '-wikibase.wbaas.localhost', + sitename: id + ' - ' + names[id % names.length], + wiki_site_stats: null, + logo_url: null, + } + + if (pseudorandom.next() >= 0.1) { + wiki.wiki_site_stats = { + pages: Math.ceil(pseudorandom.next() * 250), + } + } + + if (pseudorandom.next() >= 0.5) { + wiki.logo_url = new URL(referrer).origin + '/favicon.ico' + } + return wiki + }) + + if (parseInt(params.get('is_active'))) { + wikis = wikis.filter((wiki) => { + const stats = wiki.wiki_site_stats + return stats && stats.pages > 1 + }) + } + + if (params.get('sort') === 'sitename') { + wikis = wikis.sort((a, b) => { + let sort = a.sitename.localeCompare(b.sitename, 'en', { numeric: true }) + if (params.get('direction') === 'desc') { + sort *= -1 + } + return sort + }) + } + + if (params.get('sort') === 'pages') { + wikis = wikis.sort((a, b) => { + const aPages = a.wiki_site_stats ? a.wiki_site_stats.pages : 0 + const bPages = b.wiki_site_stats ? b.wiki_site_stats.pages : 0 + if (params.get('direction') === 'desc') { + return bPages - aPages + } + return aPages - bPages + }) + } + + const currentPage = parseInt(params.get('page')) + const resultsPerPage = parseInt(params.get('per_page')) + const start = (currentPage - 1) * resultsPerPage + const end = start + resultsPerPage + + return { + data: wikis.slice(start, end), + meta: { + last_page: Math.ceil(wikis.length / resultsPerPage), + total: wikis.length, + }, + } +} + export const handlers = [ http.get('/api/auth/login', ({ cookies }) => { const { authToken } = cookies @@ -80,6 +198,67 @@ export const handlers = [ return Response.json(data) }), + http.post('/api/wiki/entityImport', () => { + const data = { status: 'pending', payload: {}, started_at: new Date().toJSON() }; + return Response.json(data) + }), + + http.get('/api/wiki/entityImport', () => { + getEntityImportCalledTimes++ + switch (getEntityImportCalledTimes) { + case 1: + return Response.json([]) + case 2: + return Response.json([{ status: 'pending' }]) + default: + return Response.json([{status: 'success'}]) + } + }), + + http.post('/api/wiki/create', async ({ request }) => { + const body = await request.json() + const data = makeNewWiki(body) + return Response.json(data) + }), + + http.post('/api/wiki/delete', async ({ request }) => { + const wikiId = await request.json().wiki + const wikiIndex = myWikis.findIndex(w => w.id === Number(wikiId)) + + if (wikiIndex < 0) { + return new Response(null, {status: 404}) + } + + removeWiki(wikiIndex) + return new Response('Success') + }), + + http.post('/api/wiki/logo/update', () => { + return new Response('Success') + }), + + http.post(/\/api\/wiki\/setting\/.*?\/update$/, () => { + return new Response('Success') + }), + + http.post('/api/wiki/details', async ({ request }) => { + const wikiId = await request.json().wiki + const wikiDetails = myWikis.find(w => w.id === Number(wikiId)) + + if (!wikiDetails) { + return new Response(null, {status: 404}) + } + + return Response.json(wikiDetails) + }), + + http.get('/api/wiki', async ({ request }) => { + const referrer = await request.referrer + const url = new URL(await request.url) + + return Response.json(wikiDiscovery(referrer, url.searchParams)) + }), + http.get('/api/v1/policies/missing', () => { const items = [] return Response.json({ items }) diff --git a/src/backend/mocks/old.default_handlers.js b/src/backend/mocks/old.default_handlers.js deleted file mode 100644 index 42278322..00000000 --- a/src/backend/mocks/old.default_handlers.js +++ /dev/null @@ -1,226 +0,0 @@ -// this file exists only as reference until all -// legacy handlers are migrated to default_handlers.js - -import { rest } from 'msw' - -let myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] -let lastWikiId = (myWikis.length && myWikis[myWikis.length - 1].id) || 0 -let user = makeUser() -let getEntityImportCalledTimes = 0 - -function makeUser (email = 'test@local') { - return { - id: 1, - email, - verified: true, - created_at: '2020-01-01', - updated_at: '2020-01-01', - } -} - -const makeNewWiki = ({ domain, sitename }) => { - const newWiki = { - id: ++lastWikiId, - domain, - sitename, - deleted_at: null, - created_at: '2020-01-01', - updated_at: '2020-01-01', - pivot: { - user_id: user.id, - wiki_id: lastWikiId, - }, - wiki_managers: [{ - email: user.email, - pivot: { - user_id: user.id, - wiki_id: lastWikiId, - }, - }], - wiki_db_version: { - id: 101, - wiki_id: lastWikiId, - version: 'mw1.33-wbs1', - }, - public_settings: [], - } - - myWikis.push(newWiki) - localStorage.setItem('msw-myWikis', JSON.stringify(myWikis)) - - return newWiki -} - -const removeWiki = wikiIndex => { - myWikis = myWikis.splice(wikiIndex, 1) - localStorage.setItem('msw-myWikis', JSON.stringify(myWikis)) -} - -const wikiDiscovery = (referrer, params) => { - const pseudorandom = { - seed: 1, - next: function () { - const x = Math.sin(this.seed++) * 10000 - return x - Math.floor(x) - }, - } - - const names = [ - 'Wikibase Name', - 'A Very Long Wikibase Name', - ] - - let wikis = [...Array(75).keys()].map((id) => { - const wiki = { - id, - domain: id + '-wikibase.wbaas.localhost', - sitename: id + ' - ' + names[id % names.length], - wiki_site_stats: null, - logo_url: null, - } - - if (pseudorandom.next() >= 0.1) { - wiki.wiki_site_stats = { - pages: Math.ceil(pseudorandom.next() * 250), - } - } - - if (pseudorandom.next() >= 0.5) { - wiki.logo_url = new URL(referrer).origin + '/favicon.ico' - } - return wiki - }) - - if (parseInt(params.get('is_active'))) { - wikis = wikis.filter((wiki) => { - const stats = wiki.wiki_site_stats - return stats && stats.pages > 1 - }) - } - - if (params.get('sort') === 'sitename') { - wikis = wikis.sort((a, b) => { - let sort = a.sitename.localeCompare(b.sitename, 'en', { numeric: true }) - if (params.get('direction') === 'desc') { - sort *= -1 - } - return sort - }) - } - - if (params.get('sort') === 'pages') { - wikis = wikis.sort((a, b) => { - const aPages = a.wiki_site_stats ? a.wiki_site_stats.pages : 0 - const bPages = b.wiki_site_stats ? b.wiki_site_stats.pages : 0 - if (params.get('direction') === 'desc') { - return bPages - aPages - } - return aPages - bPages - }) - } - - const currentPage = parseInt(params.get('page')) - const resultsPerPage = parseInt(params.get('per_page')) - const start = (currentPage - 1) * resultsPerPage - const end = start + resultsPerPage - - return { - data: wikis.slice(start, end), - meta: { - last_page: Math.ceil(wikis.length / resultsPerPage), - total: wikis.length, - }, - } -} - -export const handlers = [ - /* User endpoints */ - rest.post(/\/api\/auth\/login$/, (req, res, ctx) => { - user = makeUser(req.body.email) - return res(ctx.json({ - user, - }), ctx.cookie('authToken', 'token_value')) - }), - rest.get(/\/api\/auth\/login$/, (req, res, ctx) => { - const { authToken } = req.cookies - if (authToken !== 'token_value') { - return res(ctx.status(401)) - } - user = makeUser(req.body.email) - return res(ctx.json({ - user, - })) - }), - rest.delete(/\/api\/auth\/login$/, (req, res, ctx) => { - user = makeUser(req.body.email) - return res(ctx.status(204)) - }), - rest.post(/\/api\/user\/forgotPassword$/, (req, res, ctx) => { - if (req.body.email === 'serverError@example.com') { - return res(ctx.status(400, 'Mocked Server Error')) - } - return res(ctx.status(200)) - }, - ), - rest.post(/\/api\/user\/resetPassword$/, (_, res, ctx) => res(ctx.status(200))), - rest.post(/\/api\/user\/sendVerifyEmail$/, (_, res, ctx) => res(ctx.json({ message: 'Already verified' }))), - rest.post(/\/api\/user\/verifyEmail$/, (_, res, ctx) => res(ctx.status(200))), - rest.post(/\/api\/complaint\/sendMessage$/, (req, res, ctx) => res(ctx.status(200))), - rest.post(/\/api\/contact\/sendMessage$/, (req, res, ctx) => { - if (req.body.name === 'recaptchaError') { - return res(ctx.status(401, 'Mocked recaptcha Error')) - } - if (req.body.name === '') { - return res(ctx.status(400, 'Mocked empty name Error')) - } - if (req.body.recaptcha === '') { - return res(ctx.status(400, 'Mocked recaptcha empty Error')) - } - return res(ctx.status(200)) - }, - ), - - /* Wiki endpoints */ - rest.post(/\/api\/wiki\/entityImport$/, (_, res, ctx) => { - return res(ctx.json({ data: { status: 'pending', payload: {}, started_at: new Date().toJSON() } })) - }), - rest.get(/\/api\/wiki\/entityImport$/, (_, res, ctx) => { - getEntityImportCalledTimes++ - switch (getEntityImportCalledTimes) { - case 1: - return res(ctx.json({ data: [] })) - case 2: - return res(ctx.json({ data: [{ status: 'pending' }] })) - default: - return res(ctx.json({ data: [{ status: 'success' }] })) - } - }), - rest.get(/\/api\/wiki\/count$/, (_, res, ctx) => res(ctx.json({ data: 1 }))), - rest.post(/\/api\/wiki\/mine$/, (_, res, ctx) => res(ctx.json({ wikis: myWikis, count: myWikis.length, limit: false }))), - rest.post(/\/api\/wiki\/create$/, (req, res, ctx) => { - return res(ctx.json({ data: makeNewWiki(req.body) })) - }), - rest.post(/\/api\/wiki\/delete$/, (req, res, ctx) => { - const wikiId = req.body.wiki - const wikiIndex = myWikis.findIndex(w => w.id === Number(wikiId)) - if (wikiIndex < 0) { - return res(ctx.status(404)) - } - - removeWiki(wikiIndex) - return res(ctx.status(200)) - }), - rest.post(/\/api\/wiki\/logo\/update$/, (_, res, ctx) => res(ctx.status(200))), - rest.post(/\/api\/wiki\/setting\/.*?\/update$/, (_, res, ctx) => res(ctx.status(200))), - rest.post(/\/api\/wiki\/details$/, (req, res, ctx) => { - const wikiId = req.body.wiki - const wikiDetails = myWikis.find(w => w.id === Number(wikiId)) - if (!wikiDetails) { - return res(ctx.status(404)) - } - return res(ctx.json({ data: wikiDetails }), ctx.status(200)) - }), - rest.get(/\/api\/wiki$/, (req, res, ctx) => { - return res(ctx.json(wikiDiscovery(req.referrer, req.url.searchParams))) - }), -] From 2adcc966c62bdfeed74d295b20d800c25c823325 Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 1 Sep 2026 17:34:27 +0200 Subject: [PATCH 04/15] formatting --- src/backend/mocks/default_handlers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 3022a37e..095c63f0 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -199,7 +199,7 @@ export const handlers = [ }), http.post('/api/wiki/entityImport', () => { - const data = { status: 'pending', payload: {}, started_at: new Date().toJSON() }; + const data = { status: 'pending', payload: {}, started_at: new Date().toJSON() } return Response.json(data) }), @@ -211,7 +211,7 @@ export const handlers = [ case 2: return Response.json([{ status: 'pending' }]) default: - return Response.json([{status: 'success'}]) + return Response.json([{ status: 'success' }]) } }), @@ -226,7 +226,7 @@ export const handlers = [ const wikiIndex = myWikis.findIndex(w => w.id === Number(wikiId)) if (wikiIndex < 0) { - return new Response(null, {status: 404}) + return new Response(null, { status: 404 }) } removeWiki(wikiIndex) @@ -246,9 +246,9 @@ export const handlers = [ const wikiDetails = myWikis.find(w => w.id === Number(wikiId)) if (!wikiDetails) { - return new Response(null, {status: 404}) + return new Response(null, { status: 404 }) } - + return Response.json(wikiDetails) }), From 85d99224e6f28b15728fea44c240060e0d8c9ef2 Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 1 Sep 2026 17:44:11 +0200 Subject: [PATCH 05/15] fix obj access --- src/backend/mocks/default_handlers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 095c63f0..bec32e86 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -222,7 +222,8 @@ export const handlers = [ }), http.post('/api/wiki/delete', async ({ request }) => { - const wikiId = await request.json().wiki + const body = await request.json() + const wikiId = body.wiki const wikiIndex = myWikis.findIndex(w => w.id === Number(wikiId)) if (wikiIndex < 0) { @@ -242,7 +243,8 @@ export const handlers = [ }), http.post('/api/wiki/details', async ({ request }) => { - const wikiId = await request.json().wiki + const body = await request.json() + const wikiId = body.wiki const wikiDetails = myWikis.find(w => w.id === Number(wikiId)) if (!wikiDetails) { From 408ab20a8081cf691a322e125ce34d2f4fb09e7e Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 12:11:01 +0200 Subject: [PATCH 06/15] fix wiki details response --- src/backend/mocks/default_handlers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index bec32e86..f926fe6c 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -251,7 +251,10 @@ export const handlers = [ return new Response(null, { status: 404 }) } - return Response.json(wikiDetails) + return Response.json({ + success: true, + data: wikiDetails, + }) }), http.get('/api/wiki', async ({ request }) => { From afb68be1c78420da716d3e42def942010b5c233c Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 13:41:51 +0200 Subject: [PATCH 07/15] strcit type checks --- src/backend/mocks/default_handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index f926fe6c..5ab6048a 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -186,7 +186,7 @@ export const handlers = [ http.post('/api/contact/sendMessage', async ({ request }) => { const body = await request.json() - if (body.name == '' || body.message == '' || body.subject == '') { + if (body.name === '' || body.message === '' || body.subject === '') { return new Response(null, { status: 400 }) } From 51a1dad3686c57390214d094cba4179b5ab685a2 Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 14:03:57 +0200 Subject: [PATCH 08/15] fix create wiki response --- src/backend/mocks/default_handlers.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 5ab6048a..c53029ba 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -217,8 +217,11 @@ export const handlers = [ http.post('/api/wiki/create', async ({ request }) => { const body = await request.json() - const data = makeNewWiki(body) - return Response.json(data) + const newWiki = makeNewWiki(body) + return Response.json({ + success: true, + data: newWiki, + }) }), http.post('/api/wiki/delete', async ({ request }) => { From 33664f4d38eb7ccaeb50fdc887a20d7dd045a88f Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 16:51:37 +0200 Subject: [PATCH 09/15] add handler for current policy --- src/backend/mocks/default_handlers.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index c53029ba..680f32f8 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -271,4 +271,27 @@ export const handlers = [ const items = [] return Response.json({ items }) }), + + http.get('/api/v1/policies/current', () => { + const items = [ + { + metadata: { + policy_id: 2, + type: 'terms-of-use', + active_from: '2026-08-27', + content_vue_file: 'terms-of-use/version-2.vue', + }, + }, + { + metadata: { + policy_id: 3, + type: 'hosting-policy', + active_from: '2026-08-27', + content_vue_file: 'hosting-policy/version-1.vue', + }, + }, + ] + + return Response.json({ items }) + }), ] From 1c5cf6092bd9e537c4077b7d6955b31b86ebf34b Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 16:51:48 +0200 Subject: [PATCH 10/15] disable mock bypass --- src/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 412fcb7d..09f46070 100644 --- a/src/main.js +++ b/src/main.js @@ -18,7 +18,8 @@ async function enableMocking () { // `worker.start()` returns a Promise that resolves // once the Service Worker is up and ready to intercept requests. - return worker.start() + // onUnhandledRequest: 'error' saves us from a false belief that mocks are working when they aren't + return worker.start({ onUnhandledRequest: 'error' }) } } From f33c8537a4b2062203bcf68b701154bc873ebd90 Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 17:34:32 +0200 Subject: [PATCH 11/15] fix removeWiki --- src/backend/mocks/default_handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 680f32f8..837f66cc 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -53,7 +53,7 @@ const makeNewWiki = ({ domain, sitename }) => { } const removeWiki = wikiIndex => { - myWikis = myWikis.splice(wikiIndex, 1) + myWikis.splice(wikiIndex, 1) localStorage.setItem('msw-myWikis', JSON.stringify(myWikis)) } From a65b6a912d043d3f88d9036b4227bb81896c88c7 Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 17:35:22 +0200 Subject: [PATCH 12/15] fix user --- src/backend/mocks/default_handlers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 837f66cc..c20493b1 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -6,7 +6,7 @@ import { http } from 'msw' let myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] let lastWikiId = (myWikis.length && myWikis[myWikis.length - 1].id) || 0 -const user = makeUser() +let user = makeUser() let getEntityImportCalledTimes = 0 function makeUser (email = 'test@local') { @@ -143,13 +143,13 @@ export const handlers = [ }) } - const user = makeUser() + user = makeUser() return Response.json({ user }) }), http.post('/api/auth/login', async ({ request }) => { const body = await request.json() - const user = makeUser(body.email) + user = makeUser(body.email) return Response.json({ user }, { headers: { 'set-cookie': 'authToken=token_value' }, From 8d52c7da3305bfd1c62940dd6ce40fd4037d7aec Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 17:38:12 +0200 Subject: [PATCH 13/15] fix entityimport handler --- src/backend/mocks/default_handlers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index c20493b1..88cdd97c 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -207,11 +207,11 @@ export const handlers = [ getEntityImportCalledTimes++ switch (getEntityImportCalledTimes) { case 1: - return Response.json([]) + return Response.json({ data: [] }) case 2: - return Response.json([{ status: 'pending' }]) + return Response.json({ data: [{ status: 'pending' }] }) default: - return Response.json([{ status: 'success' }]) + return Response.json({data: [{ status: 'success' }] }) } }), From 82be549b7a98acb40f0d3a348fecaf72781e6e32 Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 17:42:20 +0200 Subject: [PATCH 14/15] formatting --- src/backend/mocks/default_handlers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index 88cdd97c..d9f5cd2c 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -4,7 +4,7 @@ import { http } from 'msw' // see old.default_handlers.js for reference // this note can get removed after migration -let myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] +const myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] let lastWikiId = (myWikis.length && myWikis[myWikis.length - 1].id) || 0 let user = makeUser() let getEntityImportCalledTimes = 0 @@ -211,7 +211,7 @@ export const handlers = [ case 2: return Response.json({ data: [{ status: 'pending' }] }) default: - return Response.json({data: [{ status: 'success' }] }) + return Response.json({ data: [{ status: 'success' }] }) } }), From 55653143f1dc6cc7487c7843601457d205c59a60 Mon Sep 17 00:00:00 2001 From: dena Date: Thu, 3 Sep 2026 17:42:51 +0200 Subject: [PATCH 15/15] remove obsolete note --- src/backend/mocks/default_handlers.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/backend/mocks/default_handlers.js b/src/backend/mocks/default_handlers.js index d9f5cd2c..01ad49c9 100644 --- a/src/backend/mocks/default_handlers.js +++ b/src/backend/mocks/default_handlers.js @@ -1,9 +1,5 @@ import { http } from 'msw' -// implementations for msw v2 handlers go in this file -// see old.default_handlers.js for reference -// this note can get removed after migration - const myWikis = JSON.parse(localStorage.getItem('msw-myWikis')) || [] let lastWikiId = (myWikis.length && myWikis[myWikis.length - 1].id) || 0 let user = makeUser()