Skip to content

Commit

Permalink
feat(ui): Response Panel > Tests > add indicator (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Oct 1, 2024
1 parent 68c528e commit 58dacbf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
16 changes: 13 additions & 3 deletions packages/ui/src/components/ResponsePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div class="response-panel-tabs">
<div class="response-panel-tab" :class="{ 'response-panel-tab-active': activeResponsePanelTab === responsePanelTab.name }" @click="activeResponsePanelTab = responsePanelTab.name" v-for="responsePanelTab in responsePanelTabs">
{{ responsePanelTab.label }}
<i :class="`fa fa-circle ${ allTestsPassed ? 'passed-tests' : 'failed-tests' }`" v-if="responsePanelTab.name === 'Tests' && response.testResults && response.testResults.length > 0" style="margin-left: 0.2rem"></i>
</div>
<div class="response-panel-tab-fill"></div>
<div class="response-panel-tab-actions">
Expand Down Expand Up @@ -238,7 +239,7 @@ export default {
})
}
if(this.response && 'testResults' in this.response) {
if(this.isTestResultsAvailable) {
const tab = {
name: 'Tests',
label: 'Tests'
Expand Down Expand Up @@ -397,12 +398,21 @@ export default {
return getResponseContentType(this.response)
},
passedTestCases() {
if(this.response && 'testResults' in this.response) {
if(this.isTestResultsAvailable) {
return this.response.testResults.filter(item => item.passed).length
}
return 0
}
},
allTestsPassed() {
if(this.isTestResultsAvailable) {
return this.response.testResults.length === this.passedTestCases
}
return false
},
isTestResultsAvailable() {
return this.response && 'testResults' in this.response
},
},
watch: {
response() {
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,13 @@ select {
color: rgba(76, 237, 39, 0.65);
font-size: 0.6rem !important;
}

.passed-tests {
color: rgba(76, 237, 39, 0.65);
font-size: 0.6rem !important;
}

.failed-tests {
color: rgb(237, 39, 39);
font-size: 0.6rem !important;
}
4 changes: 2 additions & 2 deletions packages/ui/tests/App_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ Scenario('Send GET request', async() => {
I.createRequest('Request 1')
I.typeInRequestPanelAddressBar(`${host}${path}${queryString}`)
I.click('[data-testid="request-panel-address-bar__send-button"]')
I.waitForElement('//*[@class="response-panel-tab"][text() = "Timeline"]')
I.click('//*[@class="response-panel-tab"][text() = "Timeline"]')
I.waitForElement('//*[@class="response-panel-tab"][text() = "Timeline "]')
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}`)
Expand Down

0 comments on commit 58dacbf

Please sign in to comment.