mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-26 17:09:11 -06:00
test: adding back protocol component tests (#27697)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
urlChanged: [],
|
||||
pageLoading: [],
|
||||
resetTest: [],
|
||||
responseEndedWithEmptyBody: [],
|
||||
}
|
||||
|
||||
getDbMetadata (): { offset: number, size: number } {
|
||||
@@ -50,6 +51,7 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
this.events.viewportChanged = []
|
||||
this.events.urlChanged = []
|
||||
this.events.pageLoading = []
|
||||
this.events.responseEndedWithEmptyBody = []
|
||||
}
|
||||
|
||||
connectToBrowser = (cdpClient) => {
|
||||
@@ -98,13 +100,17 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
}
|
||||
|
||||
commandLogAdded = (log) => {
|
||||
this.events.commandLogAdded.push(log)
|
||||
// we only care about logs that occur during a test
|
||||
if (log.testId) {
|
||||
this.events.commandLogAdded.push(log)
|
||||
}
|
||||
}
|
||||
|
||||
commandLogChanged = (log) => {
|
||||
// we only care about logs that occur during a test and
|
||||
// since the number of log changes can vary per run, we only want to record
|
||||
// the passed/failed ones to ensure the snapshot can be compared
|
||||
if (log.state === 'passed' || log.state === 'failed') {
|
||||
if (log.testId && (log.state === 'passed' || log.state === 'failed')) {
|
||||
this.events.commandLogChanged.push(log)
|
||||
}
|
||||
}
|
||||
@@ -133,11 +139,13 @@ export class AppCaptureProtocol implements AppCaptureProtocolInterface {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
responseEndedWithEmptyBody = (options: ResponseEndedWithEmptyBodyOptions) => {
|
||||
this.events.responseEndedWithEmptyBody.push(options)
|
||||
}
|
||||
|
||||
resetTest (testId: string): void {
|
||||
this.resetEvents()
|
||||
|
||||
this.events.resetTest.push(testId)
|
||||
}
|
||||
|
||||
responseEndedWithEmptyBody: (options: ResponseEndedWithEmptyBodyOptions) => {}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,16 @@ const {
|
||||
|
||||
// source: https://www.myintervals.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/
|
||||
const isoDateRegex = /"([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?"/g
|
||||
const numberRegex = /"(wallClockDuration|fnDuration|afterFnDuration|lifecycle|duration|timestamp|createdAtTimestamp|updatedAtTimestamp|x|y|top|left|topCenter|leftCenter)": (0|[1-9]\d*)(\.\d+)?/g
|
||||
const numberRegex = /"(wallClockDuration|fnDuration|afterFnDuration|lifecycle|duration|timestamp|createdAtTimestamp|updatedAtTimestamp|x|y|top|left|topCenter|leftCenter|requestId)": \"?(0|[1-9]\d*)(\.\d+)?\"?/g
|
||||
const pathRegex = /"(name|absoluteFile)": "\/[^"]+"/g
|
||||
const componentSpecPathRegex = /"(url|message)": "(http:\/\/localhost:2121\/__cypress\/iframes\/index.html\?specPath=)(.*)(\/protocol\/src\/components\/)(.*)"/g
|
||||
|
||||
const normalizeEvents = (resultsJson) => {
|
||||
return resultsJson
|
||||
.replace(isoDateRegex, '"2015-03-18T00:00:00.000Z"')
|
||||
.replace(numberRegex, '"$1": 100')
|
||||
.replace(isoDateRegex, '"Any.ISODate"')
|
||||
.replace(numberRegex, '"$1": "Any.Number"')
|
||||
.replace(pathRegex, '"$1": "/path/to/$1"')
|
||||
.replace(componentSpecPathRegex, '"$1": "$2$4$5"')
|
||||
}
|
||||
|
||||
const getFilePath = (filename) => {
|
||||
@@ -56,8 +58,7 @@ describe('capture-protocol', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// TODO: skip for now because the component tests are failing with the new route consolidation logic
|
||||
describe.skip('component', () => {
|
||||
describe('component', () => {
|
||||
[true, false].forEach((experimentalSingleTabRunMode) => {
|
||||
it('verifies the protocol events are correct', function () {
|
||||
return systemTests.exec(this, {
|
||||
|
||||
Reference in New Issue
Block a user