Skip to content

Commit

Permalink
Merge branch 'develop' into issue-7306-addSelector-redux
Browse files Browse the repository at this point in the history
  • Loading branch information
Blue F committed Sep 28, 2022
2 parents 5a2db61 + d2a7de1 commit 9263b69
Show file tree
Hide file tree
Showing 15 changed files with 468 additions and 181 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Expand Up @@ -1899,7 +1899,6 @@ jobs:

npm-cypress-schematic:
<<: *defaults
resource_class: small
steps:
- restore_cached_workspace
- run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/triage_closed_issue_comment.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
!github.event.issue.pull_request &&
github.event.issue.state == 'closed' &&
github.event.comment.created_at != github.event.issue.closed_at &&
github.event.sender.login != 'cypress-bot'
github.event.sender.login != 'cypress-bot[bot]'
runs-on: ubuntu-latest
steps:
- name: Get project data
Expand Down
13 changes: 13 additions & 0 deletions npm/angular/CHANGELOG.md
@@ -1,3 +1,16 @@
# [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-09-28)


### Bug Fixes

* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4))
* Fix missing `it.skip` function in Angular tests ([#23829](https://github.com/cypress-io/cypress/issues/23829)) ([64c0f45](https://github.com/cypress-io/cypress/commit/64c0f45182456bd43f4b64b2311e816dde615236))


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-09-27)


Expand Down
4 changes: 2 additions & 2 deletions npm/webpack-preprocessor/index.ts
Expand Up @@ -14,8 +14,8 @@ const debugStats = Debug('cypress:webpack:stats')

declare global {
// this indicates which commands should be acted upon by the
// cross-origin-callback-loader. its absense means the loader should not
// be utilized at all
// cross-origin-callback-loader. its absence means the loader
// should not be utilized at all
// eslint-disable-next-line no-var
var __cypressCallbackReplacementCommands: string[] | undefined
}
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/runs/RunsContainer.vue
Expand Up @@ -20,7 +20,6 @@
/>
<RunsEmpty
v-else-if="!currentProject?.cloudProject?.runs?.nodes.length"
:gql="currentProject"
/>
<div
v-else
Expand Down Expand Up @@ -80,7 +79,6 @@ fragment RunsContainer on Query {
currentProject {
id
projectId
...RunsEmpty
...RunsConnectSuccessAlert
cloudProject {
__typename
Expand Down
32 changes: 22 additions & 10 deletions packages/app/src/runs/RunsEmpty.cy.tsx
@@ -1,14 +1,26 @@
import RunsEmpty from './RunsEmpty.vue'
import { RunsEmptyFragmentDoc } from '../generated/graphql-test'
import { defaultMessages } from '@cy/i18n'

describe('<RunsEmpty />', () => {
it('playground', () => {
cy.mountFragment(RunsEmptyFragmentDoc, {
render (gqlVal) {
return (<div class="h-screen">
<RunsEmpty gql={gqlVal} />
</div>)
},
})
describe('RunsEmpty', () => {
it('renders expected content', () => {
cy.mount(<RunsEmpty />)

cy.gqlStub.Query.currentProject = {
id: 'test_id',
title: 'project_title',
currentTestingType: 'component',
cloudProject: {
__typename: 'CloudProject',
id: 'cloud_id',
recordKeys: [{
__typename: 'CloudRecordKey',
id: 'recordKey1',
key: 'abcd-efg-1234',
}],
} as any,
} as any

cy.contains(defaultMessages.specPage.banners.record.title).should('be.visible')
cy.contains('npx cypress run --component --record --key abcd-efg-1234').should('be.visible')
})
})
48 changes: 2 additions & 46 deletions packages/app/src/runs/RunsEmpty.vue
Expand Up @@ -10,59 +10,15 @@
<p class="h-48px mb-8px text-gray-600">
{{ t("runs.empty.description") }}
</p>
<TerminalPrompt
:command="recordCommand"
:project-folder-name="projectName"
class="max-w-700px"
/>
<RecordPromptAdapter />
</div>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { gql } from '@urql/vue'
import TerminalPrompt from '@cy/components/TerminalPrompt.vue'
import type { RunsEmptyFragment } from '../generated/graphql'
import RecordPromptAdapter from '@packages/frontend-shared/src/gql-components/RecordPromptAdapter.vue'
import { useI18n } from '@cy/i18n'
const { t } = useI18n()
gql`
fragment RunsEmpty on CurrentProject {
id
title
projectId
configFile
currentTestingType
cloudProject {
__typename
... on CloudProject {
id
recordKeys {
id
...RecordKey
}
}
}
}
`
const props = defineProps<{
gql: RunsEmptyFragment
}>()
const projectName = computed(() => props.gql.title)
const firstRecordKey = computed(() => {
return props.gql.cloudProject?.__typename === 'CloudProject' && props.gql.cloudProject.recordKeys?.[0]?.key
? props.gql.cloudProject.recordKeys[0].key
: '<record-key>'
})
const recordCommand = computed(() => {
const componentFlagOrSpace = props.gql.currentTestingType === 'component' ? ' --component ' : ' '
return `npx cypress run${componentFlagOrSpace}--record --key ${firstRecordKey.value}`
})
</script>

<style scoped lang="scss">
Expand Down
44 changes: 2 additions & 42 deletions packages/app/src/specs/banners/RecordBanner.vue
Expand Up @@ -19,44 +19,16 @@
<p class="mb-24px">
{{ t('specPage.banners.record.content') }}
</p>

<TerminalPrompt
:command="recordCommand"
:project-folder-name="query.data?.value?.currentProject?.title"
class="bg-white max-w-900px"
/>
<RecordPromptAdapter />
</TrackedBanner>
</template>

<script setup lang="ts">
import { gql, useQuery } from '@urql/vue'
import RecordIcon from '~icons/cy/action-record_x16.svg'
import { useI18n } from '@cy/i18n'
import TerminalPrompt from '@cy/components/TerminalPrompt.vue'
import TrackedBanner from './TrackedBanner.vue'
import { BannerIds } from '@packages/types'
import { RecordBannerDocument } from '../../generated/graphql'
import { computed } from 'vue'
gql`
query RecordBanner {
currentProject {
id
title
currentTestingType
cloudProject {
__typename
... on CloudProject {
id
recordKeys {
id
key
}
}
}
}
}
`
import RecordPromptAdapter from '@packages/frontend-shared/src/gql-components/RecordPromptAdapter.vue'
defineProps<{
modelValue: boolean
Expand All @@ -70,16 +42,4 @@ const emit = defineEmits<{
const { t } = useI18n()
const bannerId = BannerIds.ACI_082022_RECORD
const query = useQuery({ query: RecordBannerDocument })
const firstRecordKey = computed(() => {
return (query.data?.value?.currentProject?.cloudProject?.__typename === 'CloudProject' && query.data.value.currentProject.cloudProject.recordKeys?.[0]?.key) ?? '<record-key>'
})
const recordCommand = computed(() => {
const componentFlagOrSpace = query.data?.value?.currentProject?.currentTestingType === 'component' ? ' --component ' : ' '
return `npx cypress run${componentFlagOrSpace}--record --key ${firstRecordKey.value}`
})
</script>
27 changes: 27 additions & 0 deletions packages/frontend-shared/src/gql-components/RecordPrompt.cy.tsx
@@ -0,0 +1,27 @@
import RecordPromptVue from './RecordPrompt.vue'

describe('RecordPrompt', () => {
it('renders with no props', () => {
cy.mount(<RecordPromptVue />)

cy.findByText('npx cypress run --record --key <record-key>').should('be.visible')
})

it('renders with component testing type', () => {
cy.mount(<RecordPromptVue currentTestingType="component" />)

cy.findByText('npx cypress run --component --record --key <record-key>').should('be.visible')
})

it('renders with record key', () => {
cy.mount(<RecordPromptVue recordKey="abc-123" />)

cy.findByText('npx cypress run --record --key abc-123').should('be.visible')
})

it('renders with record key for component testing', () => {
cy.mount(<RecordPromptVue currentTestingType="component" recordKey="abc-123" />)

cy.findByText('npx cypress run --component --record --key abc-123').should('be.visible')
})
})
27 changes: 27 additions & 0 deletions packages/frontend-shared/src/gql-components/RecordPrompt.vue
@@ -0,0 +1,27 @@
<template>
<TerminalPrompt
:command="recordCommand"
class="bg-white max-w-900px"
/>
</template>

<script setup lang="ts">
import TerminalPrompt from '@cy/components/TerminalPrompt.vue'
import { computed } from 'vue'
const props = defineProps<{
recordKey?: string | null
currentTestingType?: string | null
}>()
const firstRecordKey = computed(() => {
return props.recordKey ?? '<record-key>'
})
const recordCommand = computed(() => {
const componentFlagOrSpace = props.currentTestingType === 'component' ? ' --component ' : ' '
return `npx cypress run${componentFlagOrSpace}--record --key ${firstRecordKey.value}`
})
</script>
@@ -0,0 +1,35 @@
<template>
<RecordPrompt
:record-key="query.data.value?.currentProject?.cloudProject?.__typename === 'CloudProject' ? query.data.value?.currentProject.cloudProject.recordKeys?.[0]?.key : ''"
:current-testing-type="query.data.value?.currentProject?.currentTestingType"
/>
</template>
<script setup lang="ts">
import { gql, useQuery } from '@urql/vue'
import { RecordPromptAdapterDocument } from '../generated/graphql'
import RecordPrompt from './RecordPrompt.vue'
gql`
query RecordPromptAdapter {
currentProject {
id
title
currentTestingType
cloudProject {
__typename
... on CloudProject {
id
recordKeys {
id
key
}
}
}
}
}
`
const query = useQuery({ query: RecordPromptAdapterDocument })
</script>
43 changes: 43 additions & 0 deletions packages/frontend-shared/src/gql-components/RecordRunModal.cy.tsx
@@ -0,0 +1,43 @@
import RecordRunModalVue from './RecordRunModal.vue'
import { defaultMessages } from '@cy/i18n'

describe('RecordRunModal', () => {
it('is not open by default', () => {
cy.mount(<RecordRunModalVue isModalOpen={false} close={cy.stub()} utmMedium="Nav" />)

cy.findByTestId('record-run-modal').should('not.exist')
})

it('renders open', () => {
cy.mount(<RecordRunModalVue isModalOpen={true} close={cy.stub()} utmMedium="Nav" />)

cy.contains(defaultMessages.specPage.banners.record.title).should('be.visible')
cy.findByTestId('copy-button').should('be.visible')

cy.contains('npx cypress run --record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa').should('be.visible')

cy.percySnapshot()
})

it('calls close when X is clicked', () => {
const closeStub = cy.stub()

cy.mount(<RecordRunModalVue isModalOpen={true} close={closeStub} utmMedium="Nav" />)

cy.findByRole('button', { name: defaultMessages.actions.close }).click().then(() => {
expect(closeStub).to.have.been.called
})
})

it('sends UTM parameters with help link', () => {
cy.mount(<RecordRunModalVue isModalOpen={true} close={cy.stub()} utmMedium="Nav" utmContent="content" />)

cy.contains(defaultMessages.links.needHelp).should('have.attr', 'href', 'https://on.cypress.io/cypress-run-record-key?utm_medium=Nav&utm_source=Binary%3A+Launchpad&utm_content=content')
})

it('sends UTM parameters with help link without UTM content prop', () => {
cy.mount(<RecordRunModalVue isModalOpen={true} close={cy.stub()} utmMedium="Nav" />)

cy.contains(defaultMessages.links.needHelp).should('have.attr', 'href', 'https://on.cypress.io/cypress-run-record-key?utm_medium=Nav&utm_source=Binary%3A+Launchpad&utm_content=')
})
})

0 comments on commit 9263b69

Please sign in to comment.