Skip to content

Commit 0441c78

Browse files
Merge pull request #54 from binarapps/fix/mocked-data-on-mobile
Fix mocked data on mobile
2 parents 0ecd638 + c430abd commit 0441c78

9 files changed

Lines changed: 37 additions & 35 deletions

File tree

App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { enableAndroidBackgroundNotificationListener, startMockedServer } from '
1111
import * as Device from 'expo-device'
1212
import 'expo-router/entry'
1313

14-
// FIXME: moking not working on mobile app - follow this discussion https://github.com/mswjs/msw/issues/2026
1514
const ENABLE_MOCKED_SERVER = false
1615

1716
if (ENABLE_MOCKED_SERVER) {

App.web.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import '@baca/i18n'
1010
import { startMockedServer } from '@baca/services'
1111
import 'expo-router/entry'
1212

13-
// FIXME: moking not working on mobile app - follow this discussion https://github.com/mswjs/msw/issues/2026
1413
const ENABLE_MOCKED_SERVER = false
1514

1615
if (ENABLE_MOCKED_SERVER) {

orval.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ export default defineConfig({
88
target: 'src/api/query/model.ts',
99
schemas: 'src/api/types',
1010
client: 'react-query',
11-
mock: true,
11+
// solution for not working mocked data on mobile - it removes automatically added "*" to address url at the beginning
12+
mock: {
13+
baseUrl: '',
14+
type: 'msw',
15+
},
1216
clean: true,
1317
prettier: true,
1418
override: {

src/api/query/articles/articles.msw.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export const getArticlesControllerUpdateResponseMock = (
149149
})
150150

151151
export const getArticlesControllerCreateMockHandler = (overrideResponse?: ArticleEntity) => {
152-
return http.post('*/api/v1/articles', async () => {
152+
return http.post('/api/v1/articles', async () => {
153153
await delay(1000)
154154
return new HttpResponse(
155155
JSON.stringify(
@@ -166,7 +166,7 @@ export const getArticlesControllerCreateMockHandler = (overrideResponse?: Articl
166166
}
167167

168168
export const getArticlesControllerFindAllMockHandler = (overrideResponse?: ArticleEntity[]) => {
169-
return http.get('*/api/v1/articles', async () => {
169+
return http.get('/api/v1/articles', async () => {
170170
await delay(1000)
171171
return new HttpResponse(
172172
JSON.stringify(
@@ -183,7 +183,7 @@ export const getArticlesControllerFindAllMockHandler = (overrideResponse?: Artic
183183
}
184184

185185
export const getArticlesControllerFindDraftsMockHandler = (overrideResponse?: ArticleEntity[]) => {
186-
return http.get('*/api/v1/articles/drafts', async () => {
186+
return http.get('/api/v1/articles/drafts', async () => {
187187
await delay(1000)
188188
return new HttpResponse(
189189
JSON.stringify(
@@ -200,7 +200,7 @@ export const getArticlesControllerFindDraftsMockHandler = (overrideResponse?: Ar
200200
}
201201

202202
export const getArticlesControllerFindOneMockHandler = (overrideResponse?: ArticleEntity) => {
203-
return http.get('*/api/v1/articles/:id', async () => {
203+
return http.get('/api/v1/articles/:id', async () => {
204204
await delay(1000)
205205
return new HttpResponse(
206206
JSON.stringify(
@@ -217,7 +217,7 @@ export const getArticlesControllerFindOneMockHandler = (overrideResponse?: Artic
217217
}
218218

219219
export const getArticlesControllerUpdateMockHandler = (overrideResponse?: ArticleEntity) => {
220-
return http.patch('*/api/v1/articles/:id', async () => {
220+
return http.patch('/api/v1/articles/:id', async () => {
221221
await delay(1000)
222222
return new HttpResponse(
223223
JSON.stringify(
@@ -234,7 +234,7 @@ export const getArticlesControllerUpdateMockHandler = (overrideResponse?: Articl
234234
}
235235

236236
export const getArticlesControllerRemoveMockHandler = () => {
237-
return http.delete('*/api/v1/articles/:id', async () => {
237+
return http.delete('/api/v1/articles/:id', async () => {
238238
await delay(1000)
239239
return new HttpResponse(null, {
240240
status: 200,

src/api/query/auth-social/auth-social.msw.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const getAuthAppleControllerLoginResponseMock = (
144144
})
145145

146146
export const getAuthGoogleControllerLoginMockHandler = (overrideResponse?: AuthEntity) => {
147-
return http.post('*/api/v1/auth/google/login', async () => {
147+
return http.post('/api/v1/auth/google/login', async () => {
148148
await delay(1000)
149149
return new HttpResponse(
150150
JSON.stringify(
@@ -161,7 +161,7 @@ export const getAuthGoogleControllerLoginMockHandler = (overrideResponse?: AuthE
161161
}
162162

163163
export const getAuthFacebookControllerLoginMockHandler = (overrideResponse?: AuthEntity) => {
164-
return http.post('*/api/v1/auth/facebook/login', async () => {
164+
return http.post('/api/v1/auth/facebook/login', async () => {
165165
await delay(1000)
166166
return new HttpResponse(
167167
JSON.stringify(
@@ -178,7 +178,7 @@ export const getAuthFacebookControllerLoginMockHandler = (overrideResponse?: Aut
178178
}
179179

180180
export const getAuthAppleControllerLoginMockHandler = (overrideResponse?: AuthEntity) => {
181-
return http.post('*/api/v1/auth/apple/login', async () => {
181+
return http.post('/api/v1/auth/apple/login', async () => {
182182
await delay(1000)
183183
return new HttpResponse(
184184
JSON.stringify(

src/api/query/auth/auth.msw.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const getAuthControllerRefreshResponseMock = (
135135
})
136136

137137
export const getAuthControllerLoginMockHandler = (overrideResponse?: AuthEntity) => {
138-
return http.post('*/api/v1/auth/email/login', async () => {
138+
return http.post('/api/v1/auth/email/login', async () => {
139139
await delay(1000)
140140
return new HttpResponse(
141141
JSON.stringify(overrideResponse ? overrideResponse : getAuthControllerLoginResponseMock()),
@@ -150,7 +150,7 @@ export const getAuthControllerLoginMockHandler = (overrideResponse?: AuthEntity)
150150
}
151151

152152
export const getAuthControllerRegisterMockHandler = (overrideResponse?: UserEntity) => {
153-
return http.post('*/api/v1/auth/email/register', async () => {
153+
return http.post('/api/v1/auth/email/register', async () => {
154154
await delay(1000)
155155
return new HttpResponse(
156156
JSON.stringify(overrideResponse ? overrideResponse : getAuthControllerRegisterResponseMock()),
@@ -165,7 +165,7 @@ export const getAuthControllerRegisterMockHandler = (overrideResponse?: UserEnti
165165
}
166166

167167
export const getAuthControllerConfirmEmailMockHandler = () => {
168-
return http.post('*/api/v1/auth/email/confirm', async () => {
168+
return http.post('/api/v1/auth/email/confirm', async () => {
169169
await delay(1000)
170170
return new HttpResponse(null, {
171171
status: 200,
@@ -177,7 +177,7 @@ export const getAuthControllerConfirmEmailMockHandler = () => {
177177
}
178178

179179
export const getAuthControllerResendVerificationEmailMockHandler = () => {
180-
return http.post('*/api/v1/auth/email/resend', async () => {
180+
return http.post('/api/v1/auth/email/resend', async () => {
181181
await delay(1000)
182182
return new HttpResponse(null, {
183183
status: 200,
@@ -189,7 +189,7 @@ export const getAuthControllerResendVerificationEmailMockHandler = () => {
189189
}
190190

191191
export const getAuthControllerForgotPasswordMockHandler = () => {
192-
return http.post('*/api/v1/auth/forgot/password', async () => {
192+
return http.post('/api/v1/auth/forgot/password', async () => {
193193
await delay(1000)
194194
return new HttpResponse(null, {
195195
status: 200,
@@ -201,7 +201,7 @@ export const getAuthControllerForgotPasswordMockHandler = () => {
201201
}
202202

203203
export const getAuthControllerResetPasswordMockHandler = () => {
204-
return http.post('*/api/v1/auth/reset/password', async () => {
204+
return http.post('/api/v1/auth/reset/password', async () => {
205205
await delay(1000)
206206
return new HttpResponse(null, {
207207
status: 200,
@@ -213,7 +213,7 @@ export const getAuthControllerResetPasswordMockHandler = () => {
213213
}
214214

215215
export const getAuthControllerEmailChangeMockHandler = () => {
216-
return http.post('*/api/v1/auth/email/change', async () => {
216+
return http.post('/api/v1/auth/email/change', async () => {
217217
await delay(1000)
218218
return new HttpResponse(null, {
219219
status: 200,
@@ -225,7 +225,7 @@ export const getAuthControllerEmailChangeMockHandler = () => {
225225
}
226226

227227
export const getAuthControllerConfirmEmailChangeMockHandler = () => {
228-
return http.post('*/api/v1/auth/email/change-confirm', async () => {
228+
return http.post('/api/v1/auth/email/change-confirm', async () => {
229229
await delay(1000)
230230
return new HttpResponse(null, {
231231
status: 200,
@@ -237,7 +237,7 @@ export const getAuthControllerConfirmEmailChangeMockHandler = () => {
237237
}
238238

239239
export const getAuthControllerMeMockHandler = (overrideResponse?: UserEntity) => {
240-
return http.get('*/api/v1/auth/me', async () => {
240+
return http.get('/api/v1/auth/me', async () => {
241241
await delay(1000)
242242
return new HttpResponse(
243243
JSON.stringify(overrideResponse ? overrideResponse : getAuthControllerMeResponseMock()),
@@ -252,7 +252,7 @@ export const getAuthControllerMeMockHandler = (overrideResponse?: UserEntity) =>
252252
}
253253

254254
export const getAuthControllerUpdateMockHandler = () => {
255-
return http.patch('*/api/v1/auth/me', async () => {
255+
return http.patch('/api/v1/auth/me', async () => {
256256
await delay(1000)
257257
return new HttpResponse(null, {
258258
status: 200,
@@ -264,7 +264,7 @@ export const getAuthControllerUpdateMockHandler = () => {
264264
}
265265

266266
export const getAuthControllerDeleteMockHandler = () => {
267-
return http.delete('*/api/v1/auth/me', async () => {
267+
return http.delete('/api/v1/auth/me', async () => {
268268
await delay(1000)
269269
return new HttpResponse(null, {
270270
status: 200,
@@ -276,7 +276,7 @@ export const getAuthControllerDeleteMockHandler = () => {
276276
}
277277

278278
export const getAuthControllerRefreshMockHandler = (overrideResponse?: RefreshEntity) => {
279-
return http.post('*/api/v1/auth/refresh', async () => {
279+
return http.post('/api/v1/auth/refresh', async () => {
280280
await delay(1000)
281281
return new HttpResponse(
282282
JSON.stringify(overrideResponse ? overrideResponse : getAuthControllerRefreshResponseMock()),
@@ -291,7 +291,7 @@ export const getAuthControllerRefreshMockHandler = (overrideResponse?: RefreshEn
291291
}
292292

293293
export const getAuthControllerLogoutMockHandler = () => {
294-
return http.post('*/api/v1/auth/logout', async () => {
294+
return http.post('/api/v1/auth/logout', async () => {
295295
await delay(1000)
296296
return new HttpResponse(null, {
297297
status: 200,
@@ -303,7 +303,7 @@ export const getAuthControllerLogoutMockHandler = () => {
303303
}
304304

305305
export const getAuthControllerLogoutAllMockHandler = () => {
306-
return http.post('*/api/v1/auth/logout/all', async () => {
306+
return http.post('/api/v1/auth/logout/all', async () => {
307307
await delay(1000)
308308
return new HttpResponse(null, {
309309
status: 200,

src/api/query/files/files.msw.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getFilesControllerUploadFileResponseMock = (
2626
})
2727

2828
export const getFilesControllerUploadFileMockHandler = (overrideResponse?: FileEntity) => {
29-
return http.post('*/api/v1/files/upload', async () => {
29+
return http.post('/api/v1/files/upload', async () => {
3030
await delay(1000)
3131
return new HttpResponse(
3232
JSON.stringify(
@@ -43,7 +43,7 @@ export const getFilesControllerUploadFileMockHandler = (overrideResponse?: FileE
4343
}
4444

4545
export const getFilesControllerDownloadMockHandler = () => {
46-
return http.get('*/api/v1/files/:fileName', async () => {
46+
return http.get('/api/v1/files/:fileName', async () => {
4747
await delay(1000)
4848
return new HttpResponse(null, {
4949
status: 200,
@@ -55,7 +55,7 @@ export const getFilesControllerDownloadMockHandler = () => {
5555
}
5656

5757
export const getFilesControllerDeleteFileMockHandler = () => {
58-
return http.delete('*/api/v1/files/:fileName', async () => {
58+
return http.delete('/api/v1/files/:fileName', async () => {
5959
await delay(1000)
6060
return new HttpResponse(null, {
6161
status: 200,

src/api/query/health/health.msw.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const getHealthControllerCheckResponseMock = (overrideResponse: any = {})
3030
})
3131

3232
export const getHealthControllerCheckMockHandler = (overrideResponse?: HealthEntity) => {
33-
return http.get('*/api/v1/health', async () => {
33+
return http.get('/api/v1/health', async () => {
3434
await delay(1000)
3535
return new HttpResponse(
3636
JSON.stringify(overrideResponse ? overrideResponse : getHealthControllerCheckResponseMock()),

src/api/query/users/users.msw.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export const getUsersControllerRemoveResponseMock = (overrideResponse: any = {})
193193
})
194194

195195
export const getUsersControllerCreateMockHandler = (overrideResponse?: UserEntity) => {
196-
return http.post('*/api/v1/users', async () => {
196+
return http.post('/api/v1/users', async () => {
197197
await delay(1000)
198198
return new HttpResponse(
199199
JSON.stringify(overrideResponse ? overrideResponse : getUsersControllerCreateResponseMock()),
@@ -208,7 +208,7 @@ export const getUsersControllerCreateMockHandler = (overrideResponse?: UserEntit
208208
}
209209

210210
export const getUsersControllerFindAllMockHandler = (overrideResponse?: UserEntity[]) => {
211-
return http.get('*/api/v1/users', async () => {
211+
return http.get('/api/v1/users', async () => {
212212
await delay(1000)
213213
return new HttpResponse(
214214
JSON.stringify(overrideResponse ? overrideResponse : getUsersControllerFindAllResponseMock()),
@@ -223,7 +223,7 @@ export const getUsersControllerFindAllMockHandler = (overrideResponse?: UserEnti
223223
}
224224

225225
export const getUsersControllerFindOneMockHandler = (overrideResponse?: UserEntity) => {
226-
return http.get('*/api/v1/users/:id', async () => {
226+
return http.get('/api/v1/users/:id', async () => {
227227
await delay(1000)
228228
return new HttpResponse(
229229
JSON.stringify(overrideResponse ? overrideResponse : getUsersControllerFindOneResponseMock()),
@@ -238,7 +238,7 @@ export const getUsersControllerFindOneMockHandler = (overrideResponse?: UserEnti
238238
}
239239

240240
export const getUsersControllerUpdateMockHandler = (overrideResponse?: UserEntity) => {
241-
return http.patch('*/api/v1/users/:id', async () => {
241+
return http.patch('/api/v1/users/:id', async () => {
242242
await delay(1000)
243243
return new HttpResponse(
244244
JSON.stringify(overrideResponse ? overrideResponse : getUsersControllerUpdateResponseMock()),
@@ -253,7 +253,7 @@ export const getUsersControllerUpdateMockHandler = (overrideResponse?: UserEntit
253253
}
254254

255255
export const getUsersControllerRemoveMockHandler = (overrideResponse?: UserEntity) => {
256-
return http.delete('*/api/v1/users/:id', async () => {
256+
return http.delete('/api/v1/users/:id', async () => {
257257
await delay(1000)
258258
return new HttpResponse(
259259
JSON.stringify(overrideResponse ? overrideResponse : getUsersControllerRemoveResponseMock()),

0 commit comments

Comments
 (0)