mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-01 04:20:23 -05:00
chore: fixes url validation error on artifact report (#27671)
This commit is contained in:
@@ -247,7 +247,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => {
|
||||
return {
|
||||
key: artifact.reportKey,
|
||||
skipped: true,
|
||||
url: artifact.url || '',
|
||||
url: artifact.uploadUrl,
|
||||
...(artifact.error && { error: artifact.error, success: false }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3362,7 +3362,7 @@ exports['e2e record capture-protocol enabled protocol runtime errors error in pr
|
||||
|
||||
- Video - Nothing to upload
|
||||
- Screenshot - 1 kB /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png
|
||||
- Test Replay - Failed Capturing - Error constructing AppCaptureProtocol
|
||||
- Test Replay - Failed Capturing - Error in beforeSpec
|
||||
|
||||
(Uploaded Cloud Artifacts)
|
||||
|
||||
@@ -3550,3 +3550,84 @@ exports['capture-protocol api errors upload 500 - retries 5 times and succeeds o
|
||||
|
||||
|
||||
`
|
||||
|
||||
exports['e2e record capture-protocol enabled protocol runtime errors error in protocol beforeTest displays the error and reports the fatal error to the cloud via artifacts 1'] = `
|
||||
|
||||
====================================================================================================
|
||||
|
||||
(Run Starting)
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Cypress: 1.2.3 │
|
||||
│ Browser: FooBrowser 88 │
|
||||
│ Specs: 1 found (record_pass.cy.js) │
|
||||
│ Searched: cypress/e2e/record_pass* │
|
||||
│ Params: Tag: false, Group: false, Parallel: false │
|
||||
│ Run URL: https://dashboard.cypress.io/projects/cjvoj7/runs/12 │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Running: record_pass.cy.js (1 of 1)
|
||||
Estimated: X second(s)
|
||||
|
||||
|
||||
record pass
|
||||
✓ passes
|
||||
- is pending
|
||||
|
||||
|
||||
1 passing
|
||||
1 pending
|
||||
|
||||
|
||||
(Results)
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Tests: 2 │
|
||||
│ Passing: 1 │
|
||||
│ Failing: 0 │
|
||||
│ Pending: 1 │
|
||||
│ Skipped: 0 │
|
||||
│ Screenshots: 1 │
|
||||
│ Video: false │
|
||||
│ Duration: X seconds │
|
||||
│ Estimated: X second(s) │
|
||||
│ Spec Ran: record_pass.cy.js │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
(Screenshots)
|
||||
|
||||
- /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png (400x1022)
|
||||
|
||||
|
||||
(Uploading Cloud Artifacts)
|
||||
|
||||
- Video - Nothing to upload
|
||||
- Screenshot - 1 kB /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png
|
||||
- Test Replay - Failed Capturing - error in beforeTest
|
||||
|
||||
(Uploaded Cloud Artifacts)
|
||||
|
||||
- Screenshot - Done Uploading 1 kB 1/1 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png
|
||||
|
||||
====================================================================================================
|
||||
|
||||
(Run Finished)
|
||||
|
||||
|
||||
Spec Tests Passing Failing Pending Skipped
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ ✔ record_pass.cy.js XX:XX 2 1 - 1 - │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
✔ All specs passed! XX:XX 2 1 - 1 -
|
||||
|
||||
|
||||
───────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Recorded Run: https://dashboard.cypress.io/projects/cjvoj7/runs/12
|
||||
|
||||
|
||||
`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import type { AppCaptureProtocolInterface, ResponseStreamOptions } from '@packages/types'
|
||||
import type { AppCaptureProtocolInterface, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions } from '@packages/types'
|
||||
import type { Readable } from 'stream'
|
||||
|
||||
const getFilePath = (filename) => {
|
||||
@@ -133,4 +133,6 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
|
||||
this.events.resetTest.push(testId)
|
||||
}
|
||||
|
||||
responseEndedWithEmptyBody: (options: ResponseEndedWithEmptyBodyOptions) => {}
|
||||
}
|
||||
|
||||
@@ -46,3 +46,5 @@ export const PROTOCOL_STUB_CONSTRUCTOR_ERROR = stub('protocolStubWithRuntimeErro
|
||||
export const PROTOCOL_STUB_BEFORESPEC_ERROR = stub('protocolStubWithBeforeSpecError.ts')
|
||||
|
||||
export const PROTOCOL_STUB_NONFATAL_ERROR = stub('protocolStubWithNonFatalError.ts')
|
||||
|
||||
export const PROTOCOL_STUB_BEFORETEST_ERROR = stub('protocolStubWithBeforeTestError.ts')
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import type { AppCaptureProtocolInterface, CDPClient, ResponseStreamOptions } from '@packages/types'
|
||||
import type { AppCaptureProtocolInterface, CDPClient, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions } from '@packages/types'
|
||||
import type { Readable } from 'stream'
|
||||
|
||||
export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
constructor () {
|
||||
throw new Error('Error constructing AppCaptureProtocol')
|
||||
}
|
||||
getDbMetadata (): { offset: number, size: number } {
|
||||
return {
|
||||
offset: 0,
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
beforeSpec ({ archivePath, db }): void {}
|
||||
beforeSpec ({ archivePath, db }): void {
|
||||
throw new Error('Error in beforeSpec')
|
||||
}
|
||||
responseStreamReceived (options: ResponseStreamOptions): Readable {
|
||||
return options.responseStream
|
||||
}
|
||||
@@ -37,4 +36,5 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
}
|
||||
pageLoading (input: any): void {}
|
||||
resetTest (testId: string): void {}
|
||||
responseEndedWithEmptyBody: (options: ResponseEndedWithEmptyBodyOptions) => {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { AppCaptureProtocolInterface, CDPClient, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions } from '@packages/types'
|
||||
import type { Readable } from 'stream'
|
||||
|
||||
export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
getDbMetadata (): { offset: number, size: number } {
|
||||
return {
|
||||
offset: 0,
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
beforeSpec ({ archivePath, db }): void {
|
||||
//throw new Error('Error constructing AppCaptureProtocol')
|
||||
}
|
||||
responseStreamReceived (options: ResponseStreamOptions): Readable {
|
||||
return options.responseStream
|
||||
}
|
||||
addRunnables (runnables: any): void {}
|
||||
commandLogAdded (log: any): void {}
|
||||
commandLogChanged (log: any): void {}
|
||||
viewportChanged (input: any): void {}
|
||||
urlChanged (input: any): void {}
|
||||
beforeTest (test: Record<string, any>): Promise<void> {
|
||||
return Promise.reject(new Error('error in beforeTest'))
|
||||
//return Promise.resolve()
|
||||
}
|
||||
preAfterTest (test: Record<string, any>, options: Record<string, any>): Promise<void> {
|
||||
//return Promise.reject(new Error('error in preAfterTest'))
|
||||
|
||||
return Promise.resolve()
|
||||
}
|
||||
afterTest (test: Record<string, any>): Promise<void> {
|
||||
//return Promise.reject(new Error('error in afterTest'))
|
||||
return Promise.resolve()
|
||||
}
|
||||
afterSpec (): Promise<void> {
|
||||
//return Promise.reject(new Error('error in afterSpec'))
|
||||
return Promise.resolve()
|
||||
}
|
||||
connectToBrowser (cdpClient: CDPClient): Promise<void> {
|
||||
//return Promise.reject(new Error('error in connectToBrowser'))
|
||||
return Promise.resolve()
|
||||
}
|
||||
pageLoading (input: any): void {}
|
||||
resetTest (testId: string): void {}
|
||||
responseEndedWithEmptyBody (options: ResponseEndedWithEmptyBodyOptions) {
|
||||
//throw new Error('error in responseEndedWithEmptyBody')
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AppCaptureProtocolInterface, CDPClient, ResponseStreamOptions } from '@packages/types'
|
||||
import type { AppCaptureProtocolInterface, CDPClient, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions } from '@packages/types'
|
||||
import type { Readable } from 'stream'
|
||||
|
||||
export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
@@ -36,4 +36,5 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
}
|
||||
pageLoading (input: any): void {}
|
||||
resetTest (testId: string): void {}
|
||||
responseEndedWithEmptyBody: (options: ResponseEndedWithEmptyBodyOptions) => {}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AppCaptureProtocolInterface, ResponseStreamOptions } from '@packages/types'
|
||||
import type { AppCaptureProtocolInterface, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions } from '@packages/types'
|
||||
import type { Readable } from 'stream'
|
||||
|
||||
export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
@@ -38,4 +38,5 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
afterTest = (test) => {
|
||||
return Promise.resolve()
|
||||
}
|
||||
responseEndedWithEmptyBody: (options: ResponseEndedWithEmptyBodyOptions) => {}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const {
|
||||
} = require('../lib/serverStub')
|
||||
const { expectRunsToHaveCorrectTimings } = require('../lib/resultsUtils')
|
||||
const { randomBytes } = require('crypto')
|
||||
const { PROTOCOL_STUB_CONSTRUCTOR_ERROR, PROTOCOL_STUB_NONFATAL_ERROR, PROTOCOL_STUB_BEFORESPEC_ERROR } = require('../lib/protocol-stubs/protocolStubResponse')
|
||||
const { PROTOCOL_STUB_CONSTRUCTOR_ERROR, PROTOCOL_STUB_NONFATAL_ERROR, PROTOCOL_STUB_BEFORESPEC_ERROR, PROTOCOL_STUB_BEFORETEST_ERROR } = require('../lib/protocol-stubs/protocolStubResponse')
|
||||
const debug = require('debug')('cypress:system-tests:record_spec')
|
||||
const e2ePath = Fixtures.projectPath('e2e')
|
||||
const outputPath = path.join(e2ePath, 'output.json')
|
||||
@@ -2339,7 +2339,7 @@ describe('e2e record', () => {
|
||||
|
||||
expect(artifactReport?.protocol).to.exist()
|
||||
expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty()
|
||||
expect(artifactReport?.protocol?.url).to.exist()
|
||||
expect(artifactReport?.protocol?.url).to.exist().and.not.be.empty()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -2364,7 +2364,7 @@ describe('e2e record', () => {
|
||||
|
||||
expect(artifactReport?.protocol).to.exist()
|
||||
expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty()
|
||||
expect(artifactReport?.protocol?.url).to.exist()
|
||||
expect(artifactReport?.protocol?.url).to.exist().and.not.be.empty()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -2389,7 +2389,32 @@ describe('e2e record', () => {
|
||||
|
||||
expect(artifactReport?.protocol).to.exist()
|
||||
expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty()
|
||||
expect(artifactReport?.protocol?.url).to.exist()
|
||||
expect(artifactReport?.protocol?.url).to.exist().and.not.be.empty()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('error in protocol beforeTest', () => {
|
||||
enableCaptureProtocol(PROTOCOL_STUB_BEFORETEST_ERROR)
|
||||
|
||||
it('displays the error and reports the fatal error to the cloud via artifacts', function () {
|
||||
return systemTests.exec(this, {
|
||||
key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',
|
||||
configFile: 'cypress-with-project-id.config.js',
|
||||
spec: 'record_pass*',
|
||||
record: true,
|
||||
snapshot: true,
|
||||
}).then(() => {
|
||||
const urls = getRequestUrls()
|
||||
|
||||
expect(urls).to.include.members([`PUT /instances/${instanceId}/artifacts`])
|
||||
expect(urls).not.to.include.members([`PUT ${CAPTURE_PROTOCOL_UPLOAD_URL}`])
|
||||
|
||||
const artifactReport = getRequests().find(({ url }) => url === `PUT /instances/${instanceId}/artifacts`)?.body
|
||||
|
||||
expect(artifactReport?.protocol).to.exist()
|
||||
expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty()
|
||||
expect(artifactReport?.protocol?.url).to.exist().and.not.be.empty()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user