From 0681305199051ab0d6af3e6eee132bf26098de9a Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Mon, 25 Mar 2024 15:11:21 +0100 Subject: [PATCH 1/3] restore tests --- src/types/modules/act.d.ts | 14 +++++++++ ...rsion.test.js => createNewVersion.test.ts} | 31 ++++++++++--------- .../{deploy.test.js => deploy.test.ts} | 27 ++++++++-------- ...yBlocker.test.js => deployBlocker.test.ts} | 26 +++++++++------- ...cle.test.js => finishReleaseCycle.test.ts} | 30 +++++++++--------- workflow_tests/{lint.test.js => lint.test.ts} | 29 ++++++++--------- workflow_tests/mocks/createNewVersionMocks.ts | 9 +++--- workflow_tests/mocks/deployBlockerMocks.ts | 10 +++--- workflow_tests/mocks/deployMocks.ts | 10 +++--- .../mocks/finishReleaseCycleMocks.ts | 18 ++++++----- workflow_tests/mocks/lintMocks.ts | 3 +- workflow_tests/utils/JobMocker.ts | 11 ++++--- workflow_tests/utils/preGenerateTest.ts | 5 +-- workflow_tests/utils/utils.ts | 7 ++--- 14 files changed, 129 insertions(+), 101 deletions(-) create mode 100644 src/types/modules/act.d.ts rename workflow_tests/{createNewVersion.test.js => createNewVersion.test.ts} (93%) rename workflow_tests/{deploy.test.js => deploy.test.ts} (93%) rename workflow_tests/{deployBlocker.test.js => deployBlocker.test.ts} (92%) rename workflow_tests/{finishReleaseCycle.test.js => finishReleaseCycle.test.ts} (94%) rename workflow_tests/{lint.test.js => lint.test.ts} (92%) diff --git a/src/types/modules/act.d.ts b/src/types/modules/act.d.ts new file mode 100644 index 000000000000..5fe00ec479cf --- /dev/null +++ b/src/types/modules/act.d.ts @@ -0,0 +1,14 @@ +import type {StepIdentifier as ActStepIdentifier} from '@kie/act-js'; + +declare module '@kie/act-js' { + // eslint-disable-next-line rulesdir/no-inline-named-export + export declare type StepIdentifier = { + id?: string; + name: string; + run?: string; + mockWith?: string; + with?: string; + envs?: string[]; + inputs?: string[]; + } & Omit; +} diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.ts similarity index 93% rename from workflow_tests/createNewVersion.test.js rename to workflow_tests/createNewVersion.test.ts index 08ac63ba9948..3eeefa640e1a 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.ts @@ -1,12 +1,13 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/createNewVersionAssertions'); -const mocks = require('./mocks/createNewVersionMocks'); -const ExtendedAct = require('./utils/ExtendedAct').default; +import {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/createNewVersionAssertions'; +import * as mocks from './mocks/createNewVersionMocks'; +import ExtendedAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); // 90 sec -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -16,7 +17,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow createNewVersion', () => { - 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(); @@ -24,7 +25,7 @@ describe('test workflow createNewVersion', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testCreateNewVersionWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -56,7 +57,7 @@ describe('test workflow createNewVersion', () => { describe('actor is admin', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -79,7 +80,7 @@ describe('test workflow createNewVersion', () => { describe('actor is writer', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -102,7 +103,7 @@ describe('test workflow createNewVersion', () => { describe('actor is reader', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS; it('stops after validation', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -124,7 +125,7 @@ describe('test workflow createNewVersion', () => { describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -133,7 +134,7 @@ describe('test workflow createNewVersion', () => { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; - testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], [], [], false); + testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], {}, {}, false); const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, @@ -146,7 +147,7 @@ describe('test workflow createNewVersion', () => { }); it('chooses source branch depending on the SEMVER_LEVEL', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, {SEMVER_LEVEL: 'MAJOR'}); diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.ts similarity index 93% rename from workflow_tests/deploy.test.js rename to workflow_tests/deploy.test.ts index cf5b658d3ffb..37ab104ea248 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.ts @@ -1,12 +1,13 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/deployAssertions'); -const mocks = require('./mocks/deployMocks'); -const ExtendedAct = require('./utils/ExtendedAct').default; +import {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/deployAssertions'; +import * as mocks from './mocks/deployMocks'; +import ExtendedAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -16,7 +17,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow deploy', () => { - 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(); @@ -24,7 +25,7 @@ describe('test workflow deploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -48,7 +49,7 @@ describe('test workflow deploy', () => { }; describe('push', () => { it('to main - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -75,7 +76,7 @@ describe('test workflow deploy', () => { }); it('to staging - deployStaging triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -102,7 +103,7 @@ describe('test workflow deploy', () => { }); it('to production - deployProduction triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -130,7 +131,7 @@ describe('test workflow deploy', () => { }); it('different event than push - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); const testMockSteps = { diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.ts similarity index 92% rename from workflow_tests/deployBlocker.test.js rename to workflow_tests/deployBlocker.test.ts index 42c4f9e741f7..1e67498bc5a7 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.ts @@ -1,12 +1,14 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/deployBlockerAssertions'); -const mocks = require('./mocks/deployBlockerMocks'); -const ExtendedAct = require('./utils/ExtendedAct').default; +/* eslint-disable @typescript-eslint/naming-convention */ +import {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/deployBlockerAssertions'; +import * as mocks from './mocks/deployBlockerMocks'; +import ExtendedAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -23,7 +25,7 @@ describe('test workflow deployBlocker', () => { SLACK_WEBHOOK: 'dummy_slack_webhook', }; - 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(); @@ -31,7 +33,7 @@ describe('test workflow deployBlocker', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testDeployBlockerWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -64,7 +66,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'DeployBlockerCash'}; it('runs the workflow and announces success on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -90,7 +92,7 @@ describe('test workflow deployBlocker', () => { }); describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -130,7 +132,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'Different Label'}; it('does not run workflow', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.ts similarity index 94% rename from workflow_tests/finishReleaseCycle.test.js rename to workflow_tests/finishReleaseCycle.test.ts index 20ab66471d91..567323eeb052 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.ts @@ -1,12 +1,14 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/finishReleaseCycleAssertions'); -const mocks = require('./mocks/finishReleaseCycleMocks'); -const ExtendedAct = require('./utils/ExtendedAct').default; +import {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/finishReleaseCycleAssertions'; +import * as mocks from './mocks/finishReleaseCycleMocks'; +import ExtendedAct from './utils/ExtendedAct'; +import type {MockJobs} from './utils/JobMocker'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -16,7 +18,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow finishReleaseCycle', () => { - 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(); @@ -24,7 +26,7 @@ describe('test workflow finishReleaseCycle', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testFinishReleaseCycleWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -50,7 +52,7 @@ describe('test workflow finishReleaseCycle', () => { describe('actor is a team member', () => { describe('no deploy blockers', () => { it('production updated, new version created', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -71,7 +73,7 @@ describe('test workflow finishReleaseCycle', () => { updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, }; - const testMockJobs = { + const testMockJobs: MockJobs = { createNewPatchVersion: { steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, outputs: { @@ -96,7 +98,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('deploy blockers', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -143,7 +145,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('actor is not a team member', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -190,7 +192,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('issue does not have StagingDeployCash', () => { it('validate job not run', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.ts similarity index 92% rename from workflow_tests/lint.test.js rename to workflow_tests/lint.test.ts index b13b4c1c3564..45af1a26c175 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.ts @@ -1,12 +1,13 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/lintAssertions'); -const mocks = require('./mocks/lintMocks'); -const ExtendedAct = require('./utils/ExtendedAct').default; +import {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/lintAssertions'; +import * as mocks from './mocks/lintMocks'; +import ExtendedAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -19,7 +20,7 @@ describe('test workflow lint', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; - 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(); @@ -27,7 +28,7 @@ describe('test workflow lint', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testLintWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -47,7 +48,7 @@ describe('test workflow lint', () => { const event = 'workflow_call'; const eventOptions = {}; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -66,7 +67,7 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -91,7 +92,7 @@ describe('test workflow lint', () => { action: 'opened', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -110,7 +111,7 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('does not run the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -133,7 +134,7 @@ describe('test workflow lint', () => { action: 'synchronize', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); diff --git a/workflow_tests/mocks/createNewVersionMocks.ts b/workflow_tests/mocks/createNewVersionMocks.ts index 59aa6bc910a2..491307964ab8 100644 --- a/workflow_tests/mocks/createNewVersionMocks.ts +++ b/workflow_tests/mocks/createNewVersionMocks.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // validateactor @@ -11,9 +12,9 @@ const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = createMockStep('Get user permissions', 'Get user permissions', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { PERMISSION: 'read', }); -const CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK] as const; -const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK] as const; -const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK] as const; +const CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK] as const satisfies StepIdentifier[]; +const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK] as const satisfies StepIdentifier[]; +const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK] as const satisfies StepIdentifier[]; // createnewversion const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = createMockStep('Run turnstyle', 'Run turnstyle', 'CREATENEWVERSION', ['poll-interval-seconds'], ['GITHUB_TOKEN']); @@ -37,7 +38,7 @@ const CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS = [ CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; export { CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, diff --git a/workflow_tests/mocks/deployBlockerMocks.ts b/workflow_tests/mocks/deployBlockerMocks.ts index 932d4626b67b..d759654d31ac 100644 --- a/workflow_tests/mocks/deployBlockerMocks.ts +++ b/workflow_tests/mocks/deployBlockerMocks.ts @@ -1,9 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import {createMockStep} from '../utils/utils'; +import type { StepIdentifier } from '@kie/act-js'; +import { createMockStep } from '../utils/utils'; + // updateChecklist const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCK = createMockStep('updateChecklist', 'Run updateChecklist', 'UPDATECHECKLIST'); -const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS = [DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCK] as const; +const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS = [DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCK] as const satisfies StepIdentifier[]; // deployblocker const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER'); @@ -35,6 +37,6 @@ const DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS = [ DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK, DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEPLOY_BLOCKER__STEP_MOCK, DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; -export {DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS}; +export {DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS}; \ No newline at end of file diff --git a/workflow_tests/mocks/deployMocks.ts b/workflow_tests/mocks/deployMocks.ts index d0795477cfca..00b3a376cc5b 100644 --- a/workflow_tests/mocks/deployMocks.ts +++ b/workflow_tests/mocks/deployMocks.ts @@ -1,5 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import {createMockStep} from '../utils/utils'; +import type { StepIdentifier } from '@kie/act-js'; +import { createMockStep } from '../utils/utils'; + const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', [ @@ -14,7 +16,7 @@ const DEPLOY_STAGING_STEP_MOCKS = [ DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, DEPLOY_STAGING__PUSH_TAG__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['ref', 'token']); const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = createMockStep( @@ -53,6 +55,6 @@ const DEPLOY_PRODUCTION_STEP_MOCKS = [ DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK, DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK, DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; -export {DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS}; +export {DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS}; \ No newline at end of file diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.ts b/workflow_tests/mocks/finishReleaseCycleMocks.ts index 360bb017da88..824015f96411 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.ts +++ b/workflow_tests/mocks/finishReleaseCycleMocks.ts @@ -1,5 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import {createMockStep} from '../utils/utils'; +import type { StepIdentifier } from '@kie/act-js'; +import { createMockStep } from '../utils/utils'; + // validate const FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'VALIDATE', ['ref', 'token']); @@ -73,7 +75,7 @@ const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, @@ -82,7 +84,7 @@ const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, @@ -92,7 +94,7 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, @@ -126,7 +128,7 @@ const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [ FINISHRELEASECYCLE__UPDATEPRODUCTION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK, FINISHRELEASECYCLE__UPDATEPRODUCTION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; // createnewpatchversion const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = createMockStep( @@ -140,7 +142,7 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = true, 'createNewVersion', ); -const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK] as const; +const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK] as const satisfies StepIdentifier[]; // updatestaging const FINISHRELEASECYCLE__UPDATESTAGING__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'UPDATESTAGING', ['ref', 'token'], []); @@ -164,7 +166,7 @@ const FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS = [ FINISHRELEASECYCLE__UPDATESTAGING__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__UPDATESTAGING__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK, FINISHRELEASECYCLE__UPDATESTAGING__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; export { FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, @@ -174,4 +176,4 @@ export { FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, -}; +}; \ No newline at end of file diff --git a/workflow_tests/mocks/lintMocks.ts b/workflow_tests/mocks/lintMocks.ts index 93a3fd190a41..c42a0c9794b6 100644 --- a/workflow_tests/mocks/lintMocks.ts +++ b/workflow_tests/mocks/lintMocks.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // lint @@ -13,7 +14,7 @@ const LINT__LINT__STEP_MOCKS = [ LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK, LINT__LINT__VERIFY_NO_PRETTIER__STEP_MOCK, LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK, -] as const; +] as const satisfies StepIdentifier[]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/utils/JobMocker.ts b/workflow_tests/utils/JobMocker.ts index b6dc99771dd2..171d625b2fe1 100644 --- a/workflow_tests/utils/JobMocker.ts +++ b/workflow_tests/utils/JobMocker.ts @@ -1,3 +1,4 @@ +import type {StepIdentifier} from '@kie/act-js'; import type {PathOrFileDescriptor} from 'fs'; import fs from 'fs'; import path from 'path'; @@ -11,12 +12,12 @@ type YamlWorkflow = { }; type MockJob = { - steps: MockJobStep[]; + steps: StepIdentifier[]; uses?: string; secrets?: string[]; with?: string; - outputs?: string[]; - runsOn?: string; + outputs?: Record; + runsOn: string; }; type MockJobs = Record; @@ -59,8 +60,8 @@ class JobMocker { jobWith = job.with; delete job.with; } - job.steps = mockJob.steps.map((step) => { - const mockStep: MockJobStep = { + job.steps = mockJob.steps.map((step): StepIdentifier => { + const mockStep: StepIdentifier = { name: step.name, run: step.mockWith, }; diff --git a/workflow_tests/utils/preGenerateTest.ts b/workflow_tests/utils/preGenerateTest.ts index 7698e618432d..c5e54d9a11c0 100644 --- a/workflow_tests/utils/preGenerateTest.ts +++ b/workflow_tests/utils/preGenerateTest.ts @@ -1,10 +1,11 @@ /* eslint no-console: ["error", { allow: ["warn", "log"] }] */ +import type {StepIdentifier} from '@kie/act-js'; import type {PathLike} from 'fs'; import fs from 'fs'; import path from 'path'; import {exit} from 'process'; import yaml from 'yaml'; -import type {MockJobStep, YamlMockJob, YamlWorkflow} from './JobMocker'; +import type {YamlMockJob, YamlWorkflow} from './JobMocker'; const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -97,7 +98,7 @@ describe('test workflow ${workflowName}', () => { }); `; -const mockStepTemplate = (stepMockName: string, step: MockJobStep, jobId: string | undefined) => ` +const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => ` const ${stepMockName} = utils.createMockStep( '${step.name ?? ''}', '${step.name ?? ''}', diff --git a/workflow_tests/utils/utils.ts b/workflow_tests/utils/utils.ts index df4cc0468963..143294b0745d 100644 --- a/workflow_tests/utils/utils.ts +++ b/workflow_tests/utils/utils.ts @@ -1,13 +1,10 @@ +import type {EventJSON} from '@kie/act-js/build/src/action-event/action-event.types'; import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import fs from 'fs'; import path from 'path'; import yaml from 'yaml'; import type ExtendedAct from './ExtendedAct'; -type EventOptions = { - action?: string; -}; - type StepAssertionInputEntry = {key: string; value: string}; type StepAssertion = { @@ -19,7 +16,7 @@ type StepAssertion = { function setUpActParams( act: ExtendedAct, event: string | null = null, - eventOptions: EventOptions | null = null, + eventOptions: EventJSON | null = null, secrets: Record | null = null, githubToken: string | null = null, envVars: Record | null = null, From 0af758749004ae734dbba4d55b8045e7c88d33b5 Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Mon, 25 Mar 2024 15:47:37 +0100 Subject: [PATCH 2/3] fix ts --- workflow_tests/lint.test.ts | 12 ++++++------ workflow_tests/mocks/lintMocks.ts | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.ts index 45af1a26c175..55225a774ab6 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.ts @@ -1,7 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/lintAssertions'; -import * as mocks from './mocks/lintMocks'; +import LINT__LINT__STEP_MOCKS from './mocks/lintMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; @@ -53,7 +53,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: mocks.LINT__LINT__STEP_MOCKS, + lint: LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -72,7 +72,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: mocks.LINT__LINT__STEP_MOCKS, + lint: LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -97,7 +97,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: mocks.LINT__LINT__STEP_MOCKS, + lint: LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -116,7 +116,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: mocks.LINT__LINT__STEP_MOCKS, + lint: LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -139,7 +139,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: mocks.LINT__LINT__STEP_MOCKS, + lint: LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), diff --git a/workflow_tests/mocks/lintMocks.ts b/workflow_tests/mocks/lintMocks.ts index f5c4dad9f080..5ce587ac7ed7 100644 --- a/workflow_tests/mocks/lintMocks.ts +++ b/workflow_tests/mocks/lintMocks.ts @@ -16,6 +16,4 @@ const LINT__LINT__STEP_MOCKS = [ LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export default { - LINT__LINT__STEP_MOCKS, -}; +export default LINT__LINT__STEP_MOCKS; From 2242025455d20092bf9e51dfd82ff9c540b48a63 Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Tue, 26 Mar 2024 09:10:55 +0100 Subject: [PATCH 3/3] move mocks to default exports --- workflow_tests/createNewVersion.test.ts | 2 +- workflow_tests/deploy.test.ts | 2 +- workflow_tests/deployBlocker.test.ts | 2 +- workflow_tests/finishReleaseCycle.test.ts | 2 +- workflow_tests/lint.test.ts | 12 ++++++------ workflow_tests/mocks/createNewVersionMocks.ts | 2 +- workflow_tests/mocks/deployBlockerMocks.ts | 2 +- workflow_tests/mocks/deployMocks.ts | 2 +- workflow_tests/mocks/finishReleaseCycleMocks.ts | 2 +- workflow_tests/mocks/lintMocks.ts | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/workflow_tests/createNewVersion.test.ts b/workflow_tests/createNewVersion.test.ts index 3eeefa640e1a..05dcc2b10073 100644 --- a/workflow_tests/createNewVersion.test.ts +++ b/workflow_tests/createNewVersion.test.ts @@ -1,7 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/createNewVersionAssertions'; -import * as mocks from './mocks/createNewVersionMocks'; +import mocks from './mocks/createNewVersionMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/deploy.test.ts b/workflow_tests/deploy.test.ts index 37ab104ea248..4edb3b252d38 100644 --- a/workflow_tests/deploy.test.ts +++ b/workflow_tests/deploy.test.ts @@ -1,7 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployAssertions'; -import * as mocks from './mocks/deployMocks'; +import mocks from './mocks/deployMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/deployBlocker.test.ts b/workflow_tests/deployBlocker.test.ts index 1e67498bc5a7..eb4cdc2c9497 100644 --- a/workflow_tests/deployBlocker.test.ts +++ b/workflow_tests/deployBlocker.test.ts @@ -2,7 +2,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployBlockerAssertions'; -import * as mocks from './mocks/deployBlockerMocks'; +import mocks from './mocks/deployBlockerMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/finishReleaseCycle.test.ts b/workflow_tests/finishReleaseCycle.test.ts index 567323eeb052..7f81137807f4 100644 --- a/workflow_tests/finishReleaseCycle.test.ts +++ b/workflow_tests/finishReleaseCycle.test.ts @@ -1,7 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/finishReleaseCycleAssertions'; -import * as mocks from './mocks/finishReleaseCycleMocks'; +import mocks from './mocks/finishReleaseCycleMocks'; import ExtendedAct from './utils/ExtendedAct'; import type {MockJobs} from './utils/JobMocker'; import * as utils from './utils/utils'; diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.ts index 55225a774ab6..e0b0fb13859d 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.ts @@ -1,7 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/lintAssertions'; -import LINT__LINT__STEP_MOCKS from './mocks/lintMocks'; +import mocks from './mocks/lintMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; @@ -53,7 +53,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: LINT__LINT__STEP_MOCKS, + lint: mocks.LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -72,7 +72,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: LINT__LINT__STEP_MOCKS, + lint: mocks.LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -97,7 +97,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: LINT__LINT__STEP_MOCKS, + lint: mocks.LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -116,7 +116,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: LINT__LINT__STEP_MOCKS, + lint: mocks.LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), @@ -139,7 +139,7 @@ describe('test workflow lint', () => { let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { - lint: LINT__LINT__STEP_MOCKS, + lint: mocks.LINT__LINT__STEP_MOCKS, }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), diff --git a/workflow_tests/mocks/createNewVersionMocks.ts b/workflow_tests/mocks/createNewVersionMocks.ts index 491307964ab8..dd094e6459e8 100644 --- a/workflow_tests/mocks/createNewVersionMocks.ts +++ b/workflow_tests/mocks/createNewVersionMocks.ts @@ -40,7 +40,7 @@ const CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS = [ CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export { +export default { CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS, CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS, diff --git a/workflow_tests/mocks/deployBlockerMocks.ts b/workflow_tests/mocks/deployBlockerMocks.ts index 52ed6396989c..b60d41383a1e 100644 --- a/workflow_tests/mocks/deployBlockerMocks.ts +++ b/workflow_tests/mocks/deployBlockerMocks.ts @@ -38,4 +38,4 @@ const DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS = [ DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export {DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS}; +export default {DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS}; diff --git a/workflow_tests/mocks/deployMocks.ts b/workflow_tests/mocks/deployMocks.ts index 4d17b304b444..5c0d79235d89 100644 --- a/workflow_tests/mocks/deployMocks.ts +++ b/workflow_tests/mocks/deployMocks.ts @@ -56,4 +56,4 @@ const DEPLOY_PRODUCTION_STEP_MOCKS = [ DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export {DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS}; +export default {DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS}; diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.ts b/workflow_tests/mocks/finishReleaseCycleMocks.ts index fb6a8a38ada1..23d81a557705 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.ts +++ b/workflow_tests/mocks/finishReleaseCycleMocks.ts @@ -167,7 +167,7 @@ const FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS = [ FINISHRELEASECYCLE__UPDATESTAGING__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export { +export default { FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, diff --git a/workflow_tests/mocks/lintMocks.ts b/workflow_tests/mocks/lintMocks.ts index 5ce587ac7ed7..27ce53afc1f4 100644 --- a/workflow_tests/mocks/lintMocks.ts +++ b/workflow_tests/mocks/lintMocks.ts @@ -16,4 +16,4 @@ const LINT__LINT__STEP_MOCKS = [ LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK, ] as const satisfies StepIdentifier[]; -export default LINT__LINT__STEP_MOCKS; +export default {LINT__LINT__STEP_MOCKS};