mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 23:49:43 -05:00
chore: automatically infer cypress major version from package.json version and error when no splash page exists for said major version (#30911)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,9 +402,11 @@ 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(),
|
||||
[o.MAJOR_VERSION_FOR_CONTENT]: Date.now(),
|
||||
} })
|
||||
}
|
||||
}, {
|
||||
MAJOR_VERSION_FOR_CONTENT: GET_MAJOR_VERSION_FOR_CONTENT(),
|
||||
}).then(() => {
|
||||
return launchpadVisit()
|
||||
})
|
||||
|
||||
@@ -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', () => {
|
||||
@@ -231,7 +231,7 @@ describe('Launchpad: Open Mode', () => {
|
||||
[o.MAJOR_VERSION_FOR_CONTENT]: Date.now(),
|
||||
} })
|
||||
}, {
|
||||
MAJOR_VERSION_FOR_CONTENT,
|
||||
MAJOR_VERSION_FOR_CONTENT: GET_MAJOR_VERSION_FOR_CONTENT(),
|
||||
})
|
||||
|
||||
cy.scaffoldProject('launchpad')
|
||||
|
||||
@@ -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) {
|
||||
@@ -44,7 +44,7 @@ describe('Launchpad: Setup Project', () => {
|
||||
// Delete the fixtures folder so it scaffold correctly the example
|
||||
await ctx.actions.file.removeFileInProject('cypress/fixtures')
|
||||
}, {
|
||||
MAJOR_VERSION_FOR_CONTENT,
|
||||
MAJOR_VERSION_FOR_CONTENT: GET_MAJOR_VERSION_FOR_CONTENT(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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('<MajorVersionWelcome />', { 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(<MajorVersionWelcome />)
|
||||
const currentMajorVersion = GET_MAJOR_VERSION_FOR_CONTENT()
|
||||
|
||||
cy.get('a').should('contain.text', `${currentMajorVersion}.0.0`)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"clean": "rimraf src/*.js src/**/*.js",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ."
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"semver": "^7.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "20.16.0",
|
||||
"devtools-protocol": "0.0.1346313",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user