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

feat: IATR-M1.0 Debug Spec component update #25263

Merged
merged 22 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
36b2faf
made stats meta data reusable component and completed inital ui chang…
amehta265 Dec 12, 2022
f4de398
Added debugArtifacts, layered browser icons, and updated debug failed…
amehta265 Dec 14, 2022
dd44de7
updated UI and merged feature branch
amehta265 Dec 15, 2022
a1b0601
added preliminary tests for debugArtifacts
amehta265 Dec 15, 2022
dea2f61
tests for debugArtifacts and debugFailedTest
amehta265 Dec 15, 2022
a16fb90
completed all tests and made responsive UI changes
amehta265 Dec 20, 2022
3aede58
added new debugMapping functionality and wired up rest of the components
amehta265 Dec 22, 2022
167cf15
merged with feature branch and updated tests
amehta265 Dec 23, 2022
54714e0
Merge branch 'feature/IATR-M0' into ankit/IATR-M1.0-spec-component-up…
amehta265 Dec 23, 2022
4088d83
changes for responsive UI
amehta265 Dec 23, 2022
95023ec
restoring projectId in cypress config for app
amehta265 Dec 23, 2022
c43b2d8
cleaning lint issues
amehta265 Dec 23, 2022
b5e1bbc
addressing PR comments
amehta265 Dec 27, 2022
dbe0fe7
Ensure zero values render icons for ResultCounts
warrensplayer Dec 28, 2022
a75501e
Add two missing fields
warrensplayer Dec 28, 2022
9ffadc7
Updates for typescript fixes
warrensplayer Dec 29, 2022
dc694dc
Allowing element to render when value is 0
warrensplayer Dec 29, 2022
acb411b
completed responsive UI for spec component and test section
amehta265 Dec 29, 2022
f24c6e8
merging with remote branch
amehta265 Dec 29, 2022
a9fbbee
resolving conflicts with feature branch
amehta265 Dec 29, 2022
7352797
merging with feature branch and addressing PR comments
amehta265 Dec 30, 2022
c68fbcb
StatsMetadata i18n fix
warrensplayer Dec 30, 2022
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
40 changes: 40 additions & 0 deletions packages/app/src/debug/DebugArtifactLink.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import DebugArtifactLink from './DebugArtifactLink.vue'

describe('<DebugArtifacts />', () => {
const artifactMapping: {icon: string, text: string, url: string}[] = [
{ icon: 'TERMINAL_LOG', text: 'View Log', url: 'www.cypress.io' },
{ icon: 'IMAGE_SCREENSHOT', text: 'View Screenshot', url: 'cloud.cypress.io' },
{ icon: 'PLAY', text: 'View Video', url: 'www.cypress.io' },
]

it('mounts correctly, provides expected tooltip content, and emits correct event', () => {
artifactMapping.forEach((artifact) => {
cy.mount(() => (
<DebugArtifactLink icon={artifact.icon} popperText={artifact.text} url={artifact.url}/>
))

cy.findByTestId(`artifact-for-${artifact.icon}`).should('have.length', 1)
cy.findByTestId(`${artifact.icon}-button`).should('be.visible')
cy.findByTestId(`artifact-for-${artifact.icon}`).realHover().then(() => {
cy.findByTestId('tooltip-content').should('be.visible').contains(artifact.text)
})

cy.percySnapshot()
})
})

it('mounts correctly for all icons together and has correct URLs', () => {
cy.mount(() => (
<div class="flex flex-grow space-x-4.5 pt-24px justify-center" data-cy='debug-artifacts-all'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed an opportunity here, we could grab the very similar looking code here and here to make a DebugArtifactLinkList component or something. We seem to have the idea of this component 3 places if you include this test, and the presence in the test tells me we want to see the artifact links grouped on their own like this.

<DebugArtifactLink icon={'TERMINAL_LOG'} popperText={'View Log'} url={'www.cypress.io'}/>
<DebugArtifactLink icon={'IMAGE_SCREENSHOT'} popperText={'View Screenshot'} url={'cloud.cypress.io'}/>
<DebugArtifactLink icon={'PLAY'} popperText={'View Video'} url={'www.cypress.io'}/>
</div>
))

cy.findByTestId('debug-artifacts-all').children().should('have.length', 3)
cy.findByTestId(`TERMINAL_LOG-button`).should('have.attr', 'href', 'www.cypress.io')
cy.findByTestId(`IMAGE_SCREENSHOT-button`).should('have.attr', 'href', 'cloud.cypress.io')
cy.findByTestId(`PLAY-button`).should('have.attr', 'href', 'www.cypress.io')
})
})
50 changes: 50 additions & 0 deletions packages/app/src/debug/DebugArtifactLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<Tooltip
placement="bottom"
:data-cy="`artifact-for-${icon}`"
>
<ExternalLink
class="flex h-full w-full items-center justify-center"
:data-cy="`${icon}-button`"
:href="props.url || '#'"
:use-default-hocus="true"
:aria-label="popperText"
>
<component
:is="ICON_MAP[icon]"
stroke-color="gray-600"
fill-color="gray-100"
hocus-stroke-color="indigo-500"
hocus-fill-color="indigo-100"
/>
</ExternalLink>
<template #popper>
<span
class="font-normal text-sm inline-flex"
data-cy="tooltip-content"
>
{{ popperText }}
</span>
</template>
</Tooltip>
</template>
<script lang="ts" setup>
import { IconTechnologyTerminalLog, IconTechnologyImageScreenshot, IconActionPlaySmall } from '@cypress-design/vue-icon'
import Tooltip from '@packages/frontend-shared/src/components/Tooltip.vue'
import ExternalLink from '@cy/gql-components/ExternalLink.vue'

const props = defineProps<{
icon: string
popperText: string
url: string | null | undefined
}>()

type ArtifactType = 'TERMINAL_LOG' | 'IMAGE_SCREENSHOT' | 'PLAY'

const ICON_MAP: Record<ArtifactType, any> = {
'TERMINAL_LOG': IconTechnologyTerminalLog,
'IMAGE_SCREENSHOT': IconTechnologyImageScreenshot,
'PLAY': IconActionPlaySmall,
}

</script>
72 changes: 58 additions & 14 deletions packages/app/src/debug/DebugContainer.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ describe('<DebugContainer />', () => {
{ id: 'a1c', groupIds: ['a'] },
] as DebugSpecListSpecFragment[]
const tests = [
{ specId: 'a1c', id: 'random1' },
{ specId: 'a1c', id: 'random2' },
{ specId: 'a1c', id: 'random1', thumbprint: 'unique1' },
{ specId: 'a1c', id: 'random2', thumbprint: 'unique2' },
] as DebugSpecListTestsFragment[]
const groups = [
{ id: 'a', testingType: 'e2e' },
Expand All @@ -272,7 +272,16 @@ describe('<DebugContainer />', () => {
const debugMappingArray = specsList({ specs, tests, groups, localSpecs: [], currentTestingType: 'e2e' })

expect(debugMappingArray).to.have.length(1)
expect(debugMappingArray[0]).to.deep.equal({ spec: { id: 'a1c', groupIds: ['a'] }, tests: [{ specId: 'a1c', id: 'random1' }, { specId: 'a1c', id: 'random2' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true })
expect(debugMappingArray).to.have.eql([
{
spec: { id: 'a1c', groupIds: ['a'] },
tests: { 'unique1': [{ specId: 'a1c', id: 'random1', thumbprint: 'unique1' }], 'unique2': [{ specId: 'a1c', id: 'random2', thumbprint: 'unique2' }] },
groups: { 'a': { id: 'a', testingType: 'e2e' } },
foundLocally: false,
testingType: 'e2e',
matchesCurrentTestingType: true,
},
])
})

it('maps correctly for multiple specs and test', () => {
Expand All @@ -282,23 +291,48 @@ describe('<DebugContainer />', () => {
{ id: '789', groupIds: ['a', 'b'] },
] as DebugSpecListSpecFragment[]
const tests = [
{ specId: '123', id: 'random1' },
{ specId: '456', id: 'random2' },
{ specId: '456', id: 'random3' },
{ specId: '789', id: 'random4' },
{ specId: '123', id: 'random6' },
{ specId: '123', id: 'random1', thumbprint: 'unique1' },
{ specId: '456', id: 'random2', thumbprint: 'unique2' },
{ specId: '456', id: 'random3', thumbprint: 'unique3' },
{ specId: '789', id: 'random4', thumbprint: 'unique4' },
{ specId: '123', id: 'random6', thumbprint: 'unique5' },
{ specId: '789', id: 'random7', thumbprint: 'unique4' },
] as DebugSpecListTestsFragment[]
const groups = [
{ id: 'a', testingType: 'e2e' },
{ id: 'b', testingType: 'e2e' },
] as DebugSpecListGroupsFragment[]

const debugMappingArray = specsList({ specs, tests, localSpecs: [], currentTestingType: 'e2e', groups })
const expectedSpec123 = {
spec: { id: '123', groupIds: ['a'] },
tests: { 'unique1': [{ specId: '123', id: 'random1', thumbprint: 'unique1' }], 'unique5': [{ specId: '123', id: 'random6', thumbprint: 'unique5' }] },
groups: { 'a': { id: 'a', testingType: 'e2e' } },
foundLocally: false,
testingType: 'e2e',
matchesCurrentTestingType: true,
}

const expectedSpec456 = {
spec: { id: '456', groupIds: ['b'] },
tests: { 'unique2': [{ specId: '456', id: 'random2', thumbprint: 'unique2' }], 'unique3': [{ specId: '456', id: 'random3', thumbprint: 'unique3' }] },
groups: { 'b': { id: 'b', testingType: 'e2e' } },
foundLocally: false,
testingType: 'e2e',
matchesCurrentTestingType: true,
}

const expectedSpec789 = {
spec: { id: '789', groupIds: ['a', 'b'] },
tests: { 'unique4': [{ specId: '789', id: 'random4', thumbprint: 'unique4' }, { specId: '789', id: 'random7', thumbprint: 'unique4' }] },
groups: { 'a': { id: 'a', testingType: 'e2e' }, 'b': { id: 'b', testingType: 'e2e' } },
foundLocally: false,
testingType: 'e2e',
matchesCurrentTestingType: true,
}

const expected = [
{ spec: { id: '123', groupIds: ['a'] }, tests: [{ specId: '123', id: 'random1' }, { specId: '123', id: 'random6' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true },
{ spec: { id: '456', groupIds: ['b'] }, tests: [{ specId: '456', id: 'random2' }, { specId: '456', id: 'random3' }], groups: [{ id: 'b', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true },
{ spec: { id: '789', groupIds: ['a', 'b'] }, tests: [{ specId: '789', id: 'random4' }], groups: [{ id: 'a', testingType: 'e2e' }, { id: 'b', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true },
expectedSpec123, expectedSpec456, expectedSpec789,
]

expect(debugMappingArray).to.deep.equal(expected)
Expand All @@ -310,13 +344,23 @@ describe('<DebugContainer />', () => {
{ id: '456', groupIds: ['a'] },
{ id: '789', groupIds: ['a'] },
] as DebugSpecListSpecFragment[]
const tests = [{ specId: '123', id: 'random1' }] as DebugSpecListTestsFragment[]
const tests = [{ specId: '123', id: 'random1', thumbprint: 'unique1' }] as DebugSpecListTestsFragment[]
const groups = [{ id: 'a', testingType: 'e2e' }] as DebugSpecListGroupsFragment[]

const debugMappingArray = specsList({ specs, tests, localSpecs: [], currentTestingType: 'e2e', groups })

expect(debugMappingArray).to.have.length(1)
expect(debugMappingArray).to.deep.equal([{ spec: { id: '123', groupIds: ['a'] }, tests: [{ specId: '123', id: 'random1' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }])
expect(debugMappingArray).to.deep.equal(
[
{
spec: { id: '123', groupIds: ['a'] },
tests: { 'unique1': [{ specId: '123', id: 'random1', thumbprint: 'unique1' }] },
groups: { 'a': { id: 'a', testingType: 'e2e' } },
foundLocally: false,
testingType: 'e2e',
matchesCurrentTestingType: true,
},
],
)
})

it('throws an error when a test does not map to a spec', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/debug/DebugContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fragment DebugSpecs on Query {
__typename
... on CloudProject {
id
runByNumber(runNumber: 11) {
runByNumber(runNumber: 1) {
...DebugPageHeader
cancelledBy {
id
Expand Down
Loading