Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Oct 26, 2021
1 parent 519e993 commit 4bae12f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/getPullRequestDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/isPullRequestMergeable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/reopenIssueWithComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/triggerWorkflowAndWait/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/GithubUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class GithubUtils {
console.log('Filtering out the following automated pull requests:', automatedPRs);

const noQAPRs = _.pluck(
_.filter(data, PR => Str.startsWith((PR.title || '').toUpperCase(), '[No QA]')),
_.filter(data, PR => (PR.title || '').toUpperCase().startsWith('[NO QA]')),
'html_url',
);
console.log('Found the following NO QA PRs:', noQAPRs);
Expand Down
34 changes: 32 additions & 2 deletions tests/unit/GithubUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,46 @@ describe('GithubUtils', () => {
const mockPRs = [
{
number: 1,
title: 'Test PR 1',
html_url: 'https://github.com/Expensify/App/pull/1',
user: {login: 'testUser'},
labels: [],
},
{
number: 2,
title: 'Test PR 2',
html_url: 'https://github.com/Expensify/App/pull/2',
user: {login: 'testUser'},
labels: [],
},
{
number: 3,
title: 'Test PR 3',
html_url: 'https://github.com/Expensify/App/pull/3',
user: {login: 'testUser'},
labels: [],
},
{
number: 4,
title: 'Test Automated PR',
html_url: 'https://github.com/Expensify/App/pull/4',
user: {login: 'OSBotify'},
labels: [{name: 'automerge'}],
},
{
number: 5,
title: '[No QA] Test No QA PR uppercase',
html_url: 'https://github.com/Expensify/App/pull/5',
user: {login: 'testUser'},
labels: [],
},
{
number: 6,
title: '[No QA] Test No QA PR Title Case',
html_url: 'https://github.com/Expensify/App/pull/6',
user: {login: 'testUser'},
labels: [],
},
];
const mockGithub = jest.fn(() => ({
getOctokit: () => ({
Expand All @@ -279,8 +297,10 @@ describe('GithubUtils', () => {
'https://github.com/Expensify/App/pull/2',
'https://github.com/Expensify/App/pull/3',
'https://github.com/Expensify/App/pull/1',
'https://github.com/Expensify/App/pull/4',
'https://github.com/Expensify/App/pull/4', // Automated
'https://github.com/Expensify/App/pull/3', // This is an intentional duplicate for testing duplicates
'https://github.com/Expensify/App/pull/5', // No QA
'https://github.com/Expensify/App/pull/6', // No QA
];

const baseDeployBlockerList = [
Expand All @@ -305,7 +325,9 @@ describe('GithubUtils', () => {
const allVerifiedExpectedOutput = `${baseExpectedOutput}`
+ `${lineBreakDouble}${listStart}${basePRList[2]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[0]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`;
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[5]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[6]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`;


test('Test no verified PRs', () => (
Expand All @@ -316,6 +338,8 @@ describe('GithubUtils', () => {
+ `${lineBreakDouble}${listStart}${basePRList[2]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[0]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[5]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[6]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${ccApplauseLeads}`,
);
})
Expand All @@ -329,6 +353,8 @@ describe('GithubUtils', () => {
+ `${lineBreakDouble}${listStart}${basePRList[2]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[0]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[5]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[6]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${ccApplauseLeads}`,
);
})
Expand All @@ -342,6 +368,8 @@ describe('GithubUtils', () => {
+ `${lineBreakDouble}${listStart}${basePRList[2]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[0]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${openCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[5]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[6]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${ccApplauseLeads}`,
);
})
Expand Down Expand Up @@ -390,6 +418,8 @@ describe('GithubUtils', () => {
+ `${lineBreakDouble}${listStart}${basePRList[2]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[0]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${openCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[1]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[5]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${listStart}${basePRList[6]}${lineBreak}${indent}${closedCheckbox}${QA}${lineBreak}${indent}${closedCheckbox}${accessibility}`
+ `${lineBreakDouble}${deployBlockerHeader}`
+ `${lineBreak}${closedCheckbox}${baseDeployBlockerList[0]}`
+ `${lineBreak}${closedCheckbox}${baseDeployBlockerList[1]}`
Expand Down

0 comments on commit 4bae12f

Please sign in to comment.