-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(unify): fixing icons and supporting router within the shared cypress commands package #18237
Merged
JessicaSachs
merged 4 commits into
unified-desktop-gui
from
fix/icon-colors-and-shared-plugins
Sep 24, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3676263
fix(unify): fixing icons and supporting router within the shared cypr…
JessicaSachs cb1055e
Update icon-color-plugins.ts
JessicaSachs 94e2744
fix: icon colors broken in tests because of windi.config file moving …
JessicaSachs 9118348
Merge branch 'fix/icon-colors-and-shared-plugins' of github.com:cypre…
JessicaSachs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/app/.windicss/windi.config.ts → packages/app/windi.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { testUrqlClient } from '@packages/frontend-shared/src/graphql/testUrqlCl | |
import { Component, computed, watch, defineComponent, h } from 'vue' | ||
import { ClientTestContext } from '../../src/graphql/ClientTestContext' | ||
import type { TestSourceTypeLookup } from '@packages/graphql/src/testing/testUnionType' | ||
import { createI18n } from '@packages/launchpad/src/locales/i18n' | ||
import { each } from 'lodash' | ||
import 'cypress-file-upload' | ||
|
||
/** | ||
|
@@ -19,9 +19,45 @@ import 'cypress-file-upload' | |
send: () => {}, | ||
} | ||
|
||
Cypress.Commands.add( | ||
'mount', | ||
<C extends Parameters<typeof mount>[0]>(comp: C, options: CyMountOptions<C> = {}) => { | ||
export const registerMountFn = ({ plugins }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC @lmiller1990 🎉 |
||
Cypress.Commands.add( | ||
'mount', | ||
<C extends Parameters<typeof mount>[0]>(comp: C, options: CyMountOptions<C> = {}) => { | ||
const context = new ClientTestContext({ | ||
config: {}, | ||
cwd: '/dev/null', | ||
// @ts-ignore | ||
browser: null, | ||
global: false, | ||
project: '/dev/null', | ||
projectRoot: '/dev/null', | ||
invokedFromCli: true, | ||
testingType: 'e2e', | ||
os: 'darwin', | ||
_: [''], | ||
}, {}) | ||
|
||
options.global = options.global || {} | ||
options.global.stubs = options.global.stubs || {} | ||
options.global.stubs.transition = false | ||
options.global.plugins = options.global.plugins || [] | ||
each(plugins, (pluginFn: () => any) => { | ||
options?.global?.plugins?.push(pluginFn()) | ||
}) | ||
|
||
options.global.plugins.push({ | ||
install (app) { | ||
app.use(urql, testUrqlClient({ | ||
context, | ||
})) | ||
}, | ||
}) | ||
|
||
return mount(comp, options) | ||
}, | ||
) | ||
|
||
function mountFragment<Result, Variables, T extends TypedDocumentNode<Result, Variables>> (source: T, options: MountFragmentConfig<T>, list: boolean = false): Cypress.Chainable<ClientTestContext> { | ||
const context = new ClientTestContext({ | ||
config: {}, | ||
cwd: '/dev/null', | ||
|
@@ -36,111 +72,79 @@ Cypress.Commands.add( | |
_: [''], | ||
}, {}) | ||
|
||
options.global = options.global || {} | ||
options.global.stubs = options.global.stubs || {} | ||
options.global.stubs.transition = false | ||
options.global.plugins = options.global.plugins || [] | ||
options.global.plugins.push(createI18n()) | ||
options.global.plugins.push({ | ||
install (app) { | ||
app.use(urql, testUrqlClient({ | ||
context, | ||
})) | ||
}, | ||
}) | ||
|
||
return mount(comp, options) | ||
}, | ||
) | ||
|
||
function mountFragment<Result, Variables, T extends TypedDocumentNode<Result, Variables>> (source: T, options: MountFragmentConfig<T>, list: boolean = false): Cypress.Chainable<ClientTestContext> { | ||
const context = new ClientTestContext({ | ||
config: {}, | ||
cwd: '/dev/null', | ||
// @ts-ignore | ||
browser: null, | ||
global: false, | ||
project: '/dev/null', | ||
projectRoot: '/dev/null', | ||
invokedFromCli: true, | ||
testingType: 'e2e', | ||
os: 'darwin', | ||
_: [''], | ||
}, {}) | ||
|
||
let hasMounted = false | ||
|
||
return mount(defineComponent({ | ||
name: `mountFragment`, | ||
setup () { | ||
const fieldName = list ? 'testFragmentMemberList' : 'testFragmentMember' | ||
const result = useQuery({ | ||
query: ` | ||
query MountFragmentTest { | ||
${fieldName} { | ||
...${(source.definitions[0] as FragmentDefinitionNode).name.value} | ||
let hasMounted = false | ||
|
||
return mount(defineComponent({ | ||
name: `mountFragment`, | ||
setup () { | ||
const fieldName = list ? 'testFragmentMemberList' : 'testFragmentMember' | ||
const result = useQuery({ | ||
query: ` | ||
query MountFragmentTest { | ||
${fieldName} { | ||
...${(source.definitions[0] as FragmentDefinitionNode).name.value} | ||
} | ||
} | ||
} | ||
${print(source)} | ||
`, | ||
}) | ||
|
||
if (!options.expectError) { | ||
watch(result.error, (o) => { | ||
if (result.error.value) { | ||
cy.log('GraphQL Error', result.error.value).then(() => { | ||
throw result.error.value | ||
}) | ||
} | ||
${print(source)} | ||
`, | ||
}) | ||
} | ||
|
||
return { | ||
gql: computed(() => result.data.value?.[fieldName]), | ||
} | ||
}, | ||
render: (props) => { | ||
if (props.gql && !hasMounted) { | ||
hasMounted = true | ||
Cypress.log({ | ||
displayName: 'gql', | ||
message: (source.definitions[0] as FragmentDefinitionNode).name.value, | ||
consoleProps () { | ||
return { | ||
gql: props.gql, | ||
source: print(source), | ||
if (!options.expectError) { | ||
watch(result.error, (o) => { | ||
if (result.error.value) { | ||
cy.log('GraphQL Error', result.error.value).then(() => { | ||
throw result.error.value | ||
}) | ||
} | ||
}, | ||
}).end() | ||
} | ||
}) | ||
} | ||
|
||
return props.gql ? options.render(props.gql) : h('div') | ||
}, | ||
}), { | ||
global: { | ||
stubs: { | ||
transition: false, | ||
return { | ||
gql: computed(() => result.data.value?.[fieldName]), | ||
} | ||
}, | ||
plugins: [ | ||
createI18n(), | ||
{ | ||
install (app) { | ||
app.use(urql, testUrqlClient({ | ||
context, | ||
rootValue: options.type(context), | ||
})) | ||
}, | ||
render: (props) => { | ||
if (props.gql && !hasMounted) { | ||
hasMounted = true | ||
Cypress.log({ | ||
displayName: 'gql', | ||
message: (source.definitions[0] as FragmentDefinitionNode).name.value, | ||
consoleProps () { | ||
return { | ||
gql: props.gql, | ||
source: print(source), | ||
} | ||
}, | ||
}).end() | ||
} | ||
|
||
return props.gql ? options.render(props.gql) : h('div') | ||
}, | ||
}), { | ||
global: { | ||
stubs: { | ||
transition: false, | ||
}, | ||
], | ||
}, | ||
}).then(() => context) | ||
} | ||
plugins: [ | ||
{ | ||
install (app) { | ||
app.use(urql, testUrqlClient({ | ||
context, | ||
rootValue: options.type(context), | ||
})) | ||
}, | ||
}, | ||
], | ||
}, | ||
}).then(() => context) | ||
} | ||
|
||
Cypress.Commands.add('mountFragment', mountFragment) | ||
Cypress.Commands.add('mountFragment', mountFragment) | ||
|
||
Cypress.Commands.add('mountFragmentList', (source, options) => { | ||
return mountFragment(source, options, true) | ||
}) | ||
Cypress.Commands.add('mountFragmentList', (source, options) => { | ||
return mountFragment(source, options, true) | ||
}) | ||
} | ||
|
||
type GetRootType<T> = T extends TypedDocumentNode<infer U, any> | ||
? U extends { __typename?: infer V } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
import '@packages/frontend-shared/cypress/support/commands' | ||
import { registerMountFn } from '@packages/frontend-shared/cypress/support/commands' | ||
import { createI18n } from '@packages/launchpad/src/locales/i18n' | ||
|
||
registerMountFn({ plugins: [() => createI18n()] }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum... but OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was wrong the first time I wrote it.