Skip to content

Commit 0665e13

Browse files
feat: Improve launchpad browser warning (#18939)
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
1 parent a45825e commit 0665e13

File tree

33 files changed

+490
-164
lines changed

33 files changed

+490
-164
lines changed

packages/data-context/src/actions/AppActions.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ export class AppActions {
3535
browser = (await this.ctx._apis.appApi.ensureAndGetByNameOrPath(browserNameOrPath)) as FoundBrowser | undefined
3636
} catch (err: unknown?) {
3737
this.ctx.debug('Error getting browser by name or path (%s): %s', browserNameOrPath, err?.stack || err)
38-
this.ctx.coreData.wizard.browserErrorMessage = `The browser '${browserNameOrPath}' was not found on your system or is not supported by Cypress. Choose a browser below.`
38+
const message = err.details ? `${err.message}\n\n\`\`\`\n${err.details}\n\`\`\`` : err.message
39+
40+
this.ctx.coreData.wizard.warnings.push({
41+
title: 'Warning: Browser Not Found',
42+
message,
43+
setupStep: 'setupComplete',
44+
})
3945
}
4046

4147
if (browser) {

packages/data-context/src/data/coreDataShape.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, DevicePreferences, devicePreferenceDefaults, Editor } from '@packages/types'
1+
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, DevicePreferences, devicePreferenceDefaults, Editor, Warning } from '@packages/types'
22
import type { NexusGenEnums, TestingTypeEnum } from '@packages/graphql/src/gen/nxs.gen'
33
import type { BrowserWindow } from 'electron'
44
import type { ChildProcess } from 'child_process'
@@ -73,7 +73,7 @@ export interface WizardDataShape {
7373
chosenLanguage: NexusGenEnums['CodeLanguageEnum']
7474
chosenManualInstall: boolean
7575
chosenBrowser: FoundBrowser | null
76-
browserErrorMessage: string | null
76+
warnings: Warning[]
7777
}
7878

7979
export interface ElectronShape {
@@ -132,7 +132,7 @@ export function makeCoreData (): CoreDataShape {
132132
allBundlers: BUNDLERS,
133133
history: ['welcome'],
134134
chosenBrowser: null,
135-
browserErrorMessage: null,
135+
warnings: [],
136136
},
137137
user: null,
138138
electron: {

packages/frontend-shared/cypress/support/mock-graphql/clientTestContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface ClientTestContext {
3737
allBundlers: WizardBundler[]
3838
history: WizardStep[]
3939
chosenBrowser: null
40-
browserErrorMessage: null
40+
warnings: []
4141
}
4242
user: AuthenticatedUserShape | null
4343
cloudTypes: typeof cloudTypes
@@ -87,7 +87,7 @@ export function makeClientTestContext (): ClientTestContext {
8787
allBundlers,
8888
history: ['welcome'],
8989
chosenBrowser: null,
90-
browserErrorMessage: null,
90+
warnings: [],
9191
},
9292
user: null,
9393
cloudTypes,

packages/frontend-shared/cypress/support/mock-graphql/stubgql-Wizard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const stubWizard: MaybeResolver<Wizard> = {
4646
...testNodeId('WizardSampleConfigFile'),
4747
filePath: 'cypress/fixtures/example.json',
4848
description: 'Please do the necessary changes to your file',
49-
content: dedent`{
49+
content: dedent`{
5050
"foo": 1,
5151
"bar": 42
5252
}`,
@@ -97,4 +97,5 @@ export const stubWizard: MaybeResolver<Wizard> = {
9797
isSelected: idx === 0,
9898
}
9999
}),
100+
warnings: [],
100101
}

packages/graphql/schemas/schema.graphql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,6 @@ type ProjectPreferences {
598598
type Query {
599599
baseError: BaseError
600600

601-
"""An error related to finding a browser"""
602-
browserErrorMessage: String
603-
604601
"""Returns an object conforming to the Relay spec"""
605602
cloudNode(
606603
"""An ID for a Node conforming to the Relay spec"""
@@ -758,6 +755,13 @@ type VersionData {
758755
latest: Version!
759756
}
760757

758+
"""A warning"""
759+
type Warning {
760+
message: String!
761+
setupStep: String
762+
title: String!
763+
}
764+
761765
"""
762766
The Wizard is a container for any state associated with initial onboarding to Cypress
763767
"""
@@ -809,6 +813,9 @@ type Wizard {
809813

810814
"""The title of the page, given the current step of the wizard"""
811815
title: String
816+
817+
"""A list of warnings"""
818+
warnings: [Warning!]!
812819
}
813820

814821
"""Wizard bundler"""

packages/graphql/src/schemaTypes/objectTypes/gql-Query.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ export const Query = objectType({
4848
resolve: (root, args, ctx) => ctx.appData.projects,
4949
})
5050

51-
t.string('browserErrorMessage', {
52-
description: 'An error related to finding a browser',
53-
resolve: (source, args, ctx) => {
54-
return ctx.wizardData.browserErrorMessage
55-
},
56-
})
57-
5851
t.nonNull.boolean('isInGlobalMode', {
5952
description: 'Whether the app is in global mode or not',
6053
resolve: (source, args, ctx) => !ctx.currentProject,

packages/graphql/src/schemaTypes/objectTypes/gql-Wizard.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import { TestingTypeEnum, WizardStepEnum } from '../enumTypes/gql-WizardEnums'
77
import { WizardCodeLanguage } from './gql-WizardCodeLanguage'
88
import { WizardSampleConfigFile } from './gql-WizardSampleConfigFile'
99

10+
const Warning = objectType({
11+
name: 'Warning',
12+
description: 'A warning',
13+
definition (t) {
14+
t.nonNull.string('title')
15+
t.nonNull.string('message')
16+
t.string('setupStep')
17+
},
18+
sourceType: {
19+
module: '@packages/types',
20+
export: 'Warning',
21+
},
22+
})
23+
1024
export const Wizard = objectType({
1125
name: 'Wizard',
1226
description: 'The Wizard is a container for any state associated with initial onboarding to Cypress',
@@ -98,6 +112,14 @@ export const Wizard = objectType({
98112
description: 'The title of the page, given the current step of the wizard',
99113
resolve: (source, args, ctx) => ctx.wizard.title ?? null,
100114
})
115+
116+
t.nonNull.list.nonNull.field('warnings', {
117+
type: Warning,
118+
description: 'A list of warnings',
119+
resolve: (source, args, ctx) => {
120+
return ctx.coreData.wizard.warnings
121+
},
122+
})
101123
},
102124
sourceType: {
103125
module: '@packages/data-context/src/data/coreDataShape',

packages/launchpad/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"check-ts": "vue-tsc --noEmit",
77
"build-prod-ui": "cross-env NODE_ENV=production vite build",
8+
"postinstall": "patch-package",
89
"clean": "rimraf dist && rimraf ./node_modules/.vite && rimraf dist-e2e && echo 'cleaned'",
910
"clean-deps": "rimraf node_modules",
1011
"test": "yarn cypress:run:ct && yarn types",
@@ -28,6 +29,7 @@
2829
"@packages/frontend-shared": "0.0.0-development",
2930
"@percy/cypress": "^3.1.0",
3031
"@testing-library/cypress": "8.0.0",
32+
"@toycode/markdown-it-class": "1.2.4",
3133
"@urql/core": "2.3.1",
3234
"@urql/devtools": "2.0.3",
3335
"@urql/vue": "0.4.3",
@@ -46,6 +48,7 @@
4648
"graphql-tag": "^2.12.5",
4749
"gravatar": "1.8.0",
4850
"javascript-time-ago": "2.3.8",
51+
"markdown-it": "12.2.0",
4952
"rimraf": "3.0.2",
5053
"rollup-plugin-polyfill-node": "^0.7.0",
5154
"type-fest": "^2.3.4",
@@ -71,6 +74,11 @@
7174
"script",
7275
"src"
7376
],
77+
"workspaces": {
78+
"nohoist": [
79+
"@toycode/markdown-it-class"
80+
]
81+
},
7482
"vite": {
7583
"optimizeDeps": {
7684
"include": [
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/@toycode/markdown-it-class/index.js b/node_modules/@toycode/markdown-it-class/index.js
2+
index 8e8c8f4..5e2539d 100644
3+
--- a/node_modules/@toycode/markdown-it-class/index.js
4+
+++ b/node_modules/@toycode/markdown-it-class/index.js
5+
@@ -8,7 +8,7 @@ const toArray = a => (Array.isArray(a) ? a : [a])
6+
7+
function parseTokens(tokens) {
8+
tokens.forEach(token => {
9+
- if (/(_open$|image)/.test(token.type) && mapping[token.tag]) {
10+
+ if (/(_open$|image|code_inline)/.test(token.type) && mapping[token.tag]) {
11+
const orig = splitWithSpace(token.attrGet('class'))
12+
const addition = toArray(mapping[token.tag])
13+
token.attrSet('class', [...orig, ...addition].join(' '))
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Markdown from './Markdown.vue'
2+
3+
describe('<Markdown />', () => {
4+
it('renders styled markdown', () => {
5+
const text = `
6+
# Heading 1
7+
## Heading 2
8+
### Heading 3
9+
#### Heading 4
10+
##### Heading 5
11+
###### Heading 6
12+
13+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec justo feugiat, auctor nunc ac, volutpat arcu. Suspendisse faucibus aliquam ante, sit amet iaculis dolor posuere et. In ut placerat leo.
14+
15+
Has **bold text** and *italic text* and \`code\`.
16+
17+
- list 1
18+
- list 2
19+
- list 3
20+
21+
1. numbered list 1
22+
2. numbered list 2
23+
3. numbered list 3
24+
25+
[a link](https://example.com)
26+
27+
\`\`\`
28+
const heres = {
29+
some: 'code',
30+
}
31+
\`\`\`
32+
33+
`
34+
35+
cy.mount(<Markdown
36+
text={text}
37+
codeClass='bg-gray-100 border-gray-300'
38+
/>)
39+
40+
cy.get('code').first().should('have.class', 'bg-gray-100 border-gray-300')
41+
cy.get('pre').first().should('have.class', 'bg-gray-100 border-gray-300')
42+
cy.get('ul').should('have.class', 'list-disc')
43+
})
44+
})

0 commit comments

Comments
 (0)