refactor: cleanup AppveyorTests with by using shared helpers (#7077)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,31 +1,10 @@
|
||||
import {
|
||||
testResultQueryParamSchema,
|
||||
renderTestResultBadge,
|
||||
documentation,
|
||||
} from '../test-results.js'
|
||||
import AppVeyorBase from './appveyor-base.js'
|
||||
|
||||
const documentation = `
|
||||
<p>
|
||||
You may change the "passed", "failed" and "skipped" text on this badge by supplying query parameters <code>&passed_label=</code>, <code>&failed_label=</code> and <code>&skipped_label=</code> respectively.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, if you want to use a different terminology:
|
||||
<br>
|
||||
<code>/appveyor/tests/NZSmartie/coap-net-iu0to.svg?passed_label=good&failed_label=bad&skipped_label=n%2Fa</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Or symbols:
|
||||
<br>
|
||||
<code>/appveyor/tests/NZSmartie/coap-net-iu0to.svg?compact_message&passed_label=%F0%9F%8E%89&failed_label=%F0%9F%92%A2&skipped_label=%F0%9F%A4%B7</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There is also a <code>&compact_message</code> query parameter, which will default to displaying ✔, ✘ and ➟, separated by a horizontal bar |.
|
||||
</p>
|
||||
`
|
||||
|
||||
const commonPreviewProps = {
|
||||
passed: 477,
|
||||
failed: 2,
|
||||
|
||||
@@ -1,38 +1,26 @@
|
||||
import queryString from 'querystring'
|
||||
import Joi from 'joi'
|
||||
import {
|
||||
isDefaultTestTotals,
|
||||
isDefaultCompactTestTotals,
|
||||
isCustomTestTotals,
|
||||
isCustomCompactTestTotals,
|
||||
} from '../test-validators.js'
|
||||
import { createServiceTester } from '../tester.js'
|
||||
export const t = await createServiceTester()
|
||||
|
||||
const isAppveyorTestTotals = Joi.string().regex(
|
||||
/^[0-9]+ passed(, [0-9]+ failed)?(, [0-9]+ skipped)?$/
|
||||
)
|
||||
|
||||
const isCompactAppveyorTestTotals = Joi.string().regex(
|
||||
/^✔ [0-9]+( \| ✘ [0-9]+)?( \| ➟ [0-9]+)?$/
|
||||
)
|
||||
|
||||
const isCustomAppveyorTestTotals = Joi.string().regex(
|
||||
/^[0-9]+ good(, [0-9]+ bad)?(, [0-9]+ n\/a)?$/
|
||||
)
|
||||
|
||||
const isCompactCustomAppveyorTestTotals = Joi.string().regex(
|
||||
/^💃 [0-9]+( \| 🤦♀️ [0-9]+)?( \| 🤷 [0-9]+)?$/
|
||||
)
|
||||
|
||||
t.create('Test status')
|
||||
.timeout(10000)
|
||||
.get('/NZSmartie/coap-net-iu0to.json')
|
||||
.expectBadge({ label: 'tests', message: isAppveyorTestTotals })
|
||||
.expectBadge({ label: 'tests', message: isDefaultTestTotals })
|
||||
|
||||
t.create('Test status on branch')
|
||||
.timeout(10000)
|
||||
.get('/NZSmartie/coap-net-iu0to/master.json')
|
||||
.expectBadge({ label: 'tests', message: isAppveyorTestTotals })
|
||||
.expectBadge({ label: 'tests', message: isDefaultTestTotals })
|
||||
|
||||
t.create('Test status with compact message')
|
||||
.timeout(10000)
|
||||
.get('/NZSmartie/coap-net-iu0to.json?compact_message')
|
||||
.expectBadge({ label: 'tests', message: isCompactAppveyorTestTotals })
|
||||
.expectBadge({ label: 'tests', message: isDefaultCompactTestTotals })
|
||||
|
||||
t.create('Test status with custom labels')
|
||||
.timeout(10000)
|
||||
@@ -43,21 +31,21 @@ t.create('Test status with custom labels')
|
||||
skipped_label: 'n/a',
|
||||
},
|
||||
})
|
||||
.expectBadge({ label: 'tests', message: isCustomAppveyorTestTotals })
|
||||
.expectBadge({ label: 'tests', message: isCustomTestTotals })
|
||||
|
||||
t.create('Test status with compact message and custom labels')
|
||||
.timeout(10000)
|
||||
.get(
|
||||
`/NZSmartie/coap-net-iu0to.json?${queryString.stringify({
|
||||
.get('/NZSmartie/coap-net-iu0to.json', {
|
||||
qs: {
|
||||
compact_message: null,
|
||||
passed_label: '💃',
|
||||
failed_label: '🤦♀️',
|
||||
skipped_label: '🤷',
|
||||
})}`
|
||||
)
|
||||
},
|
||||
})
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: isCompactCustomAppveyorTestTotals,
|
||||
message: isCustomCompactTestTotals,
|
||||
})
|
||||
|
||||
t.create('Test status on non-existent project')
|
||||
|
||||
Reference in New Issue
Block a user