Skip to content

Commit

Permalink
Merge branch 'develop' into issue-28336-privileged-command-basic-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Nov 29, 2023
2 parents ebae3e8 + 7ba92b9 commit e7fc217
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 131 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ _Released 12/5/2023 (PENDING)_
- Fixed an issue where request logging would default the `message` to the `args` of the currently running command even though those `args` would not apply to the request log and are not displayed. If the `args` are sufficiently large (e.g. when running the `cy.task` from the [code-coverage](https://github.com/cypress-io/code-coverage/) plugin) there could be performance/memory implications. Addressed in [#28411](https://github.com/cypress-io/cypress/pull/28411).
- Fixed an issue where commands would fail with the error `must only be invoked from the spec file or support file` if the project's `baseUrl` included basic auth credentials. Fixes [#28336](https://github.com/cypress-io/cypress/issues/28336).

**Misc:**

- Artifact upload duration is now reported to Cypress Cloud. Addressed in [#28418](https://github.com/cypress-io/cypress/pull/28418)

## 13.6.0

_Released 11/21/2023_
Expand Down
13 changes: 13 additions & 0 deletions npm/puppeteer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# [@cypress/puppeteer-v0.1.1](https://github.com/cypress-io/cypress/compare/@cypress/puppeteer-v0.1.0...@cypress/puppeteer-v0.1.1) (2023-11-29)


### Bug Fixes

* Resolve types and dist issues with @cypress/puppeteer ([#28424](https://github.com/cypress-io/cypress/issues/28424)) ([72225db](https://github.com/cypress-io/cypress/commit/72225db03327744844dcfbcc72b40e85de6a2761))

# [@cypress/puppeteer-v0.1.0](https://github.com/cypress-io/cypress/compare/@cypress/puppeteer-v0.0.1...@cypress/puppeteer-v0.1.0) (2023-11-28)


### Features

* Initial release ([#28370](https://github.com/cypress-io/cypress/issues/28370)) ([b34d145](https://github.com/cypress-io/cypress/commit/b34d14571689a9b36efc707a3a48f27edcb98113))
6 changes: 3 additions & 3 deletions npm/puppeteer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Add the following in `tsconfig.json`:
```json
{
"compilerOptions": {
"types": ["cypress", "@cypress/puppeteer"]
"types": ["cypress", "@cypress/puppeteer/support"]
}
}
```
Expand All @@ -55,7 +55,7 @@ While the `cy.puppeteer()` command is executed in the browser, the majority of t
In your Cypress config (e.g. `cypress.config.ts`):

```typescript
import { setup } from '@cypress/puppeteer/plugin'
import { setup } from '@cypress/puppeteer'

export default defineConfig({
e2e: {
Expand All @@ -76,7 +76,7 @@ export default defineConfig({
In your support file (e.g. `cypress/support/e2e.ts`):
```typescript
import { setup } from '@cypress/puppeteer/support'
import '@cypress/puppeteer/support'
```
In your spec (e.g. `spec.cy.ts`):
Expand Down
4 changes: 2 additions & 2 deletions npm/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
},
"files": [
"dist",
"index.d.ts"
"support"
],
"types": "index.d.ts",
"types": "dist/plugin/index.d.ts",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions npm/puppeteer/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('../dist/support')
4 changes: 2 additions & 2 deletions npm/puppeteer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"strictNullChecks": true,
"target": "ES2020",
"types": [
"cypress"
"cypress",
"./support"
]
},
"include": [
"index.d.ts",
"src/"
]
}
47 changes: 23 additions & 24 deletions packages/server/lib/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,31 @@ type CreateRunResponse = {
} | undefined
}

type ArtifactMetadata = {
url: string
fileSize?: number
uploadDuration?: number
success: boolean
error?: string
}

type ProtocolMetadata = ArtifactMetadata & {
specAccess?: {
size: bigint
offset: bigint
}
}

type UpdateInstanceArtifactsPayload = {
screenshots: ArtifactMetadata[]
video?: ArtifactMetadata
protocol?: ProtocolMetadata
}

type UpdateInstanceArtifactsOptions = {
runId: string
instanceId: string
timeout: number | undefined
protocol: {
url: string
success: boolean
fileSize?: number | undefined
error?: string | undefined
} | undefined
screenshots: {
url: string
success: boolean
fileSize?: number | undefined
error?: string | undefined
}[] | undefined
video: {
url: string
success: boolean
fileSize?: number | undefined
error?: string | undefined
} | undefined
}

let preflightResult = {
Expand Down Expand Up @@ -497,17 +500,13 @@ module.exports = {
})
},

updateInstanceArtifacts (options: UpdateInstanceArtifactsOptions) {
updateInstanceArtifacts (options: UpdateInstanceArtifactsOptions, body: UpdateInstanceArtifactsPayload) {
return retryWithBackoff((attemptIndex) => {
return rp.put({
url: recordRoutes.instanceArtifacts(options.instanceId),
json: true,
timeout: options.timeout ?? SIXTY_SECONDS,
body: {
protocol: options.protocol,
screenshots: options.screenshots,
video: options.video,
},
body,
headers: {
'x-route-version': '1',
'x-cypress-run-id': options.runId,
Expand Down
15 changes: 7 additions & 8 deletions packages/server/lib/modes/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
url: artifact.uploadUrl,
fileSize: artifact.fileSize,
key: artifact.reportKey,
duration: performance.now() - startTime,
uploadDuration: performance.now() - startTime,
}
}

Expand All @@ -289,7 +289,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
pathToFile: artifact.filePath,
fileSize: artifact.fileSize,
key: artifact.reportKey,
duration: performance.now() - startTime,
uploadDuration: performance.now() - startTime,
}
} catch (err) {
debug('failed to upload artifact %o', {
Expand All @@ -308,7 +308,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
allErrors: err.errors,
url: artifact.uploadUrl,
pathToFile: artifact.filePath,
duration: performance.now() - startTime,
uploadDuration: performance.now() - startTime,
}
}

Expand All @@ -318,7 +318,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
error: err.message,
url: artifact.uploadUrl,
pathToFile: artifact.filePath,
duration: performance.now() - startTime,
uploadDuration: performance.now() - startTime,
}
}
}),
Expand Down Expand Up @@ -355,8 +355,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
return skipped && !report.error ? acc : {
...acc,
[key]: {
// TODO: once cloud supports reporting duration, no longer omit this
..._.omit(report, 'duration'),
...report,
error,
},
}
Expand Down Expand Up @@ -452,8 +451,8 @@ const uploadArtifacts = async (options = {}) => {
try {
debug('upload reprt: %O', uploadReport)
const res = await api.updateInstanceArtifacts({
runId, instanceId, ...uploadReport,
})
runId, instanceId,
}, uploadReport)

return res
} catch (err) {
Expand Down
8 changes: 4 additions & 4 deletions packages/server/lib/util/print-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,11 @@ type ArtifactUploadResultLike = {
success: boolean
error?: string
skipped?: boolean
duration?: number
uploadDuration?: number
}

export const printCompletedArtifactUpload = <T extends ArtifactUploadResultLike> (artifactUploadResult: T, labels: Record<'protocol' | 'screenshots' | 'video', string>, num: string): void => {
const { pathToFile, key, fileSize, success, error, skipped, duration } = artifactUploadResult
const { pathToFile, key, fileSize, success, error, skipped, uploadDuration } = artifactUploadResult

process.stdout.write(` - ${labels[key]} `)

Expand All @@ -630,8 +630,8 @@ export const printCompletedArtifactUpload = <T extends ArtifactUploadResultLike>
process.stdout.write(`- Failed Uploading`)
}

if (duration) {
const durationOut = humanTime.short(duration, 2)
if (uploadDuration) {
const durationOut = humanTime.short(uploadDuration, 2)

process.stdout.write(` ${success ? 'in' : 'after'} ${durationOut}`)
}
Expand Down
12 changes: 9 additions & 3 deletions packages/server/test/unit/cloud/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1524,20 +1524,26 @@ describe('lib/cloud/api', () => {

context('.updateInstanceArtifacts', () => {
beforeEach(function () {
this.artifactProps = {
this.artifactOptions = {
runId: 'run-id-123',
instanceId: 'instance-id-123',
}

this.artifactProps = {
screenshots: [{
url: `http://localhost:1234/screenshots/upload/instance-id-123/a877e957-f90e-4ba4-9fa8-569812f148c4.png`,
uploadSize: 100,
uploadDuration: 100,
}],
video: {
url: `http://localhost:1234/video/upload/instance-id-123/f17754c4-581d-4e08-a922-1fa402f9c6de.mp4`,
uploadSize: 122,
uploadDuration: 100,
},
protocol: {
url: `http://localhost:1234/protocol/upload/instance-id-123/2ed89c81-e7eb-4b97-8a6e-185c410471df.db`,
uploadSize: 123,
uploadDuration: 100,
},
}
// TODO: add schema validation
Expand All @@ -1546,7 +1552,7 @@ describe('lib/cloud/api', () => {
it('PUTs/instances/:id/artifacts', function () {
nock(API_BASEURL)
.matchHeader('x-route-version', '1')
.matchHeader('x-cypress-run-id', this.artifactProps.runId)
.matchHeader('x-cypress-run-id', this.artifactOptions.runId)
.matchHeader('x-cypress-request-attempt', '0')
.matchHeader('x-os-name', 'linux')
.matchHeader('x-cypress-version', pkg.version)
Expand All @@ -1557,7 +1563,7 @@ describe('lib/cloud/api', () => {
})
.reply(200)

return api.updateInstanceArtifacts(this.artifactProps)
return api.updateInstanceArtifacts(this.artifactOptions, this.artifactProps)
})
})
})
Loading

0 comments on commit e7fc217

Please sign in to comment.