Skip to content

Commit

Permalink
fix: missing querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed May 17, 2024
1 parent c46f975 commit 848c0c1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/RequestPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
data-testid="request-panel-address-bar"
/>
</div>
<button @click="sendRequest">Send</button>
<button @click="sendRequest" data-testid="request-panel-address-bar__send-button">Send</button>
</div>
<div class="request-panel-tabs" v-show="tabView === 'full'">
<div class="request-panel-tab" :class="{ 'request-panel-tab-active': activeRequestPanelTab === requestPanelTab.name }" @click="activeRequestPanelTab = requestPanelTab.name" v-for="requestPanelTab in requestPanelTabs" :data-testid="`request-panel-tab-${requestPanelTab.name}`">
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/src/components/ResponsePanelTimeline.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div>
<CodeMirrorResponsePanelPreview :model-value="timelineViewer(response)"></CodeMirrorResponsePanelPreview>
<CodeMirrorResponsePanelPreview :model-value="timelineViewer(response)" data-testid="response-panel-tab-Timeline__preview"></CodeMirrorResponsePanelPreview>
</div>
</div>
</template>
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions packages/ui/tests/App_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
})

0 comments on commit 848c0c1

Please sign in to comment.