• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 45774165149

22 Nov 2026 09:43PM UTC coverage: 79.735% (-18.4%) from 98.17%
45774165149

push

github

web-flow
[Endpoint] Support message override and position it after label in API docs (#12235)

* [Endpoint] Support message override and position it after label in API docs

* Preserve error message when a message override is provided

3371 of 3616 branches covered (93.22%)

43 of 53 new or added lines in 3 files covered. (81.13%)

9589 existing lines in 490 files now uncovered.

41514 of 52065 relevant lines covered (79.73%)

51.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.41
/services/github/github-issues.service.js
1
import gql from 'graphql-tag'
2 ✔
2
import Joi from 'joi'
2 ✔
3
import { pathParams } from '../index.js'
2 ✔
4
import { metric } from '../text-formatters.js'
2 ✔
5
import { nonNegativeInteger } from '../validators.js'
2 ✔
6
import { GithubAuthV4Service } from './github-auth-service.js'
2 ✔
7
import { documentation, transformErrors } from './github-helpers.js'
2 ✔
8

2 ✔
9
const issueCountSchema = Joi.object({
2 ✔
10
  data: Joi.object({
2 ✔
11
    repository: Joi.object({
2 ✔
12
      issues: Joi.object({
2 ✔
13
        totalCount: nonNegativeInteger,
2 ✔
14
      }).required(),
2 ✔
15
    }).required(),
2 ✔
16
  }).required(),
2 ✔
17
}).required()
2 ✔
18

2 ✔
19
const isClosedVariant = {
2 ✔
20
  'issues-closed': true,
2 ✔
21
  'issues-closed-raw': true,
2 ✔
22
}
2 ✔
23

2 ✔
24
export default class GithubIssues extends GithubAuthV4Service {
2 ✔
25
  static category = 'issue-tracking'
2 ✔
26
  static route = {
2 ✔
27
    base: 'github',
2 ✔
28
    pattern:
2 ✔
29
      ':variant(issues|issues-raw|issues-closed|issues-closed-raw)/:user/:repo/:label*',
2 ✔
30
  }
2 ✔
31

2 ✔
32
  static openApi = {
2 ✔
33
    '/github/{variant}/{user}/{repo}': {
2 ✔
34
      get: {
2 ✔
35
        summary: 'GitHub Issues',
2 ✔
36
        description: documentation,
2 ✔
37
        parameters: pathParams(
2 ✔
38
          {
2 ✔
39
            name: 'variant',
2 ✔
40
            example: 'issues',
2 ✔
41
            schema: { type: 'string', enum: this.getEnum('variant') },
2 ✔
42
          },
2 ✔
43
          { name: 'user', example: 'badges' },
2 ✔
44
          { name: 'repo', example: 'shields' },
2 ✔
45
        ),
2 ✔
46
      },
2 ✔
47
    },
2 ✔
48
    '/github/{variant}/{user}/{repo}/{label}': {
2 ✔
49
      get: {
2 ✔
50
        summary: 'GitHub Issues by label',
2 ✔
51
        description: documentation,
2 ✔
52
        parameters: pathParams(
2 ✔
53
          {
2 ✔
54
            name: 'variant',
2 ✔
55
            example: 'issues',
2 ✔
56
            schema: { type: 'string', enum: this.getEnum('variant') },
2 ✔
57
          },
2 ✔
58
          { name: 'user', example: 'badges' },
2 ✔
59
          { name: 'repo', example: 'shields' },
2 ✔
60
          { name: 'label', example: 'service-badge' },
2 ✔
61
        ),
2 ✔
62
      },
2 ✔
63
    },
2 ✔
64
  }
2 ✔
65

2 ✔
66
  static defaultBadgeData = { label: 'issues', color: 'informational' }
2 ✔
67

2 ✔
68
  static render({ isClosed, issueCount, raw, label }) {
2 ✔
UNCOV
69
    const state = isClosed ? 'closed' : 'open'
×
UNCOV
70

×
UNCOV
71
    let labelPrefix = ''
×
UNCOV
72
    let messageSuffix = ''
×
UNCOV
73
    if (raw) {
×
UNCOV
74
      labelPrefix = `${state} `
×
UNCOV
75
    } else {
×
UNCOV
76
      messageSuffix = state
×
UNCOV
77
    }
×
UNCOV
78

×
UNCOV
79
    const isGhLabelMultiWord = label && label.includes(' ')
×
UNCOV
80
    const labelText = label
×
UNCOV
81
      ? `${isGhLabelMultiWord ? `"${label}"` : label} `
×
UNCOV
82
      : ''
×
UNCOV
83
    return {
×
UNCOV
84
      label: `${labelPrefix}${labelText}issues`,
×
UNCOV
85
      message: `${metric(issueCount)}${
×
UNCOV
86
        messageSuffix ? ' ' : ''
×
UNCOV
87
      }${messageSuffix}`,
×
UNCOV
88
      color: issueCount > 0 ? 'yellow' : 'brightgreen',
×
UNCOV
89
    }
×
UNCOV
90
  }
×
91

2 ✔
92
  async fetch({ isClosed, user, repo, label }) {
2 ✔
UNCOV
93
    const {
×
UNCOV
94
      data: {
×
UNCOV
95
        repository: {
×
UNCOV
96
          issues: { totalCount },
×
UNCOV
97
        },
×
UNCOV
98
      },
×
UNCOV
99
    } = await this._requestGraphql({
×
UNCOV
100
      query: gql`
×
UNCOV
101
        query (
×
UNCOV
102
          $user: String!
×
UNCOV
103
          $repo: String!
×
UNCOV
104
          $states: [IssueState!]
×
UNCOV
105
          $labels: [String!]
×
UNCOV
106
        ) {
×
UNCOV
107
          repository(owner: $user, name: $repo) {
×
UNCOV
108
            issues(states: $states, labels: $labels) {
×
UNCOV
109
              totalCount
×
UNCOV
110
            }
×
UNCOV
111
          }
×
UNCOV
112
        }
×
UNCOV
113
      `,
×
UNCOV
114
      variables: {
×
UNCOV
115
        user,
×
UNCOV
116
        repo,
×
UNCOV
117
        labels: label ? [label] : undefined,
×
UNCOV
118
        states: isClosed ? ['CLOSED'] : ['OPEN'],
×
UNCOV
119
      },
×
UNCOV
120
      schema: issueCountSchema,
×
UNCOV
121
      transformErrors,
×
UNCOV
122
    })
×
UNCOV
123
    return { issueCount: totalCount }
×
UNCOV
124
  }
×
125

2 ✔
126
  async handle({ variant, user, repo, label }) {
2 ✔
UNCOV
127
    const raw = variant.endsWith('-raw')
×
UNCOV
128
    const isClosed = isClosedVariant[variant]
×
UNCOV
129
    const { issueCount } = await this.fetch({
×
UNCOV
130
      isClosed,
×
UNCOV
131
      user,
×
UNCOV
132
      repo,
×
UNCOV
133
      label,
×
UNCOV
134
    })
×
UNCOV
135
    return this.constructor.render({
×
UNCOV
136
      isClosed,
×
UNCOV
137
      issueCount,
×
UNCOV
138
      raw,
×
UNCOV
139
      label,
×
UNCOV
140
    })
×
UNCOV
141
  }
×
142
}
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc