-
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
feat: add spec pattern modal #19801
feat: add spec pattern modal #19801
Changes from 2 commits
2299cd0
4bac8df
8bbae88
43030d7
f7c1902
96b6473
86ee997
40c8253
5ed7e58
e051c15
718cde7
5e2cf9b
309a6a8
30b97b2
67bf00f
9f47eee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { SpecPatternModalFragmentDoc } from '../generated/graphql-test' | ||
import SpecPatternModal from './SpecPatternModal.vue' | ||
import { defaultMessages } from '@cy/i18n' | ||
|
||
describe('<SpecPatternModal />', () => { | ||
it('should not render if closed', () => { | ||
cy.mountFragment(SpecPatternModalFragmentDoc, { | ||
render (gql) { | ||
return (<SpecPatternModal gql={gql} show={false} />) | ||
}, | ||
}) | ||
|
||
cy.get('[data-cy="spec-pattern-modal"]').should('not.exist') | ||
}) | ||
|
||
it('should render and close', () => { | ||
const closeSpy = cy.stub().as('closeSpy') | ||
|
||
cy.mountFragment(SpecPatternModalFragmentDoc, { | ||
render (gql) { | ||
return (<SpecPatternModal gql={gql} show={true} onClose={closeSpy} />) | ||
}, | ||
}) | ||
|
||
cy.get('[data-cy="spec-pattern-modal"]').should('be.visible') | ||
cy.contains('h2', defaultMessages.components.specPatternModal.title) | ||
cy.get('[data-cy="external"]').should('have.attr', 'href').and('eq', 'https://on.cypress.io') | ||
cy.get('[data-cy="spec-pattern"]').should('be.visible') | ||
|
||
cy.percySnapshot() | ||
|
||
cy.get('[data-cy="open-config-file"').should('be.visible') | ||
cy.contains('button', defaultMessages.createSpec.updateSpecPattern) | ||
|
||
cy.contains('button', defaultMessages.components.modal.dismiss).click() | ||
|
||
cy.get('@closeSpy').should('have.been.called') | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<StandardModal | ||
class="transition-all transition duration-200" | ||
variant="bare" | ||
:title="t('components.specPatternModal.title')" | ||
:model-value="show" | ||
data-cy="spec-pattern-modal" | ||
help-link="https://on.cypress.io" | ||
@update:model-value="emits('close')" | ||
> | ||
<div | ||
class="w-full p-24px sm:min-w-640px" | ||
> | ||
<SpecPatterns | ||
:gql="props.gql" | ||
class="border-gray-100 rounded border-px" | ||
/> | ||
</div> | ||
<StandardModalFooter | ||
class="flex items-center h-72px gap-16px" | ||
> | ||
<OpenConfigFileInIDE> | ||
<Button size="lg"> | ||
<template #prefix> | ||
<i-cy-code-editor_x16 class="icon-dark-white" /> | ||
</template> | ||
{{ t('createSpec.updateSpecPattern') }} | ||
</Button> | ||
</OpenConfigFileInIDE> | ||
<Button | ||
variant="outline" | ||
size="lg" | ||
@click="emits('close')" | ||
> | ||
{{ t('components.modal.dismiss') }} | ||
</Button> | ||
</StandardModalFooter> | ||
</StandardModal> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import StandardModal from '@cy/components/StandardModal.vue' | ||
import SpecPatterns from '../components/SpecPatterns.vue' | ||
import { useI18n } from '@cy/i18n' | ||
import type { SpecPatternModalFragment } from '../generated/graphql' | ||
import { gql } from '@urql/core' | ||
import StandardModalFooter from '@cy/components/StandardModalFooter.vue' | ||
import Button from '../../../frontend-shared/src/components/Button.vue' | ||
import OpenConfigFileInIDE from '../../../frontend-shared/src/gql-components/OpenConfigFileInIDE.vue' | ||
|
||
gql` | ||
fragment SpecPatternModal on CurrentProject { | ||
id | ||
...SpecPatterns | ||
} | ||
` | ||
|
||
const props = defineProps<{ | ||
gql: SpecPatternModalFragment | ||
show: boolean | ||
}>() | ||
|
||
const { t } = useI18n() | ||
|
||
const emits = defineEmits<{ | ||
(eventName: 'close'): void | ||
}>() | ||
</script> |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||||
<template> | ||||||||
<div class="flex w-full gap-16px relative"> | ||||||||
<div class="relative flex w-full gap-16px"> | ||||||||
<Input | ||||||||
type="search" | ||||||||
class="flex-grow h-full min-w-200px" | ||||||||
|
@@ -10,12 +10,18 @@ | |||||||
@input="onInput" | ||||||||
> | ||||||||
<template #suffix> | ||||||||
<div | ||||||||
class="text-gray-500 border-l border-l-gray-100 pl-16px" | ||||||||
<button | ||||||||
class="mr-[-0.75rem] h-40px outline-none hover:(bg-indigo-50 text-indigo-500) transition-all rounded-r-md group" | ||||||||
data-cy="open-spec-pattern-modal" | ||||||||
aria-live="polite" | ||||||||
@click="emit('specPattern')" | ||||||||
> | ||||||||
{{ resultCount }} {{ resultCount === 1 ? t('specPage.matchSingular') : t('specPage.matchPlural') }} | ||||||||
</div> | ||||||||
<span | ||||||||
class="block border-l h-24px px-16px border-l-gray-100 group-hover:border-none" | ||||||||
> | ||||||||
{{ resultCount }} {{ resultCount === 1 ? t('specPage.matchSingular') : t('specPage.matchPlural') }} | ||||||||
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.
Suggested change
If we add an 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. Updated! I noticed alignment issues as well but they disappeared and I can't reproduce them. Could have been a new class that wasn't picked up if 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. that sounds right! |
||||||||
</span> | ||||||||
</button> | ||||||||
</template> | ||||||||
</Input> | ||||||||
|
||||||||
|
@@ -53,6 +59,7 @@ const props = withDefaults(defineProps<{ | |||||||
const emit = defineEmits<{ | ||||||||
(e: 'update:modelValue', value: string): void, | ||||||||
(e: 'newSpec'): void | ||||||||
(e: 'specPattern'): void | ||||||||
}>() | ||||||||
|
||||||||
const onInput = (e: Event) => { | ||||||||
|
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.
Should we combine the
v-if
and:show
? It looks like they do same thing (conditionally hide/show?)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.
I think they have different purposes here. It might be better to make the v-if depend just on
props.gql.currentProject
so that the SpecPatternModal component renders only once, when there is acurrentProject
, and keepbindingsOpen
to only manage the open/closed state. With the current v-if we add/remove the component from the DOM, at the same time as we are opening and closing the modal.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.
@marktnoonan I'll implement what you've stated above, and also rename some variables as
bindingsOpen
was a copy and paste and it should be named more contextually.