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.
feat(ui): snapshots summary, closes #61
- Loading branch information
Showing
21 changed files
with
572 additions
and
101 deletions.
There are no files selected for viewing
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
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,35 @@ | ||
<script lang="ts" setup> | ||
import { defineProps, PropType } from 'vue' | ||
import type { NexusGenFieldTypes } from '@peeky/server/types' | ||
import BaseTab from '../BaseTab.vue' | ||
const props = defineProps({ | ||
run: { | ||
type: Object as PropType<Pick<NexusGenFieldTypes['Run'], 'snapshotCount' | 'failedSnapshotCount'>>, | ||
required: true, | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<nav class="h-10"> | ||
<BaseTab :to="{ name: 'run-test' }"> | ||
Tests | ||
</BaseTab> | ||
<BaseTab :to="{ name: 'run-snapshot' }"> | ||
<div class="flex items-center space-x-2"> | ||
<span>Snapshots</span> | ||
<div | ||
v-if="run.failedSnapshotCount" | ||
class="text-xs px-1.5 rounded-full leading-tight text-red-200 bg-red-600 mt-0.5" | ||
> | ||
{{ run.failedSnapshotCount }} | ||
</div> | ||
<div | ||
v-else-if="run.snapshotCount" | ||
class="w-2 h-2 bg-primary-500 dark:bg-primary-400 rounded-full" | ||
/> | ||
</div> | ||
</BaseTab> | ||
</nav> | ||
</template> |
File renamed without changes.
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
114 changes: 114 additions & 0 deletions
114
packages/peeky-client/src/features/snapshot/SnapshotSummaryList.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,114 @@ | ||
<script lang="ts" setup>import { NexusGenFieldTypes } from '@peeky/server/types' | ||
import { useQuery } from '@vue/apollo-composable' | ||
import gql from 'graphql-tag' | ||
import { computed } from 'vue' | ||
import { useRoute } from 'vue-router' | ||
import SnapshotItem from './SnapshotItem.vue' | ||
const runFragment = gql`fragment runSnapshotSummary on Run { | ||
id | ||
failedSnapshots { | ||
...runSnapshotSummarySnapshot | ||
} | ||
passedSnapshots { | ||
...runSnapshotSummarySnapshot | ||
} | ||
newSnapshots { | ||
...runSnapshotSummarySnapshot | ||
} | ||
} | ||
fragment runSnapshotSummarySnapshot on Snapshot { | ||
id | ||
title | ||
failed | ||
}` | ||
type Run = Pick<NexusGenFieldTypes['Run'], 'id' | 'failedSnapshots' | 'passedSnapshots' | 'newSnapshots'> | ||
const route = useRoute() | ||
const { result, subscribeToMore } = useQuery<{ | ||
run: Run | ||
}>(() => route.params.runId !== 'last-run' ? gql` | ||
query testFileAllView ($runId: ID!) { | ||
run (id: $runId) { | ||
...runSnapshotSummary | ||
} | ||
} | ||
${runFragment} | ||
` : gql` | ||
query testFileAllViewLastRun { | ||
run: lastRun { | ||
...runSnapshotSummary | ||
} | ||
} | ||
${runFragment} | ||
`, () => ({ | ||
...route.params.runId !== 'last-run' ? { | ||
runId: route.params.runId, | ||
} : {}, | ||
}), { | ||
fetchPolicy: 'cache-and-network', | ||
}) | ||
// Updated | ||
subscribeToMore({ | ||
document: gql` | ||
subscription runUpdated { | ||
runUpdated { | ||
...runSnapshotSummary | ||
} | ||
} | ||
${runFragment}`, | ||
}) | ||
const failedSnapshots = computed(() => result.value?.run.failedSnapshots ?? []) | ||
const newSnapshots = computed(() => result.value?.run.newSnapshots ?? []) | ||
const passedSnapshots = computed(() => result.value?.run.passedSnapshots ?? []) | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="failedSnapshots.length" | ||
class="py-2" | ||
> | ||
<div class="text-red-500 flex items-center justify-center space-x-1 pb-1"> | ||
<span>Failed</span> | ||
<span class="text-xs px-1.5 rounded-full leading-tight border border-current mt-0.5">{{ failedSnapshots.length }}</span> | ||
</div> | ||
<SnapshotItem | ||
v-for="snapshot of failedSnapshots" | ||
:key="snapshot.id" | ||
:snapshot="snapshot" | ||
/> | ||
</div> | ||
<div | ||
v-if="newSnapshots.length" | ||
class="py-2" | ||
> | ||
<div class="text-green-500 flex items-center justify-center space-x-1 pb-1"> | ||
<span>New</span> | ||
<span class="text-xs px-1.5 rounded-full leading-tight border border-current mt-0.5">{{ newSnapshots.length }}</span> | ||
</div> | ||
<SnapshotItem | ||
v-for="snapshot of newSnapshots" | ||
:key="snapshot.id" | ||
:snapshot="snapshot" | ||
/> | ||
</div> | ||
<div | ||
v-if="passedSnapshots.length" | ||
class="py-2" | ||
> | ||
<div class="text-green-500 flex items-center justify-center space-x-1 pb-1"> | ||
<span>Passed</span> | ||
<span class="text-xs px-1.5 rounded-full leading-tight border border-current mt-0.5">{{ passedSnapshots.length }}</span> | ||
</div> | ||
<SnapshotItem | ||
v-for="snapshot of passedSnapshots" | ||
:key="snapshot.id" | ||
:snapshot="snapshot" | ||
/> | ||
</div> | ||
</template> |
Oops, something went wrong.