Skip to content
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

chore: fix some tests, minor refactor #23545

Merged
merged 3 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app/src/navigation/KeyboardBindingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:title="t('sidebar.keyboardShortcuts.title')"
:model-value="show"
data-cy="keyboard-modal"
help-link=""
:no-help="true"
@update:model-value="emits('close')"
>
<ul class="m-24px w-384px">
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/runner/studio/StudioSaveModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<StandardModal
:model-value="props.open"
:no-help="true"
variant="bare"
data-cy="studio-save-modal"
@update:model-value="emit('close')"
Expand Down
26 changes: 26 additions & 0 deletions packages/frontend-shared/src/components/StandardModal.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@ describe('<StandardModal />', { viewportWidth: 800, viewportHeight: 400 }, () =>
cy.percySnapshot()
})

it('does not render helpLink when noHelp is true', () => {
cy.mount(
<StandardModal
class="w-400px"
modelValue={true}
noHelp={true}
title={title}
>
{body}
</StandardModal>,
)

cy.contains('a', defaultMessages.links.needHelp).should('not.exist')

cy.findByLabelText(defaultMessages.actions.close, {
selector: 'button',
})
.should('be.visible')
.and('not.be.disabled')

cy.contains('h2', title).should('be.visible')
cy.contains(body).should('be.visible')

cy.percySnapshot()
})

it('bare variant renders without padding in body', () => {
cy.mount(<StandardModal
class="w-400px"
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend-shared/src/components/StandardModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:class="props.class || ''"
>
<StandardModalHeader
:no-help="noHelp"
:help-link="helpLink"
:help-text="helpText"
@close="closeModal"
Expand Down Expand Up @@ -72,12 +73,14 @@ const props = withDefaults(defineProps<{
helpLink?: string
helpText?: string
variant?: 'bare'
noHelp?: boolean
title?: string
class?: string | string[] | Record<string, any>
}>(), {
modelValue: false,
helpText: `${defaultMessages.links.needHelp}`,
helpLink: '',
noHelp: false,
helpLink: 'https://on.cypress.io',
class: undefined,
variant: undefined,
title: '',
Expand Down
29 changes: 17 additions & 12 deletions packages/frontend-shared/src/components/StandardModalHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
<DialogTitle class="text-gray-900 text-18px inline-block">
<slot />
</DialogTitle>
<span
v-if="helpLink.length"
class="border-t border-t-gray-100 h-6px mx-8px w-32px inline-block"
/> <ExternalLink
v-if="helpLink.length"
:href="helpLink"
class="outline-transparent text-indigo-500 text-16px group"
>
<span class="group-hocus:underline">{{ helpText }}</span>

<template v-if="!noHelp">
<span class="border-t border-t-gray-100 h-6px mx-8px w-32px inline-block" />
<ExternalLink
:href="helpLink"
class="outline-transparent text-indigo-500 text-16px group"
>
<span class="group-hocus:underline">{{ helpText }}</span>
</ExternalLink>

<i-cy-circle-bg-question-mark_x16 class="ml-8px -top-2px relative inline-block icon-dark-indigo-500 icon-light-indigo-100" />
</ExternalLink>
</template>
</div>

<button
:aria-label="t(`actions.close`)"
class="border-transparent rounded-full outline-none border-1 group"
Expand All @@ -35,10 +37,13 @@ import { useI18n } from '@cy/i18n'

const { t } = useI18n()

defineProps<{
withDefaults(defineProps<{
helpLink: string
helpText: string
}>()
noHelp?: boolean
}>(), {
noHelp: false,
})

defineEmits<{
(eventName: 'close'): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
variant="bare"
:title="title"
:model-value="show"
help-link=""
:no-help="true"
@update:model-value="emits('close')"
>
<div class="p-24px text-gray-700">
Expand Down
4 changes: 4 additions & 0 deletions packages/reporter/cypress/e2e/tests.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ describe('studio controls', () => {
})

describe('button', () => {
beforeEach(() => {
runner.emit('reporter:start', { studioActive: false })
})

it('displays studio icon with half transparency when hovering over test title', { scrollBehavior: false }, () => {
cy.contains('test 1')
.closest('.runnable-wrapper')
Expand Down