Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Nov 6, 2024
1 parent 0049f86 commit 8ba2354
Showing 1 changed file with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test.describe('network signals - fetch', () => {
indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn)
})

test('should not emit non-json requests', async () => {
test('should emit non-json requests but not include the data object', async () => {
await indexPage.network.mockTestRoute('http://localhost/upload', {
body: JSON.stringify({ foo: 'test' }),
})
Expand All @@ -26,10 +26,16 @@ test.describe('network signals - fetch', () => {
(el) => el.properties!.data.action === 'request'
)

expect(requests).toHaveLength(0)
expect(requests[0].properties!.data).toMatchObject({
action: 'request',
contentType: 'multipart/form-data',
data: null,
method: 'POST',
url: 'http://localhost/upload',
})
})

test('should try to parse the body of text/plain requests', async () => {
test('should try to parse the body of any requests with string in the body', async () => {
await indexPage.network.mockTestRoute('http://localhost/test', {
body: JSON.stringify({ foo: 'test' }),
contentType: 'application/json',
Expand Down Expand Up @@ -251,19 +257,4 @@ test.describe('network signals - fetch', () => {
expect(responses).toHaveLength(1)
})
})

test('not emit response errors if there is no corresponding request, even if correct content type', async () => {
await indexPage.network.mockTestRoute('http://localhost/test', {
body: JSON.stringify({ foo: 'test' }),
contentType: 'application/json',
status: 400,
})

await indexPage.network.makeFileUploadRequest('http://localhost/test')

await indexPage.waitForSignalsApiFlush()

const networkEvents = indexPage.signalsAPI.getEvents('network')
expect(networkEvents).toHaveLength(0)
})
})

0 comments on commit 8ba2354

Please sign in to comment.