Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/cli/src/constructs/__tests__/playwright-check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('PlaywrightCheck', () => {
})

it('should synthesize groupName', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -49,6 +50,7 @@ describe('PlaywrightCheck', () => {
})

it('should synthesize group', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -76,6 +78,7 @@ describe('PlaywrightCheck', () => {
})

it('should synthesize groupId', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -104,6 +107,7 @@ describe('PlaywrightCheck', () => {

describe('validation', () => {
it('should warn that groupName is deprecated', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -132,6 +136,7 @@ describe('PlaywrightCheck', () => {
})

it('should error if groupName is not found', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -160,6 +165,7 @@ describe('PlaywrightCheck', () => {
})

it('should error if both group and groupName are set', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -188,6 +194,7 @@ describe('PlaywrightCheck', () => {
})

it('should error if both groupId and groupName are set', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down Expand Up @@ -216,6 +223,7 @@ describe('PlaywrightCheck', () => {
})

it('should error if retryStrategy is set', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand All @@ -240,6 +248,7 @@ describe('PlaywrightCheck', () => {
})

it('should error if doubleCheck is set', async () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand All @@ -248,6 +257,7 @@ describe('PlaywrightCheck', () => {
const check = new PlaywrightCheck('foo', {
name: 'Test Check',
playwrightConfigPath: path.resolve(__dirname, './fixtures/playwright-check/playwright.config.ts'),
// @ts-expect-error Testing a property that isn't part of the type.
doubleCheck: true,
})

Expand All @@ -265,6 +275,7 @@ describe('PlaywrightCheck', () => {

describe('defaults', () => {
it('should ignore retryStrategy from session check defaults', () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand All @@ -283,6 +294,7 @@ describe('PlaywrightCheck', () => {
})

it('should ignore doubleCheck from session check defaults', () => {
Session.basePath = path.resolve(__dirname, './fixtures/playwright-check')
Session.project = new Project('project-id', {
name: 'Test Project',
repoUrl: 'https://github.com/checkly/checkly-cli',
Expand Down
43 changes: 34 additions & 9 deletions packages/cli/src/services/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export async function bundlePlayWrightProject (
outputFile,
browsers: pwConfigParsed.getBrowsers(),
playwrightVersion,
relativePlaywrightConfigPath: path.relative(dir, filePath),
relativePlaywrightConfigPath: Session.relativePosixPath(filePath),
cacheHash,
})
})
Expand Down Expand Up @@ -286,24 +286,49 @@ export async function loadPlaywrightProjectFiles (
const ignoredFiles = ['**/node_modules/**', '.git/**']
const parser = new Parser({})
const { files, errors } = await parser.getFilesAndDependencies(pwConfigParsed)
const mode = 0o755 // Default mode for files in the archive
if (errors.length) {
throw new Error(`Error loading playwright project files: ${errors.map((e: string) => e).join(', ')}`)
}
const root = Session.basePath!
const prefix = Session.relativePosixPath(dir)
const entryDefaults = {
mode: 0o755, // Default mode for files in the archive
}
for (const file of files) {
const relativePath = path.relative(dir, file)
archive.file(file, { name: relativePath, mode })
archive.file(file, {
...entryDefaults,
name: Session.relativePosixPath(file),
})
}
const lockFileDirName = path.dirname(lockFile)
archive.file(lockFile, { name: path.basename(lockFile), mode })
archive.file(path.join(lockFileDirName, 'package.json'), { name: 'package.json', mode })
const packageJsonFile = path.join(lockFileDirName, 'package.json')
archive.file(lockFile, {
...entryDefaults,
name: Session.relativePosixPath(lockFile),
})
archive.file(packageJsonFile, {
...entryDefaults,
name: Session.relativePosixPath(packageJsonFile),
})
// handle workspaces
archive.glob('**/package.json', { cwd: path.join(dir, '/'), ignore: ignoredFiles }, { mode })
archive.glob('**/package.json', {
cwd: dir,
ignore: ignoredFiles,
}, {
...entryDefaults,
prefix,
})
for (const includePattern of include) {
archive.glob(includePattern, { cwd: path.join(dir, '/') }, { mode })
archive.glob(includePattern, { cwd: dir }, {
...entryDefaults,
prefix,
})
}
for (const filePath of extraFiles) {
archive.file(path.resolve(dir, filePath), { name: filePath, mode })
archive.file(path.resolve(root, filePath), {
...entryDefaults,
name: Session.relativePosixPath(filePath),
})
}
}

Expand Down