diff --git a/server/api/app/resolver.ts b/server/api/app/resolver.ts index ee847d2..bb4abe4 100644 --- a/server/api/app/resolver.ts +++ b/server/api/app/resolver.ts @@ -3,6 +3,7 @@ import * as launch from "launch-editor"; import { App } from "./app"; import FileWatcher, { WatcherEvents } from "../../services/file-watcher"; import { pubsub } from "../../event-emitter"; +import { dirname, basename } from "path"; @Resolver(App) export default class AppResolver { @@ -45,6 +46,18 @@ export default class AppResolver { return ""; } + @Mutation(returns => String) + openSnapInEditor(@Arg("path") path: string) { + var dir = dirname(path) + var file = basename(path); + + var snap = dir + '/__snapshots__/' + file + '.snap' + console.log("opening the snapshot:", snap); + this.openInEditor(snap); + + return ""; + } + @Mutation(returns => String) openFailure(@Arg("failure") failure: string) { // The following regex matches the first line of the form: \w at () diff --git a/ui/test-file/summary/index.tsx b/ui/test-file/summary/index.tsx index 04a46d1..163cc18 100644 --- a/ui/test-file/summary/index.tsx +++ b/ui/test-file/summary/index.tsx @@ -11,10 +11,12 @@ import { CheckCircle, Frown, ZapOff, - Circle + Circle, + Eye } from "react-feather"; import Button from "../../components/button"; import OPEN_IN_EDITOR from "./open-in-editor.gql"; +import OPEN_SNAP_IN_EDITOR from "./open-snap-in-editor.gql"; import { Tooltip } from "react-tippy"; import { useMutation } from "react-apollo-hooks"; @@ -138,6 +140,12 @@ export default function FileSummary({ } }); + const openSnapshotInEditor = useMutation(OPEN_SNAP_IN_EDITOR, { + variables: { + path + } + }); + return ( {(isRunning || isLoadingResult) && } @@ -204,6 +212,15 @@ export default function FileSummary({ Update Snapshot + +