Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS migration] Migrate 'test.test.js', 'reviewerChecklist.test.js', 'preDeploy.test.js', 'platformDeploy.test.js', 'lockDeploys.test.js' workflow test to TypeScript #38045

Merged
merged 13 commits into from
Mar 28, 2024
Merged
2 changes: 1 addition & 1 deletion workflow_tests/assertions/lockDeploysAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ function assertlockStagingDeploysJobFailedAfterFirstStep(workflowResult: Step[])
});
}

export {assertlockStagingDeploysJobExecuted, assertlockStagingDeploysJobFailedAfterFirstStep};
export default {assertlockStagingDeploysJobExecuted, assertlockStagingDeploysJobFailedAfterFirstStep};
2 changes: 1 addition & 1 deletion workflow_tests/assertions/platformDeployAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute =
});
}

export {
export default {
assertVerifyActorJobExecuted,
assertDeployChecklistJobExecuted,
assertAndroidJobExecuted,
Expand Down
3 changes: 1 addition & 2 deletions workflow_tests/assertions/reviewerChecklistAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ function assertChecklistJobExecuted(workflowResult: Step[], didExecute = true) {
});
}

// eslint-disable-next-line import/prefer-default-export
export {assertChecklistJobExecuted};
export default {assertChecklistJobExecuted};
2 changes: 1 addition & 1 deletion workflow_tests/assertions/testAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ function assertShellTestsJobExecuted(workflowResult: Step[], didExecute = true)
});
}

export {assertJestJobExecuted, assertShellTestsJobExecuted};
export default {assertJestJobExecuted, assertShellTestsJobExecuted};
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const path = require('path');
const kieMockGithub = require('@kie/mock-github');
const utils = require('./utils/utils');
const assertions = require('./assertions/lockDeploysAssertions');
const mocks = require('./mocks/lockDeploysMocks').default;
const ExtendedAct = require('./utils/ExtendedAct').default;
import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types';
import * as kieMockGithub from '@kie/mock-github';
import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github';
import path from 'path';
import assertions from './assertions/lockDeploysAssertions';
import mocks from './mocks/lockDeploysMocks';
import ExtendedAct from './utils/ExtendedAct';
import * as utils from './utils/utils';

jest.setTimeout(90 * 1000);
let mockGithub;
const FILES_TO_COPY_INTO_TEST_REPO = [

let mockGithub: MockGithub;

const FILES_TO_COPY_INTO_TEST_REPO: CreateRepositoryFile[] = [
...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO),
{
src: path.resolve(__dirname, '..', '.github', 'workflows', 'lockDeploys.yml'),
Expand All @@ -16,7 +20,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [
];

describe('test workflow lockDeploys', () => {
beforeAll(async () => {
beforeAll(() => {
// in case of the tests being interrupted without cleanup the mock repo directory may be left behind
// which breaks the next test run, this removes any possible leftovers
utils.removeMockRepoDir();
Expand All @@ -43,7 +47,7 @@ describe('test workflow lockDeploys', () => {
describe('issue has StagingDeployCash', () => {
describe('actor is not OSBotify', () => {
it('job triggered, comment left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -71,7 +75,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -85,7 +89,7 @@ describe('test workflow lockDeploys', () => {
});

it('one step fails, comment not left in StagingDeployCash, announced failure in Slack', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -113,7 +117,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
testMockSteps.lockStagingDeploys[1] = utils.createMockStep(
Expand All @@ -139,7 +143,7 @@ describe('test workflow lockDeploys', () => {

describe('actor is OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -167,7 +171,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -185,7 +189,7 @@ describe('test workflow lockDeploys', () => {
describe('issue does not have StagingDeployCash', () => {
describe('actor is not OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -213,7 +217,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -229,7 +233,7 @@ describe('test workflow lockDeploys', () => {

describe('actor is OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -257,7 +261,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -277,7 +281,7 @@ describe('test workflow lockDeploys', () => {
describe('issue has StagingDeployCash', () => {
describe('actor is not OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -305,7 +309,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -321,7 +325,7 @@ describe('test workflow lockDeploys', () => {

describe('actor is OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -349,7 +353,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -367,7 +371,7 @@ describe('test workflow lockDeploys', () => {
describe('issue does not have StagingDeployCash', () => {
describe('actor is not OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -395,7 +399,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand All @@ -411,7 +415,7 @@ describe('test workflow lockDeploys', () => {

describe('actor is OSBotify', () => {
it('job not triggered, comment not left in StagingDeployCash', async () => {
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || '';
const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') ?? '';
const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml');
let act = new ExtendedAct(repoPath, workflowPath);
act = utils.setUpActParams(
Expand Down Expand Up @@ -439,7 +443,7 @@ describe('test workflow lockDeploys', () => {
},
workflowPath,
);
const testMockSteps = {
const testMockSteps: MockStep = {
lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS,
};
const result = await act.runEvent('issues', {
Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/mocks/platformDeployMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS = [
PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK,
];

export {
export default {
PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS,
PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS,
PLATFORM_DEPLOY__ANDROID__STEP_MOCKS,
Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/mocks/testMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = createMockStep('Setup Node', 'Se
const TEST__SHELLTESTS__TEST_CI_GIT_LOGIC__STEP_MOCK = createMockStep('Test CI git logic', 'Test CI git logic', 'SHELLTESTS', [], []);
const TEST__SHELLTESTS__STEP_MOCKS = [TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, TEST__SHELLTESTS__TEST_CI_GIT_LOGIC__STEP_MOCK];

export {TEST__JEST__STEP_MOCKS, TEST__SHELLTESTS__STEP_MOCKS};
export default {TEST__JEST__STEP_MOCKS, TEST__SHELLTESTS__STEP_MOCKS};
Loading
Loading