Skip to content

Feature/control test commit #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Channel implements Channel {
console.log('RECEIVED:', actionType)
switch (actionType) {
case 'TEST_RUN':
vscode.commands.executeCommand('coderoad.run_test')

vscode.commands.executeCommand('coderoad.run_test', action.payload)
return
case 'TUTORIAL_CONFIG':
tutorialConfig(action.payload)
Expand Down
4 changes: 3 additions & 1 deletion src/actions/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ interface Props {
onSuccess(): void
onFail(): void
onRun(): void
onError(): void
}

async function runTest({onSuccess, onFail, onRun}: Props): Promise<void> {
async function runTest({onSuccess, onFail, onRun, onError}: Props): Promise<void> {
// increment process id
const processId = ++currentId

Expand Down Expand Up @@ -99,6 +100,7 @@ async function runTest({onSuccess, onFail, onRun}: Props): Promise<void> {

if (!stdout) {
console.error('SOMETHING WENT WRONG WITH A PASSING TEST')
onError()
}
// test runner failed
channel = getOutputChannel(outputChannelName)
Expand Down
12 changes: 8 additions & 4 deletions src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,26 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {

webview.createOrShow(column)
},
[COMMANDS.RUN_TEST]: () => {
[COMMANDS.RUN_TEST]: ({stepId}: {stepId: string}) => {
console.log('run test webview', Object.keys(webview))
runTest({
onSuccess: () => {
console.log('COMMAND TEST_PASS')
webview.send({type: 'TEST_PASS'})
webview.send({type: 'TEST_PASS', payload: {stepId}})
vscode.window.showInformationMessage('PASS')
},
onFail: () => {
console.log('COMMAND TEST_FAIL')
webview.send({type: 'TEST_FAIL'})
webview.send({type: 'TEST_FAIL', payload: {stepId}})
vscode.window.showWarningMessage('FAIL')
},
onError: () => {
console.log('COMMAND TEST_ERROR')
webview.send({type: 'TEST_ERROR', payload: [stepId]})
},
onRun: () => {
console.log('COMMAND TEST_RUN')
webview.send({type: 'TEST_RUN'})
webview.send({type: 'TEST_RUN', payload: {stepId}})
}
})
},
Expand Down
9 changes: 6 additions & 3 deletions web-app/src/services/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Channel {
this.machineSend = send
}
public receive = (event: ReceivedEvent) => {
console.log('CLIENT RECEIVE')
const action = event.data

// @ts-ignore // ignore browser events from plugins
Expand All @@ -41,16 +40,20 @@ class Channel {
case 'TEST_PASS':
// { type: 'TEST_PASS', payload: { stepId: string }}
this.machineSend(action)
console.log('test passed')
return
case 'TEST_FAIL':
this.machineSend(action)
return
case 'TEST_RUN':
console.log('TEST_RUN')
this.machineSend(action)
return
case 'TEST_ERROR':
console.log('TEST_ERROR')
this.machineSend(action)
return
case 'ACTIONS_LOADED':
console.log('ACTIONS_LOADED')
// TODO: use this for verifying completion of stepActions
return
default:
if (action.type) {
Expand Down
5 changes: 1 addition & 4 deletions web-app/src/services/state/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,10 @@ export default {
// @ts-ignore
updateStepProgress: assign({
progress: (context: CR.MachineContext, event: CR.MachineEvent): CR.Progress => {

// update progress by tracking completed
const currentProgress: CR.Progress = context.progress

// TODO: should use event id, to verify not multiple successes jumping one
// const stepId = event.payload.stepId
const {stepId} = context.position
const {stepId} = event.payload

currentProgress.steps[stepId] = true

Expand Down
1 change: 1 addition & 0 deletions web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
actions: ['updateStepProgress']
},
TEST_FAIL: 'TestFail',
TEST_ERROR: 'Normal'
},
},
TestPass: {
Expand Down