Fix [Testspace] with new "untested" value in case_counts array (#8544)
This commit is contained in:
@@ -2,8 +2,8 @@ import Joi from 'joi'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import { BaseJsonService, NotFound } from '../index.js'
|
||||
|
||||
// https://help.testspace.com/docs/reference/web-api#list-results
|
||||
// case_counts|array|The contained cases [passed, failed, na, errored]|counters of result
|
||||
// https://help.testspace.com/reference/web-api#list-results
|
||||
// case_counts|array|The contained cases [passed, failed, na, errored, untested]|counters of result
|
||||
// session_* fields are for manual runs
|
||||
// There are instances where the api returns a 200 status code with an empty array
|
||||
// notably in cases where a space id is used
|
||||
@@ -12,14 +12,14 @@ const schema = Joi.array()
|
||||
Joi.object({
|
||||
case_counts: Joi.array()
|
||||
.items(nonNegativeInteger)
|
||||
.min(4)
|
||||
.max(4)
|
||||
.min(5)
|
||||
.max(5)
|
||||
.required(),
|
||||
})
|
||||
)
|
||||
.required()
|
||||
|
||||
// https://help.testspace.com/docs/dashboard/overview-navigate
|
||||
// https://help.testspace.com/dashboard/overview#navigate
|
||||
// Org is owner/account
|
||||
// Project is generally a repository
|
||||
// Space is a container, often a branch
|
||||
@@ -49,11 +49,11 @@ export default class TestspaceBase extends BaseJsonService {
|
||||
|
||||
const [
|
||||
{
|
||||
case_counts: [passed, failed, skipped, errored],
|
||||
case_counts: [passed, failed, skipped, errored, untested],
|
||||
},
|
||||
] = json
|
||||
const total = passed + failed + skipped + errored
|
||||
const total = passed + failed + skipped + errored + untested
|
||||
|
||||
return { passed, failed, skipped, errored, total }
|
||||
return { passed, failed, skipped, errored, untested, total }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export default class TestspaceTestCount extends TestspaceBase {
|
||||
static route = {
|
||||
base: 'testspace',
|
||||
pattern:
|
||||
':metric(total|passed|failed|skipped|errored)/:org/:project/:space+',
|
||||
':metric(total|passed|failed|skipped|errored|untested)/:org/:project/:space+',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
@@ -39,7 +39,7 @@ export default class TestspaceTestCount extends TestspaceBase {
|
||||
}
|
||||
|
||||
transform({ json, metric }) {
|
||||
const { passed, failed, skipped, errored, total } =
|
||||
const { passed, failed, skipped, errored, untested, total } =
|
||||
this.transformCaseCounts(json)
|
||||
if (metric === 'total') {
|
||||
return { value: total }
|
||||
@@ -49,6 +49,8 @@ export default class TestspaceTestCount extends TestspaceBase {
|
||||
return { value: failed }
|
||||
} else if (metric === 'skipped') {
|
||||
return { value: skipped }
|
||||
} else if (metric === 'untested') {
|
||||
return { value: untested }
|
||||
} else {
|
||||
return { value: errored }
|
||||
}
|
||||
|
||||
@@ -38,5 +38,10 @@ describe('TestspaceTestCount', function () {
|
||||
message: '0',
|
||||
color: 'informational',
|
||||
})
|
||||
given({ metric: 'untested', value: 0 }).expect({
|
||||
label: 'untested tests',
|
||||
message: '0',
|
||||
color: 'informational',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -41,3 +41,10 @@ t.create('Errored')
|
||||
label: 'errored tests',
|
||||
message: isMetricAllowZero,
|
||||
})
|
||||
|
||||
t.create('Untested')
|
||||
.get('/untested/swellaby/swellaby:testspace-sample/main.json')
|
||||
.expectBadge({
|
||||
label: 'untested tests',
|
||||
message: isMetricAllowZero,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user