From d2db92b1986ad935efc2e9fffd4eac1b1bb5330c Mon Sep 17 00:00:00 2001 From: calebcartwright Date: Wed, 19 Dec 2018 17:11:50 -0600 Subject: [PATCH 1/2] tests: updated jira tests to include colorscheme validation --- services/jira/jira-issue.tester.js | 126 ++++++++++++++++++++++++---- services/jira/jira-sprint.tester.js | 43 +++++++--- 2 files changed, 139 insertions(+), 30 deletions(-) diff --git a/services/jira/jira-issue.tester.js b/services/jira/jira-issue.tester.js index c772d233b9bfd..c94b2d3668b1d 100644 --- a/services/jira/jira-issue.tester.js +++ b/services/jira/jira-issue.tester.js @@ -1,7 +1,8 @@ 'use strict' const t = (module.exports = require('../create-service-tester')()) -const jiraTestHelpers = require('./jira-test-helpers') +const { colorScheme } = require('../test-helpers') +const { mockJiraCreds, restore, user, pass } = require('./jira-test-helpers') t.create('live: unknown issue') .get('/https/issues.apache.org/jira/notArealIssue-000.json') @@ -11,8 +12,8 @@ t.create('live: known issue') .get('/https/issues.apache.org/jira/kafka-2896.json') .expectJSON({ name: 'kafka-2896', value: 'Resolved' }) -t.create('http endpoint') - .get('/http/issues.apache.org/jira/foo-123.json') +t.create('no status color') + .get('/http/issues.apache.org/jira/foo-123.json?style=_shields_test') .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2/issue') .get(`/${encodeURIComponent('foo-123')}`) @@ -24,10 +25,14 @@ t.create('http endpoint') }, }) ) - .expectJSON({ name: 'foo-123', value: 'pending' }) + .expectJSON({ + name: 'foo-123', + value: 'pending', + colorB: colorScheme.lightgrey, + }) -t.create('endpoint with port and path') - .get('/https/issues.apache.org:8000/jira/bar-345.json') +t.create('green status color') + .get('/https/issues.apache.org:8000/jira/bar-345.json?style=_shields_test') .intercept(nock => nock('https://issues.apache.org:8000/jira/rest/api/2/issue') .get(`/${encodeURIComponent('bar-345')}`) @@ -35,14 +40,21 @@ t.create('endpoint with port and path') fields: { status: { name: 'done', + statusCategory: { + colorName: 'green', + }, }, }, }) ) - .expectJSON({ name: 'bar-345', value: 'done' }) + .expectJSON({ + name: 'bar-345', + value: 'done', + colorB: colorScheme.green, + }) -t.create('endpoint with port and no path') - .get('/https/issues.apache.org:8080/abc-123.json') +t.create('medium-gray status color') + .get('/https/issues.apache.org:8080/abc-123.json?style=_shields_test') .intercept(nock => nock('https://issues.apache.org:8080/rest/api/2/issue') .get(`/${encodeURIComponent('abc-123')}`) @@ -50,14 +62,21 @@ t.create('endpoint with port and no path') fields: { status: { name: 'under review', + statusCategory: { + colorName: 'medium-gray', + }, }, }, }) ) - .expectJSON({ name: 'abc-123', value: 'under review' }) + .expectJSON({ + name: 'abc-123', + value: 'under review', + colorB: colorScheme.lightgrey, + }) -t.create('endpoint with no port nor path') - .get('/https/issues.apache.org/test-001.json') +t.create('yellow status color') + .get('/https/issues.apache.org/test-001.json?style=_shields_test') .intercept(nock => nock('https://issues.apache.org/rest/api/2/issue') .get(`/${encodeURIComponent('test-001')}`) @@ -65,14 +84,87 @@ t.create('endpoint with no port nor path') fields: { status: { name: 'in progress', + statusCategory: { + colorName: 'yellow', + }, }, }, }) ) - .expectJSON({ name: 'test-001', value: 'in progress' }) + .expectJSON({ + name: 'test-001', + value: 'in progress', + colorB: colorScheme.yellow, + }) + +t.create('brown status color') + .get('/https/issues.apache.org/zzz-789.json?style=_shields_test') + .intercept(nock => + nock('https://issues.apache.org/rest/api/2/issue') + .get(`/${encodeURIComponent('zzz-789')}`) + .reply(200, { + fields: { + status: { + name: 'muddy', + statusCategory: { + colorName: 'brown', + }, + }, + }, + }) + ) + .expectJSON({ + name: 'zzz-789', + value: 'muddy', + colorB: colorScheme.orange, + }) + +t.create('warm-red status color') + .get('/https/issues.apache.org/fire-321.json?style=_shields_test') + .intercept(nock => + nock('https://issues.apache.org/rest/api/2/issue') + .get(`/${encodeURIComponent('fire-321')}`) + .reply(200, { + fields: { + status: { + name: 'heating up', + statusCategory: { + colorName: 'warm-red', + }, + }, + }, + }) + ) + .expectJSON({ + name: 'fire-321', + value: 'heating up', + colorB: colorScheme.red, + }) + +t.create('blue-gray status color') + .get('/https/issues.apache.org/sky-775.json?style=_shields_test') + .intercept(nock => + nock('https://issues.apache.org/rest/api/2/issue') + .get(`/${encodeURIComponent('sky-775')}`) + .reply(200, { + fields: { + status: { + name: 'cloudy', + statusCategory: { + colorName: 'blue-gray', + }, + }, + }, + }) + ) + .expectJSON({ + name: 'sky-775', + value: 'cloudy', + colorB: colorScheme.blue, + }) t.create('with auth') - .before(jiraTestHelpers.mockJiraCreds) + .before(mockJiraCreds) .get('/https/myprivatejira.com/secure-234.json') .intercept(nock => nock('https://myprivatejira.com/rest/api/2/issue') @@ -80,8 +172,8 @@ t.create('with auth') // This ensures that the expected credentials from serverSecrets are actually being sent with the HTTP request. // Without this the request wouldn't match and the test would fail. .basicAuth({ - user: jiraTestHelpers.user, - pass: jiraTestHelpers.pass, + user: user, + pass: pass, }) .reply(200, { fields: { @@ -91,5 +183,5 @@ t.create('with auth') }, }) ) - .finally(jiraTestHelpers.restore) + .finally(restore) .expectJSON({ name: 'secure-234', value: 'in progress' }) diff --git a/services/jira/jira-sprint.tester.js b/services/jira/jira-sprint.tester.js index 5a2f799e009d3..389549ba64fbe 100644 --- a/services/jira/jira-sprint.tester.js +++ b/services/jira/jira-sprint.tester.js @@ -3,7 +3,8 @@ const Joi = require('joi') const t = (module.exports = require('../create-service-tester')()) const { isIntegerPercentage } = require('../test-validators') -const jiraTestHelpers = require('./jira-test-helpers') +const { colorScheme } = require('../test-helpers') +const { mockJiraCreds, restore, user, pass } = require('./jira-test-helpers') const sprintId = 8 const queryString = { @@ -26,7 +27,7 @@ t.create('live: known sprint') ) t.create('100% completion') - .get(`/http/issues.apache.org/jira/${sprintId}.json`) + .get(`/http/issues.apache.org/jira/${sprintId}.json?style=_shields_test`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -51,10 +52,14 @@ t.create('100% completion') ], }) ) - .expectJSON({ name: 'completion', value: '100%' }) + .expectJSON({ + name: 'completion', + value: '100%', + colorB: colorScheme.brightgreen, + }) t.create('0% completion') - .get(`/http/issues.apache.org/jira/${sprintId}.json`) + .get(`/http/issues.apache.org/jira/${sprintId}.json?style=_shields_test`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -72,10 +77,14 @@ t.create('0% completion') ], }) ) - .expectJSON({ name: 'completion', value: '0%' }) + .expectJSON({ + name: 'completion', + value: '0%', + colorB: colorScheme.red, + }) t.create('no issues in sprint') - .get(`/http/issues.apache.org/jira/${sprintId}.json`) + .get(`/http/issues.apache.org/jira/${sprintId}.json?style=_shields_test`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -85,10 +94,14 @@ t.create('no issues in sprint') issues: [], }) ) - .expectJSON({ name: 'completion', value: '0%' }) + .expectJSON({ + name: 'completion', + value: '0%', + colorB: colorScheme.red, + }) t.create('issue with null resolution value') - .get(`/https/jira.spring.io:8080/${sprintId}.json`) + .get(`/https/jira.spring.io:8080/${sprintId}.json?style=_shields_test`) .intercept(nock => nock('https://jira.spring.io:8080/rest/api/2') .get('/search') @@ -111,10 +124,14 @@ t.create('issue with null resolution value') ], }) ) - .expectJSON({ name: 'completion', value: '50%' }) + .expectJSON({ + name: 'completion', + value: '50%', + colorB: colorScheme.orange, + }) t.create('with auth') - .before(jiraTestHelpers.mockJiraCreds) + .before(mockJiraCreds) .get(`/https/myprivatejira/jira/${sprintId}.json`) .intercept(nock => nock('https://myprivatejira/jira/rest/api/2') @@ -123,8 +140,8 @@ t.create('with auth') // This ensures that the expected credentials from serverSecrets are actually being sent with the HTTP request. // Without this the request wouldn't match and the test would fail. .basicAuth({ - user: jiraTestHelpers.user, - pass: jiraTestHelpers.pass, + user: user, + pass: pass, }) .reply(200, { total: 2, @@ -146,5 +163,5 @@ t.create('with auth') ], }) ) - .finally(jiraTestHelpers.restore) + .finally(restore) .expectJSON({ name: 'completion', value: '50%' }) From 4885d2e0235a5c1c3031f79ce7a0876c8bfedf1c Mon Sep 17 00:00:00 2001 From: calebcartwright Date: Wed, 19 Dec 2018 17:18:09 -0600 Subject: [PATCH 2/2] chore: fixed eslint issue with jira tests --- services/jira/jira-issue.tester.js | 4 ++-- services/jira/jira-sprint.tester.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/jira/jira-issue.tester.js b/services/jira/jira-issue.tester.js index c94b2d3668b1d..ea89806912eb1 100644 --- a/services/jira/jira-issue.tester.js +++ b/services/jira/jira-issue.tester.js @@ -172,8 +172,8 @@ t.create('with auth') // This ensures that the expected credentials from serverSecrets are actually being sent with the HTTP request. // Without this the request wouldn't match and the test would fail. .basicAuth({ - user: user, - pass: pass, + user, + pass, }) .reply(200, { fields: { diff --git a/services/jira/jira-sprint.tester.js b/services/jira/jira-sprint.tester.js index 389549ba64fbe..71762def550cb 100644 --- a/services/jira/jira-sprint.tester.js +++ b/services/jira/jira-sprint.tester.js @@ -140,8 +140,8 @@ t.create('with auth') // This ensures that the expected credentials from serverSecrets are actually being sent with the HTTP request. // Without this the request wouldn't match and the test would fail. .basicAuth({ - user: user, - pass: pass, + user, + pass, }) .reply(200, { total: 2,