Skip to content

Commit 0f8c72d

Browse files
committed
show fail message in ui
Signed-off-by: shmck <[email protected]>
1 parent d7f6949 commit 0f8c72d

File tree

9 files changed

+22
-14
lines changed

9 files changed

+22
-14
lines changed

Diff for: src/editor/commands.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as TT from 'typings/tutorial'
33
import * as vscode from 'vscode'
44
import createTestRunner from '../services/testRunner'
55
import { setupActions } from '../actions/setupActions'
6-
import createWebView from '../webview'
6+
import createWebView from '../services/webview'
77
import logger from '../services/logger'
88

99
export const COMMANDS = {
@@ -62,9 +62,9 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
6262
// send test pass message back to client
6363
webview.send({ type: 'TEST_PASS', payload: { position } })
6464
},
65-
onFail: (position: T.Position, message: string) => {
65+
onFail: (position: T.Position, failSummary: T.TestFail): void => {
6666
// send test fail message back to client with failure message
67-
webview.send({ type: 'TEST_FAIL', payload: { position, message } })
67+
webview.send({ type: 'TEST_FAIL', payload: { position, fail: failSummary } })
6868
},
6969
onError: (position: T.Position) => {
7070
// TODO: send test error message back to client

Diff for: src/services/testRunner/formatOutput.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ParserOutput, Fail } from './parser'
44
// export const formatSuccessOutput = (tap: ParserOutput): string => {}
55

66
export const formatFailOutput = (tap: ParserOutput): string => {
7-
let output = `FAILED TESTS\n`
7+
let output = `FAILED TEST LOG\n`
88
tap.failed.forEach((fail: Fail) => {
99
const details = fail.details ? `\n${fail.details}\n` : ''
1010
const logs = fail.logs ? `\n${fail.logs.join('\n')}\n` : ''

Diff for: src/services/testRunner/index.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { formatFailOutput } from './formatOutput'
1010

1111
interface Callbacks {
1212
onSuccess(position: T.Position): void
13-
onFail(position: T.Position, message: string): void
13+
onFail(position: T.Position, failSummary: T.TestFail): void
1414
onRun(position: T.Position): void
1515
onError(position: T.Position): void
1616
}
@@ -56,8 +56,12 @@ const createTestRunner = (config: TT.TutorialTestRunnerConfig, callbacks: Callba
5656
if (stderr) {
5757
// FAIL also trigger stderr
5858
if (stdout && stdout.length && !tap.ok) {
59-
const firstFailMessage = tap.failed[0].message
60-
callbacks.onFail(position, firstFailMessage)
59+
const firstFail = tap.failed[0]
60+
const failSummary = {
61+
title: firstFail.message || 'Test Failed',
62+
description: firstFail.details || 'Unknown error',
63+
}
64+
callbacks.onFail(position, failSummary)
6165
const output = formatFailOutput(tap)
6266
displayOutput({ channel: failChannelName, text: output, show: true })
6367
return

Diff for: src/services/testRunner/output.ts

-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ interface DisplayOutput {
1818
export const displayOutput = (params: DisplayOutput) => {
1919
const channel = getOutputChannel(params.channel)
2020
channel.clear()
21-
channel.show(params.show || false)
2221
channel.append(params.text)
2322
}
2423

2524
export const clearOutput = (channelName: string) => {
2625
const channel = getOutputChannel(channelName)
27-
channel.show(false)
2826
channel.clear()
2927
channel.hide()
3028
}

Diff for: src/webview/index.ts renamed to src/services/webview/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path'
22
import { Action } from 'typings'
33
import * as vscode from 'vscode'
4-
import Channel from '../channel'
4+
import Channel from '../../channel'
55
import render from './render'
66

77
interface ReactWebViewProps {

Diff for: src/webview/render.ts renamed to src/services/webview/render.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { JSDOM } from 'jsdom'
22
import * as path from 'path'
33
import * as vscode from 'vscode'
4-
import onError from '../services/sentry/onError'
4+
import onError from '../sentry/onError'
55

66
const getNonce = (): string => {
77
let text = ''

Diff for: typings/index.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface TestStatus {
4242
type: 'success' | 'warning' | 'error' | 'loading'
4343
title: string
4444
content?: string
45+
timeout?: number
4546
}
4647

4748
export interface MachineContext {
@@ -116,3 +117,8 @@ export interface ProcessEvent {
116117
description: string
117118
status: 'RUNNING' | 'SUCCESS' | 'FAIL' | 'ERROR'
118119
}
120+
121+
export type TestFail = {
122+
title: string
123+
description: string
124+
}

Diff for: web-app/src/components/ProcessMessages/TestMessage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { css, jsx } from '@emotion/core'
55

66
const durations = {
77
success: 1000,
8-
warning: 4500,
8+
warning: 20000,
99
error: 4500,
1010
loading: 300000,
1111
}

Diff for: web-app/src/services/state/actions/testNotify.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const testActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
2020
testFail: assign({
2121
testStatus: (context, event) => ({
2222
type: 'warning',
23-
title: 'Fail!',
24-
content: event.payload.message,
23+
title: event.payload.fail.title,
24+
content: event.payload.fail.description,
2525
}),
2626
}),
2727
// @ts-ignore

0 commit comments

Comments
 (0)