fix: 修复未对无数据情况做处理,导致单侧实例报错的问题
This commit is contained in:
@@ -148,6 +148,10 @@ export default {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.showError = false
|
this.showError = false
|
||||||
this.isNoData = res.data.result.length === 0
|
this.isNoData = res.data.result.length === 0
|
||||||
|
if (this.isNoData) {
|
||||||
|
this.linkTrafficListData = {}
|
||||||
|
this.linkTrafficListData.npmScore = '-'
|
||||||
|
} else {
|
||||||
const data = {
|
const data = {
|
||||||
establishLatencyMs: _.get(res.data.result[0], 'establishLatencyMs', null),
|
establishLatencyMs: _.get(res.data.result[0], 'establishLatencyMs', null),
|
||||||
httpResponseLatency: _.get(res.data.result[0], 'httpResponseLatency', null),
|
httpResponseLatency: _.get(res.data.result[0], 'httpResponseLatency', null),
|
||||||
@@ -157,6 +161,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.linkTrafficListData = res.data.result[0]
|
this.linkTrafficListData = res.data.result[0]
|
||||||
this.linkTrafficListData.npmScore = computeScore(data)
|
this.linkTrafficListData.npmScore = computeScore(data)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.showError = true
|
this.showError = true
|
||||||
this.errorMsg = res.message
|
this.errorMsg = res.message
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ describe('views/charts2/charts/npm/NpmAppCategoryScore.vue测试', () => {
|
|||||||
|
|
||||||
expect(textNode0.text()).toBe('6')
|
expect(textNode0.text()).toBe('6')
|
||||||
expect(textNode1.text()).toBe('6')
|
expect(textNode1.text()).toBe('6')
|
||||||
expect(textNode2.text()).toBe('-')
|
expect(textNode2.text()).toBe('6')
|
||||||
// expect(textNode3.text()).toBe('-')
|
// expect(textNode3.text()).toBe('-')
|
||||||
expect(textNode4.text()).toBe('5')
|
expect(textNode4.text()).toBe('5')
|
||||||
expect(textNode5.text()).toBe('3')
|
expect(textNode5.text()).toBe('3')
|
||||||
|
|||||||
Reference in New Issue
Block a user