Skip to content

Commit 2d73dc8

Browse files
committed
Merge branch 'unified-desktop-gui' into tgriesser/unify/e2e-testing-framework
* unified-desktop-gui: fix conflicts fix conflicts feat: create a copy when selecting a pre-existing story (#18440) feat: add configured state to TestingTypeCard (#18461) feat(app): run e2e tests (#18448) fix: frontend-shared typo on windi config feat: make the select language component (#18443) chore: Update Chrome (stable) to 94.0.4606.81 (#18411) release 8.6.0 fix: do not attempt to trim objects when printing to console (#18341) fix(driver): `cy.pause()` should not be ignored with `cypress run --headed --no-exit` (#18358) chore: release @cypress/vite-dev-server-v2.1.1 chore: release @cypress/react-v5.10.1
2 parents 58927ab + 25c46a2 commit 2d73dc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+812
-319
lines changed

browser-versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"chrome:beta": "95.0.4638.40",
3-
"chrome:stable": "94.0.4606.71"
3+
"chrome:stable": "94.0.4606.81"
44
}

npm/react/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# [@cypress/react-v5.10.1](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.10.0...@cypress/react-v5.10.1) (2021-10-04)
2+
3+
4+
### Bug Fixes
5+
6+
* configure proper pages directory for next application ([#18009](https://github.com/cypress-io/cypress/issues/18009)) ([70c7c36](https://github.com/cypress-io/cypress/commit/70c7c3678180d5408c144fa37f94ba5f5f8ceeb8))
7+
* next trace error ([#18189](https://github.com/cypress-io/cypress/issues/18189)) ([db6f909](https://github.com/cypress-io/cypress/commit/db6f9096bd6668db1937d0e38d3928866f6cd5df))
8+
19
# [@cypress/react-v5.10.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.9.4...@cypress/react-v5.10.0) (2021-09-10)
210

311

npm/vite-dev-server/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# [@cypress/vite-dev-server-v2.1.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.1.0...@cypress/vite-dev-server-v2.1.1) (2021-10-04)
2+
3+
4+
### Bug Fixes
5+
6+
* **vite-dev-server:** remove base and root from inlineVitConfig types ([#17180](https://github.com/cypress-io/cypress/issues/17180)) ([07e7d0e](https://github.com/cypress-io/cypress/commit/07e7d0ed252bf1a2bd3224f617e1fc2e64f19a06))
7+
* **vite-dev-server:** replace UserConfig with InlineConfig to allow correct `configFile` types ([#18167](https://github.com/cypress-io/cypress/issues/18167)) ([6e0c2c1](https://github.com/cypress-io/cypress/commit/6e0c2c1af81be750a74bad0528d52de45746a453))
8+
* **vite-dev-server:** windows `supportFile` + preserve optimize entries ([#18286](https://github.com/cypress-io/cypress/issues/18286)) ([ea2f6a4](https://github.com/cypress-io/cypress/commit/ea2f6a45c7057e51b2fc879ff70da75538fa1002))
9+
110
# [@cypress/vite-dev-server-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.8...@cypress/vite-dev-server-v2.1.0) (2021-09-10)
211

312

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cypress",
3-
"version": "8.5.0",
3+
"version": "8.6.0",
44
"description": "Cypress.io end to end testing tool",
55
"private": true,
66
"scripts": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('visit google', () => {
2+
it('goes to google.com', () => {
3+
cy.visit('https://google.com')
4+
})
5+
})

packages/app/index.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,18 @@ declare global {
4848
teardown: (state: Store) => Promise<void>
4949
teardownReporter: () => Promise<void>
5050
[key: string]: any
51+
52+
on (event: 'restart', ...args: unknown[]): void
5153
}
5254

55+
/**
56+
* This is the config served from the back-end.
57+
* We will manage config using GraphQL going forward,
58+
* but for now we are also caching it on `window`
59+
* to be able to move fast and iterate
60+
*/
61+
config: Record<string, any>
62+
5363
/**
5464
* To ensure we are only a single copy of React
5565
* We get a reference to the copy of React (and React DOM)

packages/app/src/pages/Specs.vue

-6
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,3 @@ const props = defineProps<{
3232
name: "Specs Page"
3333
}
3434
</route>
35-
36-
<style>
37-
iframe {
38-
width: 100%;
39-
}
40-
</style>

packages/app/src/runner/index.ts

+71-5
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ function teardownSpec (store: Store) {
6363
* Cypress on it.
6464
*
6565
*/
66-
function setupSpec (spec: BaseSpec) {
67-
// @ts-ignore - TODO: figure out how to manage window.config.
68-
const config = window.config
66+
function setupSpecCT (spec: BaseSpec) {
67+
// TODO: figure out how to manage window.config.
68+
const config = window.UnifiedRunner.config
6969

7070
// this is how the Cypress driver knows which spec to run.
7171
config.spec = spec
@@ -98,6 +98,64 @@ function setupSpec (spec: BaseSpec) {
9898
window.UnifiedRunner.eventManager.initialize($autIframe, config)
9999
}
100100

101+
/**
102+
* Create a Spec IFrame. Used for loading the spec to execute in E2E
103+
*/
104+
function createSpecIFrame (specSrc: string) {
105+
const el = document.createElement('iframe')
106+
107+
el.id = `Your Spec: '${specSrc}'`,
108+
el.className = 'spec-iframe'
109+
110+
return el
111+
}
112+
113+
/**
114+
* Set up an E2E spec by creating a fresh AUT for the spec to evaluate under,
115+
* a Spec IFrame to load the spec's source code, and
116+
* initialize Cypress on the AUT.
117+
*/
118+
function setupSpecE2E (spec: BaseSpec) {
119+
// TODO: manage config with GraphQL, don't put it on window.
120+
const config = window.UnifiedRunner.config
121+
122+
// this is how the Cypress driver knows which spec to run.
123+
config.spec = spec
124+
125+
// creates a new instance of the Cypress driver for this spec,
126+
// initializes a bunch of listeners
127+
// watches spec file for changes.
128+
window.UnifiedRunner.eventManager.setup(config)
129+
130+
const $runnerRoot = getRunnerElement()
131+
132+
// clear AUT, if there is one.
133+
empty($runnerRoot)
134+
135+
// create root for new AUT
136+
const $container = document.createElement('div')
137+
138+
$runnerRoot.append($container)
139+
140+
// create new AUT
141+
const autIframe = new window.UnifiedRunner.AutIframe('Test Project')
142+
143+
autIframe.showInitialBlankContents()
144+
const $autIframe: JQuery<HTMLIFrameElement> = autIframe.create().appendTo($container)
145+
146+
// create Spec IFrame
147+
const specSrc = getSpecUrl(config.namespace, spec)
148+
const $specIframe = createSpecIFrame(specSrc)
149+
150+
// append to document, so the iframe will execute the spec
151+
$container.appendChild($specIframe)
152+
153+
$specIframe.src = specSrc
154+
155+
// initialize Cypress (driver) with the AUT!
156+
window.UnifiedRunner.eventManager.initialize($autIframe, config)
157+
}
158+
101159
/**
102160
* Inject the global `UnifiedRunner` via a <script src="..."> tag.
103161
* which includes the event manager and AutIframe constructor.
@@ -125,7 +183,7 @@ function initialize (ready: () => void) {
125183
*
126184
* 4. Force the Reporter to re-render with the new spec we are executed.
127185
*
128-
* 5. Setup the spec. This involves a few things, see the `setupSpec` function's
186+
* 5. Setup the spec. This involves a few things, see the `setupSpecCT` function's
129187
* description for more information.
130188
*/
131189
async function executeSpec (spec: BaseSpec) {
@@ -137,7 +195,15 @@ async function executeSpec (spec: BaseSpec) {
137195

138196
UnifiedReporterAPI.setupReporter()
139197

140-
return setupSpec(spec)
198+
if (window.UnifiedRunner.config.testingType === 'e2e') {
199+
return setupSpecE2E(spec)
200+
}
201+
202+
if (window.UnifiedRunner.config.testingType === 'component') {
203+
return setupSpecCT(spec)
204+
}
205+
206+
throw Error('Unknown or undefined testingType on window.UnifiedRunner.config.testingType')
141207
}
142208

143209
export const UnifiedRunnerAPI = {

packages/app/src/runner/injectBundle.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export async function injectBundle (ready: () => void) {
4242
// injectReporterStyle()
4343

4444
script.onload = () => {
45-
// @ts-ignore - just stick config on window until we figure out how we are
45+
// just stick config on window until we figure out how we are
4646
// going to manage it
47-
window.config = window.UnifiedRunner.decodeBase64(data.base64Config)
47+
window.UnifiedRunner.config = window.UnifiedRunner.decodeBase64(data.base64Config)
4848
ready()
4949
}
5050
}

packages/app/src/runs/Runner.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ const props = defineProps<{
3030
}>()
3131
3232
onMounted(() => {
33-
UnifiedRunnerAPI.initialize(execute)
33+
UnifiedRunnerAPI.initialize(() => {
34+
window.UnifiedRunner.eventManager.on('restart', () => {
35+
execute()
36+
})
37+
38+
execute()
39+
})
3440
})
3541
3642
onBeforeUnmount(() => {
@@ -72,3 +78,14 @@ const execute = () => {
7278
name: "Runner"
7379
}
7480
</route>
81+
82+
<style>
83+
#unified-runner > div {
84+
height: 100%;
85+
}
86+
87+
iframe {
88+
width: 100%;
89+
height: 100%;
90+
}
91+
</style>

packages/app/src/specs/SpecsList.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fragment Specs_SpecsList on App {
6262
activeProject {
6363
id
6464
projectRoot
65-
specs(first: 25) {
65+
specs: specs(first: 25) {
6666
edges {
6767
...SpecNode_SpecsList
6868
}

0 commit comments

Comments
 (0)