Files
cypress/system-tests/test/results_spec.ts
T
Cacie Prins 0547d65a2a breaking: no longer inject document.domain by default (#30770)
* remove experimentalSkipDomainInjection, add and deprecate injectDocumentDomain

* remove experimentalSkipDomainInjection, add injectDocumentDomain

* begin rethreading domain injection

* complete document domain transition

* move some cookie specs to separate test run

* origin and privileged commands with default docdom inject

* fix privileged channel when injecting document domain

* rm unnecessary .getOrigin abstraction in cors lib

* move remote-states in prep for refactor Replace Conditional with Polymorphism

* refactor remote states to strategy pattern

* cookie commands work as expected w cross origin bridge on different origins

* some origin tests updated

* run tests with document domain enabled

* run tests actually

* use correct config, swap conditional

* check-ts

* inject documetn domain for webkit tests

* do not exec injectDocumetnDomain in parallel

* fix ServerBase construction in tests to include cfg now

* pass cfg to ServerBase

* improved integration tests

* remove document domain checks for all server integration specs - will add injectDocumentDomain cases

* tests for injecting document domain when configured to

* square away server integration tests

* ensure cookies are set correctly, potentially

* errors pkg snapshots

* fix config tests

* fixing config tests

* somewhat improves tests for cors policies in packages/network

* fix ts err in server-base

* enable injectDocumentDomain for cy in cy tests

* fix Policy type ref

* refactor cypress-schematic ct spec to be less prone to timeouts

* run vite-dev-server tests with injectDocumentDomain

* rm document domain assertion from page_loading system test

* add system tests that test with injectDocumentDomain and others that test with cy.origin

* fix results_spec snapshot

* update experimentalSkipDomainInjection system test

* different behavior for certain net_stubbing tests based on injectDocumentDomain or not

* fix ts

* extract origin key logic from remote states, for now

* move server-base and response-middleware over to new pattern

* WIP - reentry

* fix build, remove console.log

* check-ts

* fix spec frame injection

* remove injection for localhost

* mostly fix vite-dev-server app integration tests

* fix codeframe in certain cases in chrome

* drop internal stack frames from stacks intended for determining code frame data

* some improvements to vite ct error codeframes

* fix proxy unit tests to use document domain injection util class

* rm .only

* fix all vite ct error specs

* rm console.log

* slight refactor to util class to make easier to test

* fix refactor - missing rename in files.js

* several tests do not set testingtype in config, so just check against component instead of checking for e2e

* revert changes to getInvocationDetails to see if that breaks tests

* re-enable stack stripping in invocation details for chrome

* new snapshots with more accurate invocation details

* test for same-site cross-origin cookie behavior

* ignore window.top ts errors

* revert forcing injectDocumentDomain in vite-dev-server cy config

* fix normalized whitespace for firefox "loading_failed" error

* always trim trailing wsp from stack before appending additional content

* force normalization of whitespace to three \n when adding additional stack details

* normalize wsp between stack and additional stack to "\n  \n" in firefox

* remove stack_utils attempt at normalizing wsp

* various cleanup: remove commented console logs, add more detailed comments

* add on links to error messages

* remove experimentalSkipDomainInjection from exported type defs

* Update system-tests/test/experimental_skip_domain_injection_spec.ts

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* Update packages/driver/cypress/e2e/e2e/origin/cookie_misc.cy.ts

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* no need to coerce a boolean value to a booleanc

* export base config from primary cypress config in driver for use in inject-document-domain test subset

* lift experimentalSkipDomainInjection breaking option to root

* rollback config/options changes

* rm invalid comment

* use hostname instead of origin to create cookie from automation cookie

* clarify stack regex in results_spec

* lint

* take a stab at the changelog entries for this

* Update cli/CHANGELOG.md

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* Update cli/CHANGELOG.md

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* reenable locally-failing test

* changelog

* snapshot updatesfor experimental skip domain injection err msg

* remove packageManager declaration in package.json

---------

Co-authored-by: Bill Glesias <bglesias@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
2025-01-06 13:48:43 -05:00

73 lines
3.1 KiB
TypeScript

import path from 'path'
import { fs } from '@packages/server/lib/util/fs'
import systemTests from '../lib/system-tests'
import Fixtures from '../lib/fixtures'
// 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 = /"(duration|totalDuration|port)": \d+/g
const osNameRegex = /"(osName|platform)": "[^"]+"/g
const archRegex = /"arch": "[^"]+"/g
const versionRegex = /"(browserVersion|cypressVersion|osVersion|resolvedNodeVersion|version)": "[^"]+"/g
const majorVersionRegex = /"(majorVersion)": [0-9]+/g
const pathRegex = /"(absolute|projectRoot|downloadsFolder|fileServerFolder|fixturesFolder|resolvedNodePath|screenshotsFolder|videosFolder|cypressBinaryRoot|path)": "[^"]+"/g
// matches similar to: `\n at SOME_CODEPATH"`
const stackLineRegex = /(\Wn {4}at.+)"/g
/**
* normalize dynamic data in results json like dates, paths, durations, etc
* @param {string} resultsJson input string
* @returns {string} cleaned output string
*/
const normalizeResults = (resultsJson) => {
return resultsJson
.replace(isoDateRegex, '"2015-03-18T00:00:00.000Z"')
.replace(numberRegex, '"$1": 100')
.replace(pathRegex, '"$1": "/path/to/$1"')
.replace(versionRegex, '"$1": "X.Y.Z"')
.replace(majorVersionRegex, '"$1": "X"')
.replace(osNameRegex, '"$1": "linux"')
.replace(archRegex, '"arch": "x64"')
.replace(stackLineRegex, ' <stack lines>"')
}
const normalizeBrowsers = (browsers) => {
return browsers.filter((browser) => browser.name === 'electron')
}
const stringify = (obj) => JSON.stringify(obj, null, 2)
describe('module api, after:spec, and after:run results', () => {
systemTests.setup()
const projectPath = Fixtures.projectPath('results')
const outputPath = path.join(projectPath, 'module-api-results.json')
systemTests.it('has expected properties and values', {
project: 'results',
browser: 'electron',
outputPath,
expectedExitCode: 3,
config: {
retries: 2,
},
async onRun (execFn) {
await execFn()
const moduleResults = await fs.readJson(outputPath)
const afterRunResults = await fs.readJson(path.join(projectPath, '_results', 'results-after-run.json'))
const afterSpecResults = await fs.readJson(path.join(projectPath, '_results', 'results-after-spec.json'))
expect(moduleResults).to.deep.equal(afterRunResults)
moduleResults.config.browsers = normalizeBrowsers(moduleResults.config.browsers)
moduleResults.config.env = {}
const moduleResultsString = stringify(moduleResults)
const afterSpecResultsString = stringify(afterSpecResults)
systemTests.snapshot('module api and after:run results', normalizeResults(moduleResultsString))
systemTests.snapshot('after:spec results', normalizeResults(afterSpecResultsString))
},
})
})