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
44 changed files
with
1,095 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Peeky snapshots v1.0 | ||
|
||
exports[`vue create vue app 1`] = ` | ||
<div data-v-app> | ||
<div> | ||
hello | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`vue create vue app demo 1`] = ` | ||
"Hello" | ||
`; | ||
|
||
exports[`vue create vue app demo 2`] = ` | ||
"Meow" | ||
`; |
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,10 @@ | ||
// Peeky snapshots v1.0 | ||
|
||
exports[`vue + peeky demo mount component 1`] = ` | ||
<pre> | ||
4 x 2 = 9 | ||
</pre> | ||
<button> | ||
More | ||
</button> | ||
`; |
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,73 @@ | ||
<script lang="ts" setup> | ||
import * as monaco from 'monaco-editor' | ||
import { onMounted, ref, watch } from 'vue' | ||
import { onResize } from '../../util/resize' | ||
import '../../util/monaco' | ||
import { useSettings } from '../settings' | ||
const props = defineProps({ | ||
code: { | ||
type: String, | ||
required: true, | ||
}, | ||
}) | ||
const el = ref<HTMLDivElement>() | ||
let editor: monaco.editor.IEditor | ||
onMounted(() => { | ||
if (!el.value) return | ||
editor = monaco.editor.create(el.value, { | ||
readOnly: true, | ||
lineNumbers: 'off', | ||
scrollBeyondLastLine: false, | ||
}) | ||
updateEditorModel() | ||
updateEditorTheme() | ||
}) | ||
/* Model */ | ||
watch(() => [props.code], () => { | ||
updateEditorModel() | ||
}) | ||
function updateEditorModel () { | ||
if (editor) { | ||
editor.setModel(monaco.editor.createModel(props.code, props.code.trim().startsWith('<') ? 'html' : 'javascript')) | ||
} | ||
} | ||
/* Theme */ | ||
const { settings } = useSettings() | ||
watch(() => settings.value?.darkMode, () => { | ||
updateEditorTheme() | ||
}) | ||
function updateEditorTheme () { | ||
if (!editor) return | ||
editor.updateOptions({ | ||
// @ts-ignore | ||
theme: settings.value?.darkMode ? 'peeky-dark' : 'peeky-light', | ||
}) | ||
} | ||
/* Resize */ | ||
onResize(el, () => { | ||
if (editor) { | ||
editor.layout() | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col"> | ||
<div | ||
ref="el" | ||
class="flex-1" | ||
/> | ||
</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
33 changes: 33 additions & 0 deletions
33
packages/peeky-client/src/features/snapshot/SnapshotItem.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,33 @@ | ||
<script lang="ts" setup> | ||
import StatusIcon from '../StatusIcon.vue' | ||
const props = defineProps({ | ||
snapshot: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<router-link | ||
:to="{ | ||
query: { | ||
...$route.query, | ||
snapshotId: snapshot.id, | ||
}, | ||
}" | ||
class="px-3 flex items-center hover:bg-gray-50 dark:hover:bg-gray-900 space-x-2 h-8" | ||
:class="{ | ||
'active-colors': $route.query.snapshotId === snapshot.id, | ||
}" | ||
> | ||
<StatusIcon | ||
:status="snapshot.newContent && !snapshot.updated ? 'error' : 'success'" | ||
class="w-5 h-5" | ||
/> | ||
<span class="flex-1 truncate py-1"> | ||
{{ snapshot.title }} | ||
</span> | ||
</router-link> | ||
</template> |
117 changes: 117 additions & 0 deletions
117
packages/peeky-client/src/features/snapshot/SnapshotView.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,117 @@ | ||
<script lang="ts" setup> | ||
import { useMutation } from '@vue/apollo-composable' | ||
import gql from 'graphql-tag' | ||
import { ChevronLeftIcon, ChevronRightIcon, SaveIcon } from '@zhuowenli/vue-feather-icons' | ||
import BaseButton from '../BaseButton.vue' | ||
import CodeEditor from '../editor/CodeEditor.vue' | ||
import DiffEditor from '../editor/DiffEditor.vue' | ||
const props = defineProps({ | ||
snapshot: { | ||
type: Object, | ||
required: true, | ||
}, | ||
test: { | ||
type: Object, | ||
required: true, | ||
}, | ||
suite: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}) | ||
const { mutate: openInEditor } = useMutation(gql` | ||
mutation openInEditor ($id: ID!, $line: Int!, $col: Int!) { | ||
openTestFileInEditor (id: $id, line: $line, col: $col) | ||
} | ||
`) | ||
const { mutate: updateSnapshot } = useMutation(gql` | ||
mutation updateSnapshot ($id: ID!) { | ||
updateSnapshot (input: { id: $id }) { | ||
id | ||
updated | ||
} | ||
} | ||
`, { | ||
update: (cache, { data: { updateSnapshot: snapshot } }) => { | ||
const select = { | ||
fragment: gql`fragment updateSnapshotCacheTest on Test { | ||
id | ||
failedSnapshotCount | ||
}`, | ||
id: `Test:${props.test.id}`, | ||
} | ||
const data: any = cache.readFragment(select) | ||
cache.writeFragment({ | ||
...select, | ||
data: { | ||
...data, | ||
failedSnapshotCount: data.failedSnapshotCount - 1, | ||
}, | ||
}) | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col divide-y divide-gray-100 dark:divide-gray-800 overflow-hidden"> | ||
<div class="flex items-center space-x-2 px-4 h-10"> | ||
<button | ||
v-if="snapshot.newContent && !snapshot.updated" | ||
class="text-red-500 hover:text-red-400 hover:bg-red-500/10 rounded cursor-pointer px-2 py-1" | ||
@click="openInEditor({ | ||
id: suite.runTestFile.testFile.id, | ||
line: snapshot.line, | ||
col: snapshot.col, | ||
})" | ||
> | ||
Mismatch at <span class="font-mono text-sm">{{ suite?.runTestFile.testFile.relativePath }}:{{ snapshot.line }}:{{ snapshot.col }}</span> | ||
</button> | ||
|
||
<div class="flex-1" /> | ||
|
||
<BaseButton | ||
v-if="snapshot.newContent && !snapshot.updated && $route.params.runId === 'last-run'" | ||
class="px-2 h-8" | ||
@click="updateSnapshot({ id: snapshot.id })" | ||
> | ||
<SaveIcon class="w-4 h-4 mr-1" /> | ||
<span>Update snapshot</span> | ||
</BaseButton> | ||
|
||
<BaseButton | ||
color="gray" | ||
flat | ||
class="p-2" | ||
@click="$emit('previous')" | ||
> | ||
<ChevronLeftIcon class="w-4 h-4" /> | ||
</BaseButton> | ||
|
||
<BaseButton | ||
color="gray" | ||
flat | ||
class="p-2" | ||
@click="$emit('next')" | ||
> | ||
<ChevronRightIcon class="w-4 h-4" /> | ||
</BaseButton> | ||
</div> | ||
|
||
<DiffEditor | ||
v-if="snapshot.newContent && !snapshot.updated" | ||
:actual="snapshot.newContent" | ||
:expected="snapshot.content" | ||
class="flex-1" | ||
/> | ||
<CodeEditor | ||
v-else | ||
:code="snapshot.content" | ||
class="flex-1" | ||
/> | ||
</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
Oops, something went wrong.