-
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
490 changed files
with
13,848 additions
and
4,766 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 |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
|
||
# test helper file that we auto-generate | ||
parse-test/ | ||
isolate*.log | ||
perf.txt | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
|
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,46 @@ | ||
import { Logger } from '@idl/logger'; | ||
|
||
import { Runner } from '../runner.class'; | ||
import { RunNotebookRestart } from './notebook-restart'; | ||
import { RunNotebookStop } from './notebook-stop'; | ||
import { RunTestNotebook } from './run-test-notebook'; | ||
import { SaveAndClearNotebook } from './save-and-clear-output'; | ||
|
||
/* | ||
* Logger to be used for tests related to debugging | ||
*/ | ||
export const NOTEBOOK_TEST_LOGGER = new Logger( | ||
'tests-notebook', | ||
false, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
() => {} | ||
); | ||
|
||
/** | ||
* Test runner for debugging | ||
*/ | ||
export const NOTEBOOK_RUNNER = new Runner(NOTEBOOK_TEST_LOGGER); | ||
|
||
NOTEBOOK_RUNNER.addTest({ | ||
name: 'Run notebook that tests everything', | ||
fn: RunTestNotebook, | ||
critical: true, | ||
}); | ||
|
||
NOTEBOOK_RUNNER.addTest({ | ||
name: 'Save output and reload', | ||
fn: SaveAndClearNotebook, | ||
critical: true, | ||
}); | ||
|
||
NOTEBOOK_RUNNER.addTest({ | ||
name: 'Stop does the right thing', | ||
fn: RunNotebookStop, | ||
critical: true, | ||
}); | ||
|
||
NOTEBOOK_RUNNER.addTest({ | ||
name: 'Reset does the right thing', | ||
fn: RunNotebookRestart, | ||
critical: true, | ||
}); |
13 changes: 13 additions & 0 deletions
13
apps/client-e2e/src/tests/notebooks/helpers/compare-cells.interface.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,13 @@ | ||
type MimeTypes = 'text/html' | 'text/plain' | 'image/png'; | ||
|
||
/** | ||
* Output for cells | ||
*/ | ||
export interface ICompareCells { | ||
/** Cell we are comparing against */ | ||
idx: number; | ||
/** did we succeed */ | ||
success: boolean; | ||
/** Retrieve all of the cell mimetypes */ | ||
mimeTypes: MimeTypes[]; | ||
} |
50 changes: 50 additions & 0 deletions
50
apps/client-e2e/src/tests/notebooks/helpers/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,50 @@ | ||
import expect from 'expect'; | ||
import * as vscode from 'vscode'; | ||
|
||
import { ICompareCells } from './compare-cells.interface'; | ||
|
||
/** | ||
* Compares cells from a notebook against what we expect them to be | ||
*/ | ||
export function CompareCells( | ||
nb: vscode.NotebookDocument, | ||
cellOutput: ICompareCells[] | ||
) { | ||
/** | ||
* get notebook cells | ||
*/ | ||
const cells = nb.getCells(); | ||
|
||
// validate outputs from all known cells | ||
for (let i = 0; i < cellOutput.length; i++) { | ||
/** | ||
* Get expected cell output | ||
*/ | ||
const expected = cellOutput[i]; | ||
|
||
// debug log | ||
console.log(` Comparing known output cell "${expected.idx}"`); | ||
|
||
/** | ||
* get notebook cell | ||
*/ | ||
const nbCell = cells[expected.idx]; | ||
|
||
// make sure it exists | ||
expect(nbCell).not.toBeUndefined(); | ||
|
||
// validate success if we have it | ||
if (nbCell.executionSummary.success !== undefined) { | ||
expect(nbCell.executionSummary.success).toEqual(expected.success); | ||
} | ||
|
||
// get output mime types | ||
let mimes: string[] = []; | ||
for (let j = 0; j < nbCell.outputs.length; j++) { | ||
mimes = mimes.concat(nbCell.outputs[j].items.map((item) => item.mime)); | ||
} | ||
|
||
// validate cell mime types | ||
expect(mimes).toEqual(expected.mimeTypes); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/client-e2e/src/tests/notebooks/helpers/verify-empty.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,35 @@ | ||
import expect from 'expect'; | ||
import * as vscode from 'vscode'; | ||
|
||
/** | ||
* Verifies that a notebook is empty | ||
*/ | ||
export function VerifyEmpty(nb: vscode.NotebookDocument) { | ||
/** | ||
* get notebook cells | ||
*/ | ||
const cells = nb.getCells(); | ||
|
||
// track number of output cells | ||
let nOut = 0; | ||
|
||
// validate outputs from all known cells | ||
for (let i = 0; i < cells.length; i++) { | ||
/** | ||
* get notebook cell | ||
*/ | ||
const nbCell = cells[i]; | ||
|
||
// get output mime types | ||
let mimes: string[] = []; | ||
for (let j = 0; j < nbCell.outputs.length; j++) { | ||
mimes = mimes.concat(nbCell.outputs[j].items.map((item) => item.mime)); | ||
} | ||
|
||
// track total output | ||
nOut += mimes.length; | ||
} | ||
|
||
// validate cell mime types | ||
expect(nOut).toEqual(0); | ||
} |
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,65 @@ | ||
import { GetExtensionPath, IDL_COMMANDS, Sleep } from '@idl/shared'; | ||
import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; | ||
import expect from 'expect'; | ||
import * as vscode from 'vscode'; | ||
|
||
import { RunnerFunction } from '../runner.interface'; | ||
import { CompareCells } from './helpers/compare-cells'; | ||
import { ICompareCells } from './helpers/compare-cells.interface'; | ||
|
||
/** | ||
* Types of outputs from cells that we expect to have | ||
*/ | ||
export const CELL_OUTPUT: ICompareCells[] = [ | ||
{ | ||
idx: 0, | ||
success: false, | ||
mimeTypes: [], | ||
}, | ||
]; | ||
|
||
/** | ||
* Function that verifies that we can do basic debugging of IDL sessions | ||
* and launch a new debugging session. | ||
*/ | ||
export const RunNotebookRestart: RunnerFunction = async (init) => { | ||
/** | ||
* Get the file we are going to open | ||
*/ | ||
const file = GetExtensionPath('idl/test/client-e2e/stop-notebook.idlnb'); | ||
|
||
/** | ||
* Open the notebook | ||
*/ | ||
const nb = await OpenNotebookInVSCode(file); | ||
|
||
// trigger a run to start IDL | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL); | ||
|
||
// make sure launched | ||
expect(init.notebooks.controller.isLaunched()).toBeTruthy(); | ||
|
||
// trigger a run | ||
vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL); | ||
|
||
// short pause | ||
await Sleep(100); | ||
|
||
// stop execution | ||
await vscode.commands.executeCommand(IDL_COMMANDS.NOTEBOOKS.RESET); | ||
|
||
// short pause | ||
await Sleep(100); | ||
|
||
// make sure stopped | ||
expect(init.notebooks.controller.isLaunched()).toBeTruthy(); | ||
|
||
// clear outputs | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_CLEAR_OUTPUTS); | ||
|
||
// compare state | ||
CompareCells(nb, CELL_OUTPUT); | ||
|
||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { GetExtensionPath, IDL_COMMANDS, Sleep } from '@idl/shared'; | ||
import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; | ||
import expect from 'expect'; | ||
import * as vscode from 'vscode'; | ||
|
||
import { RunnerFunction } from '../runner.interface'; | ||
import { CompareCells } from './helpers/compare-cells'; | ||
import { ICompareCells } from './helpers/compare-cells.interface'; | ||
|
||
/** | ||
* Types of outputs from cells that we expect to have | ||
*/ | ||
export const CELL_OUTPUT: ICompareCells[] = [ | ||
{ | ||
idx: 0, | ||
success: false, | ||
mimeTypes: [], | ||
}, | ||
]; | ||
|
||
/** | ||
* Function that verifies that we can do basic debugging of IDL sessions | ||
* and launch a new debugging session. | ||
*/ | ||
export const RunNotebookStop: RunnerFunction = async (init) => { | ||
/** | ||
* Get the file we are going to open | ||
*/ | ||
const file = GetExtensionPath('idl/test/client-e2e/stop-notebook.idlnb'); | ||
|
||
/** | ||
* Open the notebook | ||
*/ | ||
const nb = await OpenNotebookInVSCode(file); | ||
|
||
// trigger a run to start IDL | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL); | ||
|
||
// make sure launched | ||
expect(init.notebooks.controller.isLaunched()).toBeTruthy(); | ||
|
||
// trigger a run | ||
vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL); | ||
|
||
// short pause | ||
await Sleep(100); | ||
|
||
// stop execution | ||
await vscode.commands.executeCommand(IDL_COMMANDS.NOTEBOOKS.STOP); | ||
|
||
// short pause | ||
await Sleep(100); | ||
|
||
// make sure stopped | ||
expect(init.notebooks.controller.isLaunched()).toBeFalsy(); | ||
|
||
// clear outputs | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_CLEAR_OUTPUTS); | ||
|
||
// compare state | ||
CompareCells(nb, CELL_OUTPUT); | ||
|
||
// clear any existing outputs | ||
await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); | ||
}; |
Oops, something went wrong.