Skip to content

Commit

Permalink
refactor: after review [sc-18837]
Browse files Browse the repository at this point in the history
  • Loading branch information
maxigimenez committed Mar 7, 2024
1 parent a186647 commit b9b4e4e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class Deploy extends AuthCommand {
repoUrl: checklyConfig.repoUrl,
checkMatch: checklyConfig.checks?.checkMatch,
browserCheckMatch: checklyConfig.checks?.browserChecks?.testMatch,
multistepCheckMatch: checklyConfig.checks?.multistepChecks?.testMatch,
multiStepCheckMatch: checklyConfig.checks?.multiStepChecks?.testMatch,
ignoreDirectoriesMatch: checklyConfig.checks?.ignoreDirectoriesMatch,
checkDefaults: checklyConfig.checks,
browserCheckDefaults: checklyConfig.checks?.browserChecks,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class Test extends AuthCommand {
repoUrl: checklyConfig.repoUrl,
checkMatch: checklyConfig.checks?.checkMatch,
browserCheckMatch: checklyConfig.checks?.browserChecks?.testMatch,
multistepCheckMatch: checklyConfig.checks?.multistepChecks?.testMatch,
multiStepCheckMatch: checklyConfig.checks?.multiStepChecks?.testMatch,
ignoreDirectoriesMatch: checklyConfig.checks?.ignoreDirectoriesMatch,
checkDefaults: checklyConfig.checks,
browserCheckDefaults: checklyConfig.checks?.browserChecks,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/constructs/check-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class CheckGroup extends Construct {
if (props.browserChecks?.testMatch) {
this.__addChecks(fileAbsolutePath, props.browserChecks.testMatch, CheckTypes.BROWSER)
}
this.multiStepChecks = props.multiStepChecks
if (props.multiStepChecks?.testMatch) {
this.__addChecks(fileAbsolutePath, props.multiStepChecks.testMatch, CheckTypes.MULTI_STEP)
}
Expand Down Expand Up @@ -272,7 +273,7 @@ export class CheckGroup extends Construct {

public getMultiStepCheckDefaults (): CheckConfigDefaults {
return {
frequency: this.browserChecks?.frequency,
frequency: this.multiStepChecks?.frequency,
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/services/__tests__/project-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('parseProject()', () => {
availableRuntimes: runtimes,
checkMatch: [],
browserCheckMatch: ['**/__checks__/browser/*.spec.js'],
multistepCheckMatch: ['**/__checks__/multistep/*.spec.js'],
multiStepCheckMatch: ['**/__checks__/multistep/*.spec.js'],
checkDefaults: {
runtimeId: '2023.09',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/services/checkly-config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type ChecklyConfig = {
/**
* Multistep checks default configuration properties.
*/
multistepChecks?: CheckConfigDefaults & {
multiStepChecks?: CheckConfigDefaults & {
/**
* Glob pattern where the CLI looks for Playwright test files, i.e. all `.spec.ts` files
*/
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/services/project-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ProjectParseOpts = {
repoUrl?: string,
checkMatch?: string | string[],
browserCheckMatch?: string | string[],
multistepCheckMatch?: string | string[],
multiStepCheckMatch?: string | string[],
ignoreDirectoriesMatch?: string[],
checkDefaults?: CheckConfigDefaults,
browserCheckDefaults?: CheckConfigDefaults,
Expand All @@ -35,7 +35,7 @@ export async function parseProject (opts: ProjectParseOpts): Promise<Project> {
directory,
checkMatch = '**/*.check.{js,ts}',
browserCheckMatch,
multistepCheckMatch,
multiStepCheckMatch,
projectLogicalId,
projectName,
repoUrl,
Expand All @@ -62,7 +62,7 @@ export async function parseProject (opts: ProjectParseOpts): Promise<Project> {
const ignoreDirectories = ['**/node_modules/**', '**/.git/**', ...ignoreDirectoriesMatch]
await loadAllCheckFiles(directory, checkMatch, ignoreDirectories)
await loadAllBrowserChecks(directory, browserCheckMatch, ignoreDirectories, project)
await loadAllMultistepChecks(directory, multistepCheckMatch, ignoreDirectories, project)
await loadAllMultiStepChecks(directory, multiStepCheckMatch, ignoreDirectories, project)

// private-location must be processed after all checks and groups are loaded.
await loadAllPrivateLocationsSlugNames(project)
Expand Down Expand Up @@ -127,16 +127,16 @@ async function loadAllBrowserChecks (
}
}

async function loadAllMultistepChecks (
async function loadAllMultiStepChecks (
directory: string,
multistepCheckFilePattern: string | string[] | undefined,
multiStepCheckFilePattern: string | string[] | undefined,
ignorePattern: string[],
project: Project,
): Promise<void> {
if (!multistepCheckFilePattern) {
if (!multiStepCheckFilePattern) {
return
}
const checkFiles = await findFilesWithPattern(directory, multistepCheckFilePattern, ignorePattern)
const checkFiles = await findFilesWithPattern(directory, multiStepCheckFilePattern, ignorePattern)
const preexistingCheckFiles = new Set<string>()
Object.values(project.data.check).forEach((check) => {
if ((check instanceof MultiStepCheck || check instanceof BrowserCheck) && check.scriptPath) {
Expand Down

0 comments on commit b9b4e4e

Please sign in to comment.