-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Added E2E for #114. Creating new TST that imports an coded test. Check in E2E if we can edit the coded test with `// vmock` autocompletion. ## Added `vcast_coded_tests_relative_path.test.ts` E2E test. Added `import_coded_tests` spec group.
- Loading branch information
Showing
3 changed files
with
192 additions
and
6 deletions.
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
tests/internal/e2e/test/specs/vcast_coded_tests_relative_path.test.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,183 @@ | ||
// Test/specs/vcast.test.ts | ||
import { | ||
type BottomBarPanel, | ||
type TextEditor, | ||
type Workbench, | ||
type TreeItem, | ||
} from "wdio-vscode-service"; | ||
import { Key } from "webdriverio"; | ||
import { | ||
getViewContent, | ||
findSubprogram, | ||
updateTestID, | ||
expandWorkspaceFolderSectionInExplorer, | ||
getTestHandle, | ||
} from "../test_utils/vcast_utils"; | ||
|
||
describe("vTypeCheck VS Code Extension", () => { | ||
let bottomBar: BottomBarPanel; | ||
let workbench: Workbench; | ||
const TIMEOUT = 20_000; | ||
before(async () => { | ||
workbench = await browser.getWorkbench(); | ||
// Opening bottom bar and problems view before running any tests | ||
bottomBar = workbench.getBottomBar(); | ||
await bottomBar.toggle(true); | ||
process.env.E2E_TEST_ID = "0"; | ||
}); | ||
|
||
it("test 1: should be able to load VS Code", async () => { | ||
await updateTestID(); | ||
expect(await workbench.getTitleBar().getTitle()).toBe( | ||
"[Extension Development Host] vcastTutorial - Visual Studio Code" | ||
); | ||
}); | ||
|
||
it("should activate vcastAdapter", async () => { | ||
await updateTestID(); | ||
|
||
await browser.keys([Key.Control, Key.Shift, "p"]); | ||
// Typing Vector in the quick input box | ||
// This brings up VectorCAST Test Explorer: Configure | ||
// so just need to hit Enter to activate | ||
for (const character of "vector") { | ||
await browser.keys(character); | ||
} | ||
|
||
await browser.keys(Key.Enter); | ||
|
||
const activityBar = workbench.getActivityBar(); | ||
const viewControls = await activityBar.getViewControls(); | ||
for (const viewControl of viewControls) { | ||
console.log(await viewControl.getTitle()); | ||
} | ||
|
||
await bottomBar.toggle(true); | ||
const outputView = await bottomBar.openOutputView(); | ||
|
||
console.log("Waiting for VectorCAST activation"); | ||
await $("aria/VectorCAST Test Pane Initialization"); | ||
console.log("WAITING FOR TESTING"); | ||
await browser.waitUntil( | ||
async () => (await activityBar.getViewControl("Testing")) !== undefined, | ||
{ timeout: TIMEOUT } | ||
); | ||
console.log("WAITING FOR TEST EXPLORER"); | ||
await browser.waitUntil(async () => | ||
(await outputView.getChannelNames()) | ||
.toString() | ||
.includes("VectorCAST Test Explorer") | ||
); | ||
await outputView.selectChannel("VectorCAST Test Explorer"); | ||
console.log("Channel selected"); | ||
console.log("WAITING FOR LANGUAGE SERVER"); | ||
await browser.waitUntil( | ||
async () => | ||
(await outputView.getText()) | ||
.toString() | ||
.includes("Starting the language server"), | ||
{ timeout: TIMEOUT } | ||
); | ||
|
||
const testingView = await activityBar.getViewControl("Testing"); | ||
await testingView?.openView(); | ||
}); | ||
|
||
it("should set default config file", async () => { | ||
await updateTestID(); | ||
|
||
const workbench = await browser.getWorkbench(); | ||
const activityBar = workbench.getActivityBar(); | ||
const explorerView = await activityBar.getViewControl("Explorer"); | ||
await explorerView?.openView(); | ||
|
||
const workspaceFolderSection = | ||
await expandWorkspaceFolderSectionInExplorer("vcastTutorial"); | ||
|
||
const configFile = await workspaceFolderSection.findItem("CCAST_.CFG"); | ||
await configFile.openContextMenu(); | ||
await (await $("aria/Set as VectorCAST Configuration File")).click(); | ||
}); | ||
|
||
it("should enable coded test", async () => { | ||
await updateTestID(); | ||
|
||
const workbench = await browser.getWorkbench(); | ||
const settingsEditor = await workbench.openSettings(); | ||
console.log("Looking for coded tests settings"); | ||
await settingsEditor.findSetting( | ||
"vectorcastTestExplorer.enableCodedTesting" | ||
); | ||
// Only one setting in search results, so the current way of clicking is correct | ||
console.log("Enabling coded tests"); | ||
await (await settingsEditor.checkboxSetting$).click(); | ||
await workbench.getEditorView().closeAllEditors(); | ||
}); | ||
|
||
it("should check for vmock code completion", async () => { | ||
await updateTestID(); | ||
|
||
console.log("Opening Testing View"); | ||
const vcastTestingViewContent = await getViewContent("Testing"); | ||
|
||
let subprogram: TreeItem; | ||
let testHandle: TreeItem; | ||
|
||
// Iterate over sections to find the "moo" subprogram and expand it | ||
for (const section of await vcastTestingViewContent.getSections()) { | ||
subprogram = await findSubprogram("moo", section); | ||
if (subprogram) { | ||
// Expand the subprogram if it's not already expanded | ||
if (!(await subprogram.isExpanded())) await subprogram.expand(); | ||
console.log("Getting test handle"); | ||
|
||
testHandle = await getTestHandle( | ||
subprogram, | ||
"Coded Tests", | ||
"mooTests.ExampleTestCase", | ||
1 | ||
); | ||
|
||
if (testHandle) break; | ||
throw new Error("Test handle not found for mooTests.ExampleTestCase"); | ||
} | ||
} | ||
|
||
expect(testHandle).not.toBe(undefined); | ||
|
||
let contextMenu = await testHandle.openContextMenu(); | ||
await contextMenu.select("VectorCAST"); | ||
|
||
let menuElement = await $("aria/Edit Coded Test"); | ||
await menuElement.click(); | ||
|
||
// Wait until the "tests.cpp" tab is active in the editor view | ||
const editorView = workbench.getEditorView(); | ||
await browser.waitUntil( | ||
async () => | ||
(await (await editorView.getActiveTab()).getTitle()) === "tests.cpp" | ||
); | ||
|
||
// Open the "tests.cpp" file in the editor and trigger code completion | ||
const tab = (await editorView.openEditor("tests.cpp")) as TextEditor; | ||
await browser.keys([Key.Ctrl, Key.Space]); | ||
|
||
const contentAssist = await tab.toggleContentAssist(true); | ||
|
||
// Just do some autocompletion to see if we can edit the Coded Test | ||
await tab.setTextAtLine(14, "// vmock"); | ||
let currentLine = await tab.getLineOfText("// vmock"); | ||
await tab.typeTextAt(currentLine, "// vmock".length + 1, " "); | ||
await tab.save(); | ||
await browser.waitUntil( | ||
async () => (await contentAssist.getItems()).length > 0 | ||
); | ||
|
||
// Validating content assist for '// vmock' | ||
const expectedItems = ["moo", "Prototype-Stubs"]; | ||
|
||
for (const item of expectedItems) { | ||
expect(await contentAssist.hasItem(item)).toBe(true); | ||
} | ||
}); | ||
}); |
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