forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
claAssertions.ts
73 lines (68 loc) · 2.42 KB
/
claAssertions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import type {Step} from '@kie/act-js';
import {createStepAssertion} from '../utils/utils';
function assertCLAJobExecuted(workflowResult: Step[], commentBody = '', githubRepository = '', didExecute = true, runAssistant = true) {
const steps = [
createStepAssertion(
'CLA comment check',
true,
null,
'CLA',
'CLA comment check',
[
{key: 'text', value: commentBody},
{key: 'regex', value: '\\s*I have read the CLA Document and I hereby sign the CLA\\s*'},
],
[],
),
createStepAssertion(
'CLA comment re-check',
true,
null,
'CLA',
'CLA comment re-check',
[
{key: 'text', value: commentBody},
{key: 'regex', value: '\\s*recheck\\s*'},
],
[],
),
] as const;
steps.forEach((expectedStep) => {
if (didExecute) {
expect(workflowResult).toEqual(expect.arrayContaining([expectedStep]));
} else {
expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep]));
}
});
const assistantSteps = [
createStepAssertion(
'CLA Assistant',
true,
null,
'CLA',
'CLA Assistant',
[
{key: 'path-to-signatures', value: `${githubRepository}/cla.json`},
{key: 'path-to-document', value: `https://github.com/${githubRepository}/blob/main/contributingGuides/CLA.md`},
{key: 'branch', value: 'main'},
{key: 'remote-organization-name', value: 'Expensify'},
{key: 'remote-repository-name', value: 'CLA'},
{key: 'lock-pullrequest-aftermerge', value: false},
{key: 'allowlist', value: 'OSBotify,snyk-bot'},
],
[
{key: 'GITHUB_TOKEN', value: '***'},
{key: 'PERSONAL_ACCESS_TOKEN', value: '***'},
],
),
] as const;
assistantSteps.forEach((step) => {
if (didExecute && runAssistant) {
expect(workflowResult).toEqual(expect.arrayContaining([step]));
} else {
expect(workflowResult).not.toEqual(expect.arrayContaining([step]));
}
});
}
// eslint-disable-next-line import/prefer-default-export
export {assertCLAJobExecuted};