diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts
index f37d2d406258..bb648686686d 100644
--- a/packages/data-context/src/data/ProjectLifecycleManager.ts
+++ b/packages/data-context/src/data/ProjectLifecycleManager.ts
@@ -23,7 +23,7 @@ import { EventRegistrar } from './EventRegistrar'
import { getServerPluginHandlers, resetPluginHandlers } from '../util/pluginHandlers'
import { detectLanguage } from '@packages/scaffold-config'
import { validateNeedToRestartOnChange } from '@packages/config'
-import { MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
import { telemetry } from '@packages/telemetry'
export interface SetupFullConfigOptions {
@@ -332,7 +332,7 @@ export class ProjectLifecycleManager {
const preferences = await this.ctx._apis.localSettingsApi.getPreferences()
- const hasWelcomeBeenDismissed = Boolean(preferences.majorVersionWelcomeDismissed?.[MAJOR_VERSION_FOR_CONTENT])
+ const hasWelcomeBeenDismissed = Boolean(preferences.majorVersionWelcomeDismissed?.[GET_MAJOR_VERSION_FOR_CONTENT()])
// only continue if the browser was successfully set - we must have an activeBrowser once this function resolves
// but if the user needs to dismiss a landing page, don't continue, the active browser will be opened
diff --git a/packages/data-context/test/unit/helper.ts b/packages/data-context/test/unit/helper.ts
index b2f5be39ec6d..6622daa77073 100644
--- a/packages/data-context/test/unit/helper.ts
+++ b/packages/data-context/test/unit/helper.ts
@@ -15,7 +15,7 @@ import { getOperationName } from '@urql/core'
import { CloudQuery } from '@packages/graphql/test/stubCloudTypes'
import { remoteSchema } from '@packages/graphql/src/stitching/remoteSchema'
import type { OpenModeOptions, RunModeOptions } from '@packages/types'
-import { MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
import { RelevantRunInfo } from '../../src/gen/graphcache-config.gen'
type SystemTestProject = typeof fixtureDirs[number]
@@ -48,7 +48,7 @@ export function createTestDataContext (mode: DataContextConfig['mode'] = 'run',
appApi: {} as AppApiShape,
localSettingsApi: {
getPreferences: sinon.stub().resolves({
- majorVersionWelcomeDismissed: { [MAJOR_VERSION_FOR_CONTENT]: 123456 },
+ majorVersionWelcomeDismissed: { [GET_MAJOR_VERSION_FOR_CONTENT()]: 123456 },
notifyWhenRunCompletes: ['failed'],
}),
getAvailableEditors: sinon.stub(),
diff --git a/packages/frontend-shared/cypress/support/e2e.ts b/packages/frontend-shared/cypress/support/e2e.ts
index 7594ffb1f0c6..abd911a1cbc9 100644
--- a/packages/frontend-shared/cypress/support/e2e.ts
+++ b/packages/frontend-shared/cypress/support/e2e.ts
@@ -5,7 +5,7 @@ import { fixtureDirs, ProjectFixtureDir } from '@tooling/system-tests'
import type { DataContext } from '@packages/data-context'
import type { AuthenticatedUserShape } from '@packages/data-context/src/data'
import type { DocumentNode, ExecutionResult } from 'graphql'
-import type { Browser, FoundBrowser, OpenModeOptions } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT, type Browser, type FoundBrowser, type OpenModeOptions } from '@packages/types'
import type { SinonStub } from 'sinon'
import type sinon from 'sinon'
@@ -402,7 +402,7 @@ function visitLaunchpad (options: { showWelcome?: boolean } = { showWelcome: fal
// avoid re-stubbing already stubbed prompts in case we call getPreferences multiple times
if ((ctx._apis.localSettingsApi.getPreferences as any).wrappedMethod === undefined) {
o.sinon.stub(ctx._apis.localSettingsApi, 'getPreferences').resolves({ majorVersionWelcomeDismissed: {
- [14]: Date.now(),
+ [GET_MAJOR_VERSION_FOR_CONTENT()]: Date.now(),
} })
}
}).then(() => {
diff --git a/packages/launchpad/cypress/e2e/open-mode.cy.ts b/packages/launchpad/cypress/e2e/open-mode.cy.ts
index a782e776178d..001e889a94fb 100644
--- a/packages/launchpad/cypress/e2e/open-mode.cy.ts
+++ b/packages/launchpad/cypress/e2e/open-mode.cy.ts
@@ -1,6 +1,6 @@
import type { SinonStub } from 'sinon'
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
-import { MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
describe('Launchpad: Open Mode', () => {
describe('global mode', () => {
@@ -228,10 +228,10 @@ describe('Launchpad: Open Mode', () => {
cy.withCtx((ctx, o) => {
o.sinon.stub(ctx._apis.projectApi, 'launchProject').resolves()
o.sinon.stub(ctx._apis.localSettingsApi, 'getPreferences').resolves({ majorVersionWelcomeDismissed: {
- [o.MAJOR_VERSION_FOR_CONTENT]: Date.now(),
+ [o.GET_MAJOR_VERSION_FOR_CONTENT()]: Date.now(),
} })
}, {
- MAJOR_VERSION_FOR_CONTENT,
+ GET_MAJOR_VERSION_FOR_CONTENT: GET_MAJOR_VERSION_FOR_CONTENT(),
})
cy.scaffoldProject('launchpad')
diff --git a/packages/launchpad/cypress/e2e/project-setup.cy.ts b/packages/launchpad/cypress/e2e/project-setup.cy.ts
index 02a3bd0ff775..c732c7161430 100644
--- a/packages/launchpad/cypress/e2e/project-setup.cy.ts
+++ b/packages/launchpad/cypress/e2e/project-setup.cy.ts
@@ -1,4 +1,4 @@
-import { MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
import { getPathForPlatform } from './support/getPathForPlatform'
function verifyScaffoldedFiles (testingType: string) {
@@ -38,13 +38,13 @@ describe('Launchpad: Setup Project', () => {
cy.withCtx(async (ctx, o) => {
o.sinon.stub(ctx.project, 'projectId').resolves(null)
o.sinon.stub(ctx._apis.localSettingsApi, 'getPreferences').resolves({ majorVersionWelcomeDismissed: {
- [o.MAJOR_VERSION_FOR_CONTENT]: Date.now(),
+ [o.GET_MAJOR_VERSION_FOR_CONTENT()]: Date.now(),
} })
// Delete the fixtures folder so it scaffold correctly the example
await ctx.actions.file.removeFileInProject('cypress/fixtures')
}, {
- MAJOR_VERSION_FOR_CONTENT,
+ GET_MAJOR_VERSION_FOR_CONTENT: GET_MAJOR_VERSION_FOR_CONTENT(),
})
}
diff --git a/packages/launchpad/src/Main.vue b/packages/launchpad/src/Main.vue
index 8ca8d895c03a..4e9e0b0912a6 100644
--- a/packages/launchpad/src/Main.vue
+++ b/packages/launchpad/src/Main.vue
@@ -103,7 +103,7 @@ import OpenBrowser from './setup/OpenBrowser.vue'
import LoginConnectModals from '@cy/gql-components/LoginConnectModals.vue'
import CloudViewerAndProject from '@cy/gql-components/CloudViewerAndProject.vue'
import { usePromptManager } from '@cy/gql-components/composables/usePromptManager'
-import { MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
const { setMajorVersionWelcomeDismissed } = usePromptManager()
const { t } = useI18n()
@@ -234,7 +234,7 @@ watch(
)
function handleClearLandingPage () {
- setMajorVersionWelcomeDismissed(MAJOR_VERSION_FOR_CONTENT)
+ setMajorVersionWelcomeDismissed(GET_MAJOR_VERSION_FOR_CONTENT())
const shouldLaunchBrowser = query.data?.value?.localSettings?.preferences?.shouldLaunchBrowserFromOpenBrowser
const currentTestingType = currentProject.value?.currentTestingType
@@ -246,7 +246,7 @@ function handleClearLandingPage () {
const shouldShowWelcome = computed(() => {
if (query.data.value) {
- const hasThisVersionBeenSeen = query.data.value?.localSettings?.preferences?.majorVersionWelcomeDismissed?.[MAJOR_VERSION_FOR_CONTENT]
+ const hasThisVersionBeenSeen = query.data.value?.localSettings?.preferences?.majorVersionWelcomeDismissed?.[GET_MAJOR_VERSION_FOR_CONTENT()]
const wasBrowserSetInCLI = query.data?.value?.localSettings.preferences?.wasBrowserSetInCLI
const currentTestingType = currentProject.value?.currentTestingType
diff --git a/packages/launchpad/src/migration/MajorVersionWelcome.cy.tsx b/packages/launchpad/src/migration/MajorVersionWelcome.cy.tsx
index 2a2a01bac99a..145228ecc0ae 100644
--- a/packages/launchpad/src/migration/MajorVersionWelcome.cy.tsx
+++ b/packages/launchpad/src/migration/MajorVersionWelcome.cy.tsx
@@ -1,6 +1,7 @@
import { defaultMessages } from '@cy/i18n'
import MajorVersionWelcome from './MajorVersionWelcome.vue'
import interval from 'human-interval'
+import { GET_MAJOR_VERSION_FOR_CONTENT } from '@packages/types'
const text = defaultMessages.majorVersionWelcome
@@ -52,4 +53,13 @@ describe('', { viewportWidth: 1280, viewportHeight: 1400
cy.percySnapshot('content overflows inside box')
})
+
+ // Test is designed to fail as a signal when the next major version of Cypress is bumped in the package.json
+ // to signal to the team that we need to create a splash page
+ it('makes sure there is an entry for the current major release in the monorepo package.json version', () => {
+ cy.mount()
+ const currentMajorVersion = GET_MAJOR_VERSION_FOR_CONTENT()
+
+ cy.get('a').should('contain.text', `${currentMajorVersion}.0.0`)
+ })
})
diff --git a/packages/types/package.json b/packages/types/package.json
index 7d1022d35687..34d046575c6b 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -14,6 +14,7 @@
"devDependencies": {
"@types/node": "20.16.0",
"devtools-protocol": "0.0.1346313",
+ "semver": "^7.6.3",
"typescript": "~5.4.5"
},
"files": [
diff --git a/packages/types/src/constants.ts b/packages/types/src/constants.ts
index b564b5615f49..6aed486cbc3c 100644
--- a/packages/types/src/constants.ts
+++ b/packages/types/src/constants.ts
@@ -1,3 +1,6 @@
+import semverMajor from 'semver/functions/major'
+import { version } from '../../../package.json'
+
import type { SpecFile } from './spec'
export const PLUGINS_STATE = ['uninitialized', 'initializing', 'initialized', 'error'] as const
@@ -25,7 +28,7 @@ export const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'] as const
// Note: ONLY change this in code that will be merged into a release branch
// for a new major version of Cypress
-export const MAJOR_VERSION_FOR_CONTENT = '14'
+export const GET_MAJOR_VERSION_FOR_CONTENT = () => semverMajor(version).toString()
export const RUN_ALL_SPECS_KEY = '__all' as const