From 848c0c134b7484c4c5dc4442742acad8b6ce9157 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 17 May 2024 10:50:04 +0200 Subject: [PATCH] fix: missing querystring --- packages/ui/src/components/RequestPanel.vue | 2 +- .../ui/src/components/ResponsePanelTimeline.vue | 8 ++++---- packages/ui/src/helpers.ts | 5 +++-- packages/ui/tests/App_test.ts | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/components/RequestPanel.vue b/packages/ui/src/components/RequestPanel.vue index 0b465b16..584eafee 100644 --- a/packages/ui/src/components/RequestPanel.vue +++ b/packages/ui/src/components/RequestPanel.vue @@ -25,7 +25,7 @@ data-testid="request-panel-address-bar" /> - +
diff --git a/packages/ui/src/components/ResponsePanelTimeline.vue b/packages/ui/src/components/ResponsePanelTimeline.vue index 05cd7d48..c0e7fa97 100644 --- a/packages/ui/src/components/ResponsePanelTimeline.vue +++ b/packages/ui/src/components/ResponsePanelTimeline.vue @@ -1,7 +1,7 @@ @@ -23,10 +23,10 @@ export default { }, methods: { timelineViewer(response) { - const preparationInfo = `* Preparing request to ${response.url}\n* Current time is ${new Date(dateFormat(response.createdAt, true)).toISOString()}\n` - const uriInfo = uriParse(response.url) + const preparationInfo = `* Preparing request to ${response.request.original.url}\n* Current time is ${new Date(dateFormat(response.createdAt, true)).toISOString()}\n` + const uriInfo = uriParse(response.request.original.url) - let requestInfo = `> ${response.request.method} ${uriInfo.pathname}\n> Host: ${uriInfo.host}\n` + let requestInfo = `> ${response.request.method} ${uriInfo.search !== '' ? uriInfo.pathname + uriInfo.search : uriInfo.pathname}\n> Host: ${uriInfo.host}\n` for (const [key, value] of Object.entries(response.request.headers)) { if (key && value) { diff --git a/packages/ui/src/helpers.ts b/packages/ui/src/helpers.ts index 3beb860a..958dbde3 100644 --- a/packages/ui/src/helpers.ts +++ b/packages/ui/src/helpers.ts @@ -1620,9 +1620,10 @@ export function uriParse(urlString: string): { port: string | null; pathname: string | null; hash: string | null; + search: string | null; } { - const { protocol, host, port, pathname, hash} = new URL(urlString) - return { protocol, host, port, pathname, hash } + const { protocol, host, port, pathname, hash, search} = new URL(urlString) + return { protocol, host, port, pathname, hash, search } } export function getStatusText(statusCode: number): string { diff --git a/packages/ui/tests/App_test.ts b/packages/ui/tests/App_test.ts index f82b3fd5..1c5c4849 100644 --- a/packages/ui/tests/App_test.ts +++ b/packages/ui/tests/App_test.ts @@ -53,3 +53,17 @@ Scenario('type url with query params', async() => { text = await I.grabTextFrom(queryTab) I.expectEqual(text.trim(), 'Query') }) + +Scenario('Send GET request', async() => { + const host = 'https://httpbin.org' + const path = '/get' + const queryString = '?hello=there' + + I.createRequest('Request 1') + I.typeInRequestPanelAddressBar(`${host}${path}${queryString}`) + I.click('[data-testid="request-panel-address-bar__send-button"]') + I.click('//*[@class="response-panel-tab"][text() = "Timeline"]') + const text = await I.grabTextFrom('[data-testid="response-panel-tab-Timeline__preview"]') + I.expectContain(text, `* Preparing request to ${host}${path}${queryString}`) + I.expectContain(text, `GET ${path}${queryString}`) +})