This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
packages/peeky-client/src/features/run/RunSummaryBar.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<script lang="ts" setup> | ||
import type { NexusGenFieldTypes } from '@peeky/server/types' | ||
import { useQuery, useSubscription } from '@vue/apollo-composable' | ||
import gql from 'graphql-tag' | ||
import { computed } from 'vue' | ||
const runStatsFragment = gql`fragment runStats on Run { | ||
testCount | ||
inProgressTestCount: testCount (status: in_progress) | ||
successTestCount: testCount (status: success) | ||
errorTestCount: testCount (status: error) | ||
skippedTestCount: testCount (status: skipped) | ||
todoTestCount: testCount (status: todo) | ||
}` | ||
const props = defineProps<{ | ||
run: NexusGenFieldTypes['Run'] | ||
}>() | ||
const { result, refetch } = useQuery<{ | ||
run: { | ||
id: string | ||
testCount: number | ||
successTestCount: number | ||
errorTestCount: number | ||
skippedTestCount: number | ||
todoTestCount: number | ||
} | ||
}>(gql`query runStats ($runId: ID!) { | ||
run (id: $runId) { | ||
id | ||
...runStats | ||
} | ||
} | ||
${runStatsFragment}`, () => ({ | ||
runId: props.run.id, | ||
})) | ||
const runStats = computed(() => result.value?.run) | ||
useSubscription(gql`subscription testUpdatedInRunSummary ($runId: ID!) { | ||
runStatsUpdated (runId: $runId) { | ||
id | ||
...runStats | ||
} | ||
} | ||
${runStatsFragment}`, () => ({ | ||
runId: props.run.id, | ||
})) | ||
const kinds = [ | ||
{ field: 'errorTestCount', label: 'Error', css: 'bg-red-400 dark:bg-red-600' }, | ||
{ field: 'successTestCount', label: 'Success', css: 'bg-green-500' }, | ||
{ field: 'todoTestCount', label: 'Todo', css: 'bg-yellow-400 dark:bg-yellow-600' }, | ||
{ field: 'skippedTestCount', label: 'Skipped', css: 'bg-gray-200 dark:bg-gray-800' }, | ||
] | ||
</script> | ||
|
||
<template> | ||
<div class="flex-none flex items-center space-x-2 h-10"> | ||
<template v-if="runStats"> | ||
<div class="w-full h-full relative mx-3 flex items-center"> | ||
<div class="w-full h-2 rounded-full overflow-hidden flex bg-gray-100 dark:bg-gray-900"> | ||
<div | ||
v-for="kind of kinds" | ||
:key="kind.field" | ||
class="h-full" | ||
:class="kind.css" | ||
:style="{ | ||
width: (runStats[kind.field] / runStats.testCount * 100) + '%', | ||
}" | ||
/> | ||
</div> | ||
|
||
<div class="absolute top-0 left-0 w-full h-full flex"> | ||
<VTooltip | ||
v-for="kind of kinds" | ||
:key="kind.field" | ||
class="h-full" | ||
:style="{ | ||
width: (runStats[kind.field] / runStats.testCount * 100) + '%', | ||
}" | ||
> | ||
<div class="w-full h-full" /> | ||
|
||
<template #popper> | ||
<div class="flex items-center space-x-4"> | ||
<div | ||
class="w-6 h-2 rounded-full" | ||
:class="kind.css" | ||
/> | ||
<div> | ||
<b>{{ kind.label }} {{ runStats[kind.field] }}</b> / {{ runStats.testCount }} test{{ runStats.testCount > 1 ? 's' : '' }} | ||
</div> | ||
</div> | ||
</template> | ||
</VTooltip> | ||
</div> | ||
</div> | ||
</template> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { withFilter } from 'apollo-server-express' | ||
import { arg, extendType, idArg, nonNull } from 'nexus' | ||
import { Context } from 'vm' | ||
import { getRunId, runs } from './Run.js' | ||
import { tests } from './Test.js' | ||
|
||
export const StatsExtendRun = extendType({ | ||
type: 'Run', | ||
definition (t) { | ||
t.nonNull.int('testCount', { | ||
args: { | ||
status: arg({ | ||
type: 'Status', | ||
}), | ||
}, | ||
resolve: (run, { status }) => tests.filter(t => t.runId === run.id && (!status || t.status === status)).length, | ||
}) | ||
}, | ||
}) | ||
|
||
export const RunStatsUpdated = 'run-stats-updated' | ||
|
||
export interface RunStatsUpdatedPayload { | ||
runId: string | ||
} | ||
|
||
export const StatsExtendSubpscription = extendType({ | ||
type: 'Subscription', | ||
definition (t) { | ||
t.field('runStatsUpdated', { | ||
type: 'Run', | ||
args: { | ||
runId: nonNull(idArg()), | ||
}, | ||
subscribe: withFilter( | ||
(_, args, ctx) => ctx.pubsub.asyncIterator(RunStatsUpdated), | ||
(payload: RunStatsUpdatedPayload, args) => payload.runId === getRunId(args.runId), | ||
), | ||
resolve: (payload: RunStatsUpdatedPayload) => runs.find(r => r.id === getRunId(payload.runId)), | ||
}) | ||
}, | ||
}) | ||
|
||
export function publishRunStatsUpdated (ctx: Context, runId: string) { | ||
ctx.pubsub.publish(RunStatsUpdated, { runId } as RunStatsUpdatedPayload) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters