mirror of
https://github.com/badges/shields.git
synced 2026-11-21 16:06:35 +03:00
* refactor(github): separate pull request count service Count all pull request badge variants through GitHub search so draft qualifiers can be composed consistently. Keep issue badges on the repository issues connection and document each preserved PR route explicitly. Co-authored-by: Philippe Martin <phmartin@redhat.com> * test(github): move pull request badge coverage Keep the existing live picture checks with the service that now owns the pull request routes. * test(github): cover pull request search variants Assert the exact unfiltered GitHub search qualifier and preserve open, closed, raw, and non-raw badge rendering. * test(github): cover draft pull request filters Verify excludeDrafts, onlyDrafts, label composition, and closed raw rendering against exact GitHub search qualifiers. * test(github): cover pull request request errors Reject incompatible draft filters before an outbound request and keep missing repositories distinct from valid zero-count results. * test(github): guard GraphQL response boundaries Cover malformed pull request search data and prove issue badges remain on the repository issues query after the service split. * fix(github): preserve unfiltered pull request counts * test(github): use live pull request fixtures --------- Co-authored-by: Philippe Martin <phmartin@redhat.com>
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
import Joi from 'joi'
|
|
import { isMetric, isMetricOpenIssues } from '../test-validators.js'
|
|
import { createServiceTester } from '../tester.js'
|
|
export const t = await createServiceTester()
|
|
|
|
t.create('GitHub closed issues')
|
|
.get('/issues-closed/badges/shields.json')
|
|
.expectBadge({
|
|
label: 'issues',
|
|
message: Joi.string().regex(
|
|
/^([0-9]+[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) closed$/,
|
|
),
|
|
})
|
|
|
|
t.create('GitHub closed issues raw')
|
|
.get('/issues-closed-raw/badges/shields.json')
|
|
.expectBadge({
|
|
label: 'closed issues',
|
|
message: isMetric,
|
|
})
|
|
|
|
t.create('GitHub open issues').get('/issues/badges/shields.json').expectBadge({
|
|
label: 'issues',
|
|
message: isMetricOpenIssues,
|
|
})
|
|
|
|
t.create('GitHub open issues raw')
|
|
.get('/issues-raw/badges/shields.json')
|
|
.expectBadge({ label: 'open issues', message: isMetric })
|
|
|
|
t.create('GitHub open issues by label is > zero')
|
|
.get('/issues/badges/shields/service-badge.json')
|
|
.expectBadge({
|
|
label: 'service-badge issues',
|
|
message: isMetricOpenIssues,
|
|
})
|
|
|
|
t.create('GitHub open issues by multi-word label is > zero')
|
|
.get('/issues/Cockatrice/Cockatrice/App%20-%20Cockatrice.json')
|
|
.expectBadge({
|
|
label: '"App - Cockatrice" issues',
|
|
message: isMetricOpenIssues,
|
|
})
|
|
|
|
t.create('GitHub open issues by label (raw)')
|
|
.get('/issues-raw/badges/shields/service-badge.json')
|
|
.expectBadge({
|
|
label: 'open service-badge issues',
|
|
message: isMetric,
|
|
})
|
|
|
|
// https://github.com/badges/shields/issues/1870
|
|
t.create('GitHub open issues by label including slash character (raw)')
|
|
.get('/issues-raw/calebcartwright/shields-service-test-target/@foo/bar.json')
|
|
.expectBadge({
|
|
label: 'open @foo/bar issues',
|
|
// Not always > 0.
|
|
message: Joi.alternatives(isMetric, Joi.equal('0')),
|
|
})
|
|
|
|
t.create('GitHub open issues (repo not found)')
|
|
.get('/issues-raw/badges/helmets.json')
|
|
.expectBadge({
|
|
label: 'issues',
|
|
message: 'repo not found',
|
|
})
|