-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge test changes to main - v0.33.0-pre.3ef8937 (#115)
Automatically created pull-request in order to merge changes that were recently pushed to the test branch, back to main
- Loading branch information
Showing
26 changed files
with
723 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/frontend/src/api/endpoints/blogging/blogging.msw.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
//@ts-nocheck | ||
import { faker } from '@faker-js/faker' | ||
import { HttpResponse, delay, http } from 'msw' | ||
|
||
export const getGetBlogsResponseMock = (): Blog[] => | ||
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
posts: faker.helpers.arrayElement([ | ||
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
})), | ||
undefined, | ||
]), | ||
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
})) | ||
|
||
export const getPostBlogResponseMock = (overrideResponse: Partial<Blog> = {}): Blog => ({ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
posts: faker.helpers.arrayElement([ | ||
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | ||
blog: faker.helpers.arrayElement([ | ||
{ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
posts: faker.helpers.arrayElement([[], undefined]), | ||
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
}, | ||
undefined, | ||
]), | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
})), | ||
undefined, | ||
]), | ||
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
...overrideResponse, | ||
}) | ||
|
||
export const getGetPostsResponseMock = (): Post[] => | ||
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | ||
blog: faker.helpers.arrayElement([ | ||
{ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
posts: faker.helpers.arrayElement([[], undefined]), | ||
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
}, | ||
undefined, | ||
]), | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
})) | ||
|
||
export const getPostPostResponseMock = (overrideResponse: Partial<Post> = {}): Post => ({ | ||
blog: faker.helpers.arrayElement([ | ||
{ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
posts: faker.helpers.arrayElement([ | ||
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
})), | ||
undefined, | ||
]), | ||
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
}, | ||
undefined, | ||
]), | ||
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]), | ||
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]), | ||
...overrideResponse, | ||
}) | ||
|
||
export const getGetBlogsMockHandler = () => { | ||
return http.get('*/Blogging/Blog', async () => { | ||
await delay(1000) | ||
return new HttpResponse(getGetBlogsResponseMock(), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
export const getPostBlogMockHandler = () => { | ||
return http.post('*/Blogging/Blog', async () => { | ||
await delay(1000) | ||
return new HttpResponse(getPostBlogResponseMock(), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
export const getGetPostsMockHandler = () => { | ||
return http.get('*/Blogging/Post', async () => { | ||
await delay(1000) | ||
return new HttpResponse(getGetPostsResponseMock(), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
export const getPostPostMockHandler = () => { | ||
return http.post('*/Blogging/Post', async () => { | ||
await delay(1000) | ||
return new HttpResponse(getPostPostResponseMock(), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
}, | ||
}) | ||
}) | ||
} | ||
export const getBloggingMock = () => [ | ||
getGetBlogsMockHandler(), | ||
getPostBlogMockHandler(), | ||
getGetPostsMockHandler(), | ||
getPostPostMockHandler(), | ||
] |
Oops, something went wrong.