Skip to content

Commit

Permalink
feat: add ability to filter by group tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrandiaz committed Nov 22, 2023
1 parent 6d5a909 commit 98368f3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { loadChecklyConfig } from '../services/checkly-config-loader'
import { filterByFileNamePattern, filterByCheckNamePattern, filterByTags } from '../services/test-filters'
import type { Runtime } from '../rest/runtimes'
import { AuthCommand } from './authCommand'
import { BrowserCheck, Check, HeartbeatCheck, Session } from '../constructs'
import { BrowserCheck, Check, HeartbeatCheck, Project, Session } from '../constructs'
import type { Region } from '..'
import { splitConfigFilePath, getGitInformation, getCiInformation, getEnvs } from '../services/util'
import { createReporters, ReporterType } from '../reporters/reporter'
Expand Down Expand Up @@ -181,7 +181,13 @@ export default class Test extends AuthCommand {
return filterByCheckNamePattern(grep, check.name)
})
.filter(([, check]) => {
return filterByTags(targetTags?.map((tags: string) => tags.split(',')) ?? [], check.tags)
const tags = check.tags ?? []
const checkGroup = this.getCheckGroup(project, check)
if (checkGroup) {
const checkGroupTags = checkGroup.tags ?? []
tags.concat(checkGroupTags)
}
return filterByTags(targetTags?.map((tags: string) => tags.split(',')) ?? [], tags)
})
.map(([key, check]) => {
check.logicalId = key
Expand Down Expand Up @@ -346,4 +352,12 @@ export default class Test extends AuthCommand {
}
}
}

private getCheckGroup (project: Project, check: Check) {
if (!check.groupId) {
return
}
const ref = check.groupId.ref.toString()
return project.data['check-group'][ref]
}
}

0 comments on commit 98368f3

Please sign in to comment.