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: Support "Queued" latest run status #22497

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
208 changes: 107 additions & 101 deletions packages/app/src/specs/RunStatusDots.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,122 +1,128 @@
import type { RunStatusDotsFragment } from '../generated/graphql'
import RunStatusDots from './RunStatusDots.vue'
import { fakeRuns } from '@packages/frontend-shared/cypress/support/mock-graphql/fakeCloudSpecRun'
import { fill } from 'lodash'
import type { CloudSpecRun } from '@packages/graphql/src/gen/cloud-source-types.gen'

describe('<RunStatusDots />', () => {
it('mounts correctly for example scenario 1', () => {
const runs = fakeRuns(['PASSED', 'FAILED', 'CANCELLED', 'ERRORED'])

cy.mount(() => {
const gql: RunStatusDotsFragment = {
id: 'id',
data: {
__typename: 'CloudProjectSpec',
retrievedAt: new Date().toISOString(),
id: 'id',
specRuns: {
nodes: [
...runs as any, // suppress TS compiler
],
},
},
}

return (
function mountWithRuns (runs: Required<CloudSpecRun>[]) {
const gql: RunStatusDotsFragment = {
id: 'id',
data: {
__typename: 'CloudProjectSpec',
retrievedAt: new Date().toISOString(),
id: 'id',
specRuns: {
nodes: [
...runs as any, // suppress TS compiler
],
},
},
}

cy.mount(() => {
return (
<div class="flex justify-center">
<RunStatusDots gql={gql} specFileExtension=".cy.ts" specFileName="spec"/>
)
</div>
)
})
}

describe('<RunStatusDots />', () => {
context('runs scenario 1', () => {
beforeEach(() => {
const runs = fakeRuns(['PASSED', 'FAILED', 'CANCELLED', 'ERRORED'])

mountWithRuns(runs)
})

cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-orange-400')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-red-400')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
it('renders as expected', () => {
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-orange-400')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-red-400')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
})
})

it('mounts correctly for example scenario 2', () => {
const runs = fakeRuns(['NOTESTS', 'OVERLIMIT', 'RUNNING', 'TIMEDOUT'])

cy.mount(() => {
const gql: RunStatusDotsFragment = {
id: 'id',
data: {
__typename: 'CloudProjectSpec',
id: 'id',
retrievedAt: new Date().toISOString(),
specRuns: {
nodes: [
...runs as any, // suppress TS compiler
],
},
},
}

return (
<RunStatusDots gql={gql} specFileExtension=".cy.ts" specFileName="spec"/>
)
context('runs scenario 2', () => {
beforeEach(() => {
const runs = fakeRuns(['NOTESTS', 'UNCLAIMED', 'RUNNING', 'TIMEDOUT'])

mountWithRuns(runs)
})

cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-orange-400')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-indigo-400')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-orange-400')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
it('renders as expected', () => {
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-orange-400')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-indigo-400')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-gray-400')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
})
})

it('mounts correctly for example scenario 3', () => {
const runs = fakeRuns(['RUNNING'])

cy.mount(() => {
const gql: RunStatusDotsFragment = {
id: 'id',
data: {
__typename: 'CloudProjectSpec',
id: 'id',
retrievedAt: new Date().toISOString(),
specRuns: {
nodes: [
...runs as any, // suppress TS compiler
],
},
},
}

return (
<RunStatusDots gql={gql} specFileExtension=".cy.ts" specFileName="spec"/>
)
context('single RUNNING status', () => {
beforeEach(() => {
const runs = fakeRuns(['RUNNING'])

mountWithRuns(runs)
})

cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-latest').should('have.class', 'animate-spin')
it('renders as expected', () => {
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-latest').should('have.class', 'animate-spin')
})
})

it('renders placeholder without tooltip or link', () => {
cy.mount(() => {
const gql: RunStatusDotsFragment = {
id: 'id',
data: {
__typename: 'CloudProjectSpec',
id: 'id',
retrievedAt: new Date().toISOString(),
specRuns: {
nodes: [],
},
},
}

return (
<RunStatusDots gql={gql} specFileExtension=".cy.ts" specFileName="spec"/>
)
context('single UNCLAIMED status', () => {
beforeEach(() => {
const runs = fakeRuns(['UNCLAIMED'])

mountWithRuns(runs)
})

it('renders as expected', () => {
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
})
})

cy.findByTestId('external').should('not.exist')
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').should('not.exist')
context('no runs', () => {
beforeEach(() => {
mountWithRuns([])
})

it('renders placeholder without tooltip or link', () => {
cy.findByTestId('external').should('not.exist')
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').should('not.exist')
})
})

context('unknown/unhandled statuses', () => {
beforeEach(() => {
const runs = fakeRuns(fill(['', '', '', ''], 'FAKE_UNKNOWN_STATUS' as any))

mountWithRuns(runs)
})

it('renders as expected', () => {
cy.findByTestId('run-status-dots').trigger('mouseenter')
cy.get('.v-popper__popper--shown').contains('spec.cy.ts')
cy.findAllByTestId('run-status-dot-0').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-1').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-2').should('have.class', 'icon-light-gray-300')
cy.findAllByTestId('run-status-dot-latest').should('not.have.class', 'animate-spin')
})
})
})
6 changes: 4 additions & 2 deletions packages/app/src/specs/RunStatusDots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import ErroredIcon from '~icons/cy/errored-solid_x16.svg'
import FailedIcon from '~icons/cy/failed-solid_x16.svg'
import PassedIcon from '~icons/cy/passed-solid_x16.svg'
import PlaceholderIcon from '~icons/cy/placeholder-solid_x16.svg'
import QueuedIcon from '~icons/cy/queued-solid_x16.svg'
import RunningIcon from '~icons/cy/running-outline_x16.svg'
import SpecRunSummary from './SpecRunSummary.vue'
import { gql } from '@urql/vue'
Expand Down Expand Up @@ -155,9 +156,9 @@ const dotClasses = computed(() => {
case 'FAILED':
return 'icon-light-red-400'
case 'ERRORED':
case 'OVERLIMIT':
case 'TIMEDOUT':
return 'icon-light-orange-400'
case 'UNCLAIMED':
case 'NOTESTS':
return 'icon-light-gray-400'
case 'CANCELLED':
Expand All @@ -183,10 +184,11 @@ const latestDot = computed(() => {
return { icon: PassedIcon, spin: false, status }
case 'RUNNING':
return { icon: RunningIcon, spin: true, status }
case 'UNCLAIMED':
return { icon: QueuedIcon, spin: false, status }
case 'FAILED':
return { icon: FailedIcon, spin: false, status }
case 'ERRORED':
case 'OVERLIMIT':
case 'TIMEDOUT':
return { icon: ErroredIcon, spin: false, status }
case 'NOTESTS':
Expand Down
Loading