Skip to content

Commit 58927ab

Browse files
committed
WIP on getting open mode e2e testing
1 parent 9aac75f commit 58927ab

17 files changed

+158
-122
lines changed

packages/app/cypress.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../cli/schema/cypress.schema.json",
23
"projectId": "sehy69",
34
"viewportWidth": 800,
45
"viewportHeight": 850,

packages/frontend-shared/cypress/e2e/support/e2eProjectRegistry.ts

+80-80
Large diffs are not rendered by default.

packages/frontend-shared/cypress/e2e/support/e2eSupport.ts

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ProjectFixture = keyof typeof e2eProjectPaths
77

88
export interface WithCtxOptions extends Cypress.Loggable, Cypress.Timeoutable {
99
projectName?: string
10+
[key: string]: any
1011
}
1112

1213
declare global {
@@ -18,12 +19,20 @@ declare global {
1819
initializeApp: typeof initializeApp
1920
visitApp(href?: string): Chainable<string>
2021
visitLaunchpad(href?: string): Chainable<string>
22+
/**
23+
* Get the project path for testing opening a new project
24+
*/
25+
e2eProjectPath(project: ProjectFixture): string
2126
// graphqlRequest(): Chainable<string>
2227
}
2328
}
2429
}
2530

2631
beforeEach(() => {
32+
cy.e2eProjectPath = (project: ProjectFixture) => {
33+
return e2eProjectPaths[project]
34+
}
35+
2736
// Reset the ports so we know we need to call "setupE2E" before each test
2837
Cypress.env('e2e_serverPort', undefined)
2938
Cypress.env('e2e_gqlPort', undefined)

packages/launchpad/cypress.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../cli/schema/cypress.schema.json",
23
"projectId": "sehy69",
34
"viewportWidth": 800,
45
"viewportHeight": 850,
@@ -19,6 +20,8 @@
1920
"pluginsFile": "cypress/component/plugins/index.js"
2021
},
2122
"e2e": {
22-
"supportFile": false
23+
"supportFile": "cypress/e2e/support/e2eSupport.ts",
24+
"integrationFolder": "cypress/e2e/integration",
25+
"pluginsFile": "cypress/e2e/plugins/index.ts"
2326
}
2427
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('Launchpad: Open Mode', () => {
2+
beforeEach(() => {
3+
cy.setupE2E()
4+
cy.visitLaunchpad()
5+
})
6+
7+
it('Shows the open page, with a search bar', () => {
8+
cy.get('h1').should('contain', 'Cypress')
9+
cy.get('[type=search]')
10+
})
11+
12+
it('allows adding a project', () => {
13+
cy.withCtx((ctx, o) => {
14+
ctx.actions.project.setActiveProject(o.projectPath)
15+
ctx.emitter.toLaunchpad()
16+
}, { projectPath: cy.e2eProjectPath('todos') })
17+
18+
cy.get('h1').should('contain', 'Welcome')
19+
})
20+
})

packages/launchpad/cypress/plugins/index.ts packages/launchpad/cypress/e2e/plugins/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="cypress" />
2-
const { monorepoPaths } = require('../../../../scripts/gulp/monorepoPaths')
2+
const { monorepoPaths } = require('../../../../../scripts/gulp/monorepoPaths')
33
import { e2ePluginSetup } from '@packages/frontend-shared/cypress/e2e/e2ePluginSetup'
44

55
// ***********************************************************
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference path="../../../../frontend-shared/cypress/e2e/support/e2eSupport.ts" />
2+
require('../../../../frontend-shared/cypress/e2e/support/e2eSupport')

packages/launchpad/cypress/integration/add-project-from-global-mode.ts

-17
This file was deleted.

packages/launchpad/cypress/integration/basic.spec.ts

-14
This file was deleted.

packages/launchpad/cypress/integration/global-mode-navigation.ts

-5
This file was deleted.

packages/launchpad/cypress/integration/navigating-back-to-global-mode.ts

Whitespace-only changes.

packages/launchpad/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"test": "yarn cypress:run:ct && yarn types",
1111
"windi": "yarn windicss-analysis",
1212
"cypress:launch": "cross-env TZ=America/New_York node ../../scripts/cypress open --project ${PWD}",
13-
"cypress:open": "yarn gulp cyOpenLaunchpadE2E",
13+
"cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open --project ${PWD}",
1414
"cypress:run:ct": "cross-env TZ=America/New_York node ../../scripts/cypress run-ct --project ${PWD}",
15-
"cypress:run:e2e": "yarn gulp cyRunLaunchpadE2E",
15+
"cypress:run:e2e": "cross-env TZ=America/New_York node ../../scripts/cypress run --project ${PWD}",
1616
"dev": "yarn gulp dev --project ${PWD}",
1717
"start": "echo 'run yarn dev from the root' && exit 1",
1818
"watch": "echo 'run yarn dev from the root' && exit 1"

packages/launchpad/src/setup/TestingTypeCards.vue

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<TestingTypeCard
44
v-if="ct"
55
:id="ct.type"
6+
:data-e2e="ct.type"
67
:title="ct.title"
78
:description="firstTimeCT ? ct.description : 'LAUNCH'"
89
role="button"
@@ -14,6 +15,7 @@
1415
<TestingTypeCard
1516
v-if="e2e"
1617
:id="e2e.type"
18+
:data-e2e="e2e.type"
1719
:title="e2e.title"
1820
:description="firstTimeE2E ? e2e.description : 'LAUNCH'"
1921
role="button"

scripts/gulp/gulpfile.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import gulp from 'gulp'
1111
import { autobarrelWatcher } from './tasks/gulpAutobarrel'
1212
import { startCypressWatch, openCypressLaunchpad, openCypressApp, runCypressLaunchpad, wrapRunWithExit, runCypressApp, killExistingCypress } from './tasks/gulpCypress'
1313
import { graphqlCodegen, graphqlCodegenWatch, nexusCodegen, nexusCodegenWatch, generateFrontendSchema, syncRemoteGraphQL } from './tasks/gulpGraphql'
14-
import { viteApp, viteCleanApp, viteCleanLaunchpad, viteLaunchpad, viteBuildApp, viteBuildAndWatchApp, viteBuildLaunchpad, viteBuildAndWatchLaunchpad } from './tasks/gulpVite'
14+
import { viteApp, viteCleanApp, viteCleanLaunchpad, viteLaunchpad, viteBuildApp, viteBuildAndWatchApp, viteBuildLaunchpad, viteBuildAndWatchLaunchpad, symlinkViteProjects } from './tasks/gulpVite'
1515
import { checkTs } from './tasks/gulpTsc'
1616
import { makePathMap } from './utils/makePathMap'
1717
import { makePackage } from './tasks/gulpMakePackage'
@@ -135,6 +135,18 @@ gulp.task(
135135
),
136136
)
137137

138+
gulp.task('watchForE2E', gulp.series(
139+
'codegen',
140+
gulp.parallel(
141+
gulp.series(
142+
viteBuildAndWatchLaunchpad,
143+
viteBuildAndWatchApp,
144+
),
145+
webpackRunner,
146+
),
147+
symlinkViteProjects,
148+
))
149+
138150
/**------------------------------------------------------------------------
139151
* Launchpad Testing
140152
* This task builds and hosts the launchpad as if it was a static website.
@@ -182,6 +194,8 @@ const cyOpenLaunchpad = gulp.series(
182194
viteBuildApp,
183195
),
184196

197+
symlinkViteProjects,
198+
185199
// 2. Start the REAL (dev) Cypress App, which will launch in open mode.
186200
openCypressLaunchpad,
187201
)
@@ -198,6 +212,8 @@ const cyOpenApp = gulp.series(
198212
webpackRunner,
199213
),
200214

215+
symlinkViteProjects,
216+
201217
// 2. Start the REAL (dev) Cypress App, which will launch in open mode.
202218
openCypressApp,
203219
)
@@ -244,6 +260,7 @@ gulp.task(makePackage)
244260
* here for debugging, e.g. `yarn gulp syncRemoteGraphQL`
245261
*------------------------------------------------------------------------**/
246262

263+
gulp.task(symlinkViteProjects)
247264
gulp.task(syncRemoteGraphQL)
248265
gulp.task(generateFrontendSchema)
249266
gulp.task(makePathMap)

scripts/gulp/tasks/gulpE2ETestScaffold.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import path from 'path'
3030
export const e2eProjectPaths = {
3131
${allDirs
3232
.map((dir) => {
33-
return ` '${path.basename(dir)}': path.join(__dirname, '${path.relative(OUTPUT_PATH, dir)}')`
33+
return ` '${path.basename(dir)}': path.join(__dirname, '${path.relative(path.dirname(OUTPUT_PATH), dir)}')`
3434
}).join(',\n')}
3535
} as const
3636
`,

scripts/gulp/tasks/gulpVite.ts

+17
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ function spawnViteDevServer (
7272
* * viteBuildLaunchpad
7373
*------------------------------------------------------------------------**/
7474

75+
export async function symlinkViteProjects () {
76+
await Promise.all([
77+
spawned('cmd-symlink', 'yarn rimraf dist-launchpad && ln -s dist dist-launchpad', {
78+
cwd: monorepoPaths.pkgLaunchpad,
79+
}),
80+
spawned('cmd-symlink', 'yarn rimraf dist-app && ln -s ../app/dist dist-app', {
81+
cwd: monorepoPaths.pkgLaunchpad,
82+
}),
83+
spawned('cmd-symlink', 'yarn rimraf dist-app && ln -s dist dist-app', {
84+
cwd: monorepoPaths.pkgApp,
85+
}),
86+
spawned('cmd-symlink', 'yarn rimraf dist-launchpad && ln -s ../launchpad/dist dist-launchpad', {
87+
cwd: monorepoPaths.pkgApp,
88+
}),
89+
])
90+
}
91+
7592
export function viteBuildApp () {
7693
return spawned('vite:build-app', `yarn vite build`, {
7794
cwd: monorepoPaths.pkgApp,

scripts/gulp/utils/childProcessUtils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { prefixLog, prefixStream } from './prefixStream'
77
import { addChildProcess } from '../tasks/gulpRegistry'
88

99
export type AllSpawnableApps =
10+
| `cmd-${string}`
1011
| `vite-${string}`
1112
| `vite:build-${string}`
1213
| `serve:${string}`

0 commit comments

Comments
 (0)