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 cloud data backend #25316

Merged
merged 65 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d16fe12
Basic relevant run field in place
warrensplayer Dec 21, 2022
2318faa
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Dec 23, 2022
6035b86
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Dec 23, 2022
03be489
Introduce useRelevantRun composable
warrensplayer Dec 23, 2022
9c0123a
Remove test yarn script
warrensplayer Dec 23, 2022
b91fd55
Remove other test yarn script
warrensplayer Dec 23, 2022
3e9f2c1
Merge from feature branch and updates for new form of Relevant Runs m…
warrensplayer Dec 29, 2022
30f5e4d
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Dec 30, 2022
48a563e
Renaming fields for relevantRuns field and adding composable for retu…
warrensplayer Dec 30, 2022
0e23ecb
Update IATR release date
warrensplayer Dec 30, 2022
b9bcb11
Revert projectId
warrensplayer Dec 30, 2022
1b8ef17
Updating subscription to use same logic as query
warrensplayer Dec 30, 2022
05540c4
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Jan 3, 2023
26fc728
Adding support for "next" run
warrensplayer Jan 3, 2023
3835679
Adding GitDataSource tests and fixing subscription
warrensplayer Jan 3, 2023
ff16fe1
Add descriptions to GQL object
warrensplayer Jan 3, 2023
fd84e72
Adding support for saving the current run
warrensplayer Jan 4, 2023
e98530f
Support scenario of only finding a RUNNING CloudRun
warrensplayer Jan 5, 2023
f071945
Fixing type error
warrensplayer Jan 5, 2023
255532c
Fixing tests
warrensplayer Jan 5, 2023
e669b3e
Do not try to fetch git log if git has errored
warrensplayer Jan 5, 2023
1f9566b
Updating relevant runs logic
warrensplayer Jan 5, 2023
476aeae
Adding comments
warrensplayer Jan 5, 2023
33f6a89
Additional run logic and comment
warrensplayer Jan 5, 2023
d12723a
Update to work with latest schema from cloud
warrensplayer Jan 5, 2023
71954b6
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Jan 5, 2023
30dc649
Fixing jank in sidebar badge for Debug
warrensplayer Jan 5, 2023
ff20051
Removed fields from moveToNextRelevantRun mutation
warrensplayer Jan 6, 2023
b9e936b
Add schema update for mutation
warrensplayer Jan 6, 2023
2dbbaba
Adding relevant runs polling
warrensplayer Jan 9, 2023
7913f2c
Fixing sidebar tests
warrensplayer Jan 9, 2023
ef76589
Moved loading component
warrensplayer Jan 9, 2023
60d2b25
Fix type error
warrensplayer Jan 9, 2023
f040a60
data source tests
warrensplayer Jan 9, 2023
a696d80
Adding commits ahead calculation
warrensplayer Jan 9, 2023
84ac46c
Fix type error
warrensplayer Jan 10, 2023
f838137
Reverting DataEmitter changes and adding test
warrensplayer Jan 10, 2023
a2b119e
Support for remote polling intervals
warrensplayer Jan 10, 2023
19240eb
Fix type error with default props
warrensplayer Jan 10, 2023
c03faf8
Moved polling functions to separate file
warrensplayer Jan 11, 2023
ad2c326
Adding polling for spec counts
warrensplayer Jan 12, 2023
2e130b6
Update DebugPendingRunSplash to use subscription
warrensplayer Jan 12, 2023
6e34637
Moving component to use subscription and adding registerSubscriptionH…
warrensplayer Jan 13, 2023
03c51a7
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Jan 13, 2023
bb736bf
Fixing types and exports
warrensplayer Jan 13, 2023
1fb9ee9
Tests and typescript
warrensplayer Jan 13, 2023
8d6f5d6
Fix polling for new run, test and type fixes
warrensplayer Jan 13, 2023
291a82a
Debug statements and removing unused gql field
warrensplayer Jan 13, 2023
23e16ce
Fix for badge flickering through states on load
warrensplayer Jan 13, 2023
ea29436
Fixing scenario for initial running build
warrensplayer Jan 13, 2023
e9f2cb6
Handle being offline plus fixing release date
warrensplayer Jan 13, 2023
c7700c0
Minor changes for useTestsForDebug
warrensplayer Jan 13, 2023
bd5c9ac
Adding padding below debug specs list
warrensplayer Jan 16, 2023
5639934
Updating text for testing type in spec header
warrensplayer Jan 16, 2023
142da67
Fixing to use clearTimeout
warrensplayer Jan 17, 2023
09c311e
PR comments
warrensplayer Jan 17, 2023
2fb26a3
Reloading git hashes after branch change
warrensplayer Jan 17, 2023
61f9f82
Removing unused code and updating debug statements
warrensplayer Jan 17, 2023
94a9bc4
Fixing error handling
warrensplayer Jan 17, 2023
3611b8e
Fix type check
warrensplayer Jan 17, 2023
d6461e5
Fixing test
warrensplayer Jan 17, 2023
8786a12
Fix data-context tests
warrensplayer Jan 17, 2023
1ba7d7b
Merge branch 'feature/IATR-M0' into stokes/IATR-M0-cloud-run-data
warrensplayer Jan 17, 2023
a694fca
Make sure empty state shows when isHidden is true
warrensplayer Jan 17, 2023
a97a39d
Removing whitespace
warrensplayer Jan 17, 2023
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
22 changes: 22 additions & 0 deletions packages/app/src/composables/useRelevantRun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { gql, useSubscription } from '@urql/vue'
import { Debug_RelevantRuns_SubscriptionDocument } from '@packages/app/src/generated/graphql'
import { computed } from 'vue'

gql`
subscription Debug_RelevantRuns_Subscription {
relevantRuns {
current
next
commitsAhead
}
}

`

export function useRelevantRun () {
const subscriptionResponse = useSubscription({ query: Debug_RelevantRuns_SubscriptionDocument })

return computed(() => {
return subscriptionResponse.data.value?.relevantRuns
})
}
25 changes: 25 additions & 0 deletions packages/app/src/composables/useTestsForDebug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { gql, useQuery } from '@urql/vue'
import { Debug_TestsForDebugDocument } from '@packages/app/src/generated/graphql'

gql`
query Debug_TestsForDebug($specTitle: String!) {
currentProject {
id
testsForReviewBySpec(specTitle: $specTitle)
}
}
`

export function useTestsForDebug () {
const variables = { specTitle: '' }

const query = useQuery({ query: Debug_TestsForDebugDocument, variables, pause: true })

return (specTitle: string) => {
variables.specTitle = specTitle

const results = query.executeQuery()

return results.data.value
}
}
85 changes: 82 additions & 3 deletions packages/app/src/debug/DebugContainer.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@ import { useLoginConnectStore } from '@packages/frontend-shared/src/store/login-
import { specsList } from './utils/DebugMapping'
import { CloudRunStubs } from '@packages/graphql/test/stubCloudTypes'

const DebugSpecVariableTypes = {
hasNextRun: 'Boolean',
runNumber: 'Int',
nextRunNumber: 'Int',
}

describe('<DebugContainer />', () => {
describe('offline', () => {
it('shows offline message if offline', () => {
cy.mount(() => <DebugContainer online={false}/>)

cy.contains('You have no internet connection').should('be.visible')
})
})

describe('empty states', () => {
const validateEmptyState = (expectedMessages: string[]) => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
render: (gqlVal) => <DebugContainer gql={gqlVal} />,
})

Expand Down Expand Up @@ -38,6 +58,12 @@ describe('<DebugContainer />', () => {
loginConnectStore.setUserFlag('isLoggedIn', true)
loginConnectStore.setProjectFlag('isProjectConnected', true)
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
render: (gqlVal) => <DebugContainer gql={gqlVal} />,
})

Expand All @@ -51,6 +77,12 @@ describe('<DebugContainer />', () => {
loginConnectStore.setUserFlag('isLoggedIn', true)
loginConnectStore.setProjectFlag('isProjectConnected', true)
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
render: (gqlVal) => <DebugContainer gql={gqlVal} showError={true} />,
})

Expand All @@ -69,6 +101,12 @@ describe('<DebugContainer />', () => {

function mountTestRun (runName: string) {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber
Expand Down Expand Up @@ -181,6 +219,12 @@ describe('<DebugContainer />', () => {

it('render first pending run', () => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber
Expand All @@ -204,6 +248,12 @@ describe('<DebugContainer />', () => {

it('renders specs and tests when completed run available', () => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber
Expand All @@ -223,6 +273,12 @@ describe('<DebugContainer />', () => {

it('renders failed test limit when exceeded', () => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber
Expand All @@ -242,13 +298,24 @@ describe('<DebugContainer />', () => {
context('newer relevant run available', () => {
it('displays newer run with progress when running', () => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: -1,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber

result.currentProject.cloudProject.runByNumber = {
...CloudRunStubs.running,
...CloudRunStubs.failingWithTests,
} as typeof test

const nextRun = result.currentProject.cloudProject.nextRun
const nextCompleted = CloudRunStubs.running as typeof nextRun

result.currentProject.cloudProject.nextRun = nextCompleted
}
},
render: (gqlVal) => <DebugContainer gql={gqlVal} />,
Expand All @@ -262,12 +329,24 @@ describe('<DebugContainer />', () => {

it('displays newer run with link when complete', () => {
cy.mountFragment(DebugSpecsFragmentDoc, {
variableTypes: DebugSpecVariableTypes,
variables: {
hasNextRun: false,
runNumber: 1,
nextRunNumber: 2,
},
onResult: (result) => {
if (result.currentProject?.cloudProject?.__typename === 'CloudProject') {
const test = result.currentProject.cloudProject.runByNumber
const other = CloudRunStubs.failingWithTests as typeof test

result.currentProject.cloudProject.runByNumber = other
result.currentProject.cloudProject.runByNumber = {
...CloudRunStubs.failingWithTests,
} as typeof test

const nextRun = result.currentProject.cloudProject.nextRun
const nextCompleted = CloudRunStubs.failingWithTests as typeof nextRun

result.currentProject.cloudProject.nextRun = nextCompleted
}
},
render: (gqlVal) => <DebugContainer gql={gqlVal} />,
Expand Down
50 changes: 35 additions & 15 deletions packages/app/src/debug/DebugContainer.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<template>
<div class="h-full">
<NoInternetConnection v-if="!online">
{{ t('launchpadErrors.noInternet.connectProject') }}
</NoInternetConnection>
<DebugLoading v-else-if="isLoading" />
<DebugError
v-if="showError"
v-else-if="showError"
/>
<div
v-else-if="loginConnectStore.user.isLoggedIn && loginConnectStore.project.isProjectConnected && run?.status"
class="flex flex-col h-full"
>
<DebugPageHeader
:gql="run"
:commits-ahead="0"
:commits-ahead="props.commitsAhead"
/>
<DebugNewRelevantRunBar
v-if="newerRelevantRun"
Expand All @@ -19,11 +23,10 @@
<DebugPendingRunSplash
v-if="isFirstPendingRun"
class="mt-12"
:spec-statuses="specStatuses"
/>
<template v-else>
<DebugPageDetails
v-if="shouldDisplayDetails(run.status)"
v-if="shouldDisplayDetails(run.status, run.isHidden)"
:status="run.status"
:specs="run.specs"
:cancellation="{ cancelledAt: run.cancelledAt, cancelledBy: run.cancelledBy }"
Expand Down Expand Up @@ -62,6 +65,8 @@ import { gql } from '@urql/vue'
import { computed } from 'vue'
import type { CloudRunStatus, DebugSpecsFragment, TestingTypeEnum } from '../generated/graphql'
import { useLoginConnectStore } from '@packages/frontend-shared/src/store/login-connect-store'
import NoInternetConnection from '@packages/frontend-shared/src/components/NoInternetConnection.vue'
import DebugLoading from '../debug/empty/DebugLoading.vue'
import DebugPageHeader from './DebugPageHeader.vue'
import DebugPendingRunSplash from './DebugPendingRunSplash.vue'
import DebugSpecList from './DebugSpecList.vue'
Expand All @@ -75,6 +80,9 @@ import DebugNewRelevantRunBar from './DebugNewRelevantRunBar.vue'
import { specsList } from './utils/DebugMapping'
import type { CloudRunHidingReason } from './DebugOverLimit.vue'
import dayjs from 'dayjs'
import { useI18n } from '@cy/i18n'

const { t } = useI18n()

gql`
fragment DebugLocalSpecs on Spec {
Expand All @@ -92,7 +100,7 @@ fragment DebugSpecs on Query {
__typename
... on CloudProject {
id
runByNumber(runNumber: 1) {
runByNumber(runNumber: $runNumber) {
...DebugPageHeader
cancelledBy {
id
Expand Down Expand Up @@ -134,7 +142,9 @@ fragment DebugSpecs on Query {
...DebugSpecListGroups
}
createdAt
...DebugPendingRunSplash
}
nextRun: runByNumber(runNumber: $nextRunNumber) @include(if: $hasNextRun) {
id
...DebugNewRelevantRunBar
}
}
Expand All @@ -148,20 +158,33 @@ fragment DebugSpecs on Query {
}
`

const props = defineProps<{
const props = withDefaults(defineProps<{
gql?: DebugSpecsFragment
// This prop is just to stub the error state for now
showError?: boolean
}>()
isLoading?: boolean
commitsAhead?: number
online?: boolean
}>(),
{
gql: undefined,
isLoading: false,
commitsAhead: 0,
online: true,
})

const loginConnectStore = useLoginConnectStore()

const run = computed(() => {
return props.gql?.currentProject?.cloudProject?.__typename === 'CloudProject' ? props.gql.currentProject.cloudProject.runByNumber : null
})

function shouldDisplayDetails (status: CloudRunStatus) {
return !['RUNNING', 'FAILED'].includes(status)
const nextRun = computed(() => {
return props.gql?.currentProject?.cloudProject?.__typename === 'CloudProject' ? props.gql.currentProject.cloudProject.nextRun : null
})

function shouldDisplayDetails (status: CloudRunStatus, isHidden: boolean) {
return !['RUNNING', 'FAILED'].includes(status) || isHidden
}

function shouldDisplaySpecsList (status: CloudRunStatus) {
Expand Down Expand Up @@ -189,12 +212,9 @@ const debugSpecsArray = computed(() => {
return []
})

const specStatuses = computed(() => run.value?.specs.map((spec) => spec.status || 'UNCLAIMED') || [])

// TODO GH#24440 Re-map to use relevant run data point (currently stubbed with current run)
const newerRelevantRun = computed(() => run.value)
const newerRelevantRun = computed(() => nextRun.value)

const isFirstPendingRun = computed(() => run.value && run.value.runNumber === 1 && run.value.status === 'RUNNING')
const isFirstPendingRun = computed(() => run.value && run.value.status === 'RUNNING')

const reasonsRunIsHidden = computed(() => (run.value?.reasonsRunIsHidden || []) as CloudRunHidingReason[])

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/debug/DebugFailedTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>
<template
v-for="{text, type}, index in failedTestData.mappedTitleParts"
:key="`${titlePart}-${index}`"
:key="`${text}-${index}`"
:data-cy="`titleParts-${index}`"
>
<IconChevronRightSmall
Expand Down
Loading