-
Notifications
You must be signed in to change notification settings - Fork 22
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
98 changed files
with
3,303 additions
and
737 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
68 changes: 68 additions & 0 deletions
68
apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts
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,68 @@ | ||
import { NOTEBOOK_FOLDER } from '@idl/notebooks/shared'; | ||
import { Sleep } from '@idl/shared'; | ||
import { IDLNotebookController } from '@idl/vscode/notebooks'; | ||
import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; | ||
import expect from 'expect'; | ||
import { existsSync, rmSync } from 'fs'; | ||
import * as vscode from 'vscode'; | ||
|
||
import { CompareCellOutputs } from './compare-cells'; | ||
import { ICompareCellOutputs } from './compare-cells.interface'; | ||
|
||
/** | ||
* helper function to: | ||
* | ||
* 1. Open notebook | ||
* 2. Clear existing outputs | ||
* 3. Run notebook | ||
* 4. Compare expected outputs to actual outputs | ||
* 5. Clear outputs | ||
* 6. Close | ||
*/ | ||
export async function RunNotebookAndCompareCells( | ||
file: string, | ||
cells: ICompareCellOutputs[], | ||
controller: IDLNotebookController, | ||
clear = true | ||
) { | ||
// nuke .idl folder if it exists | ||
if (existsSync(NOTEBOOK_FOLDER)) { | ||
rmSync(NOTEBOOK_FOLDER, { recursive: true, force: true }); | ||
} | ||
|
||
/** | ||
* Open the notebook | ||
*/ | ||
const nb = await OpenNotebookInVSCode(file); | ||
|
||
// clear any existing outputs | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_CLEAR_OUTPUTS); | ||
|
||
// save to disk | ||
await nb.save(); | ||
|
||
// run all cells | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL); | ||
|
||
// make sure launched | ||
expect(controller.isStarted()).toBeTruthy(); | ||
|
||
// short pause | ||
await Sleep(100); | ||
|
||
// compare cells | ||
CompareCellOutputs(nb, cells); | ||
|
||
if (clear) { | ||
// clear outputs | ||
await vscode.commands.executeCommand( | ||
VSCODE_COMMANDS.NOTEBOOK_CLEAR_OUTPUTS | ||
); | ||
} | ||
|
||
// save again | ||
await nb.save(); | ||
|
||
// clear any existing outputs | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); | ||
} |
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
61 changes: 61 additions & 0 deletions
61
apps/client-e2e/src/tests/notebooks/run-envi-message-listener-test-notebook.ts
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,61 @@ | ||
import { GetExtensionPath } from '@idl/shared'; | ||
|
||
import { RunnerFunction } from '../runner.interface'; | ||
import { ICompareCellOutputs } from './helpers/compare-cells.interface'; | ||
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells'; | ||
|
||
/** | ||
* Types of outputs from cells that we expect to have | ||
*/ | ||
export const CELL_OUTPUT: ICompareCellOutputs[] = [ | ||
{ | ||
idx: 0, | ||
success: true, | ||
mimeTypes: [], | ||
}, | ||
{ | ||
idx: 1, | ||
success: true, | ||
mimeTypes: [], | ||
}, | ||
{ | ||
idx: 2, | ||
success: true, | ||
mimeTypes: ['text/plain'], | ||
}, | ||
{ | ||
idx: 3, | ||
success: true, | ||
mimeTypes: [], | ||
}, | ||
{ | ||
idx: 4, | ||
success: true, | ||
mimeTypes: [], | ||
}, | ||
{ | ||
idx: 5, | ||
success: true, | ||
mimeTypes: [], | ||
}, | ||
{ | ||
idx: 6, | ||
success: true, | ||
mimeTypes: ['text/plain'], | ||
}, | ||
]; | ||
|
||
/** | ||
* Function that runs basic tests for ENVI message listeners | ||
*/ | ||
export const RunENVIMessageListenerTestNotebook: RunnerFunction = async ( | ||
init | ||
) => { | ||
await RunNotebookAndCompareCells( | ||
GetExtensionPath( | ||
'idl/test/client-e2e/notebooks/envi-message-listener.idlnb' | ||
), | ||
CELL_OUTPUT, | ||
init.notebooks.controller | ||
); | ||
}; |
Oops, something went wrong.