Skip to content

Commit

Permalink
Merge branch 'master' into issue364
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanluker authored May 1, 2022
2 parents 7192fb9 + 8b19da3 commit 5c3c19b
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 133 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ See [examples directory](example) on how to setup a project.
## Requirements
- vscode 1.27.0 and up
- macos, linux or windows
- Requires Live Preview extension
- vscode extension id: ms-vscode.live-server
- v0.2.12 or higher

## Extension Settings
See extension setting options in IDE.
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bugs": "https://github.com/ryanluker/vscode-coverage-gutters/issues",
"publisher": "ryanluker",
"engines": {
"vscode": "^1.59.0",
"vscode": "^1.66.0",
"node": "^16.11.0"
},
"categories": [
Expand Down Expand Up @@ -130,7 +130,8 @@
"lcov.info",
"cov.xml",
"coverage.xml",
"jacoco.xml"
"jacoco.xml",
"coverage.cobertura.xml"
],
"description": "coverage file names for the extension to automatically look for"
},
Expand Down Expand Up @@ -264,7 +265,7 @@
"@types/sinon": "10.0.11",
"@types/sinon-chai": "3.2.8",
"@types/uuid": "8.3.4",
"@types/vscode": "1.64.0",
"@types/vscode": "1.66.0",
"@vscode/test-electron": "2.1.2",
"chai": "4.3.6",
"cross-env": "7.0.3",
Expand All @@ -283,5 +284,8 @@
"jacoco-parse": "2.0.1",
"lcov-parse": "1.0.0",
"uuid": "8.3.2"
}
},
"extensionDependencies": [
"ms-vscode.live-server"
]
}
27 changes: 24 additions & 3 deletions src/extension/gutters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { commands, extensions } from "vscode";
import { OutputChannel, window } from "vscode";
import { Coverage } from "../coverage-system/coverage";
import { CoverageService } from "../coverage-system/coverageservice";
import { Config } from "./config";
import { StatusBarToggler } from "./statusbartoggler";
import { PreviewPanel } from "./webview";

export class Gutters {
private coverage: Coverage;
Expand Down Expand Up @@ -38,8 +38,29 @@ export class Gutters {
window.showWarningMessage("Could not show Coverage Report file!");
return;
}
const previewPanel = new PreviewPanel(pickedReport);
await previewPanel.createWebView();

// TODO: Figure out how to convert pickedReport to a workspace relative filename.
// Right now the livePreview.start.internalPreview.atFile is called with "false" as
// the second parameter. This means that the file specified has an absolute path.
// See the Live Preview extension source code:
// https://github.com/microsoft/vscode-livepreview/blob/
// 3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
const livePreview = extensions.getExtension("ms-vscode.live-server");
// is the ext loaded and ready?
if (livePreview?.isActive === false) {
livePreview.activate().then(
function() {
console.log("Extension activated");
commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
},
function() {
console.log("Extension activation failed");
},
);
} else {
commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
}

} catch (error: any) {
this.handleError("previewCoverageReport", error);
}
Expand Down
48 changes: 0 additions & 48 deletions src/extension/webview.ts

This file was deleted.

7 changes: 4 additions & 3 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ suite("Extension Tests", function() {
// is in the root of the node folder and not inside the default /coverage
await vscode.commands.executeCommand("coverage-gutters.previewCoverageReport");
// Look to see if the webview is open and showing preview coverage
await wait(500);
const reportView = vscode.workspace.textDocuments[0];
expect(reportView.languageId).to.equal("html");
await checkCoverage(() => {
const livePreview = vscode.extensions.getExtension("ms-vscode.live-server");
expect(livePreview?.isActive).to.equal(true);
});
});

test("Run display coverage on a test file that has coverages generated remotely @integration", async () => {
Expand Down
60 changes: 0 additions & 60 deletions test/extension/webview.test.ts

This file was deleted.

21 changes: 14 additions & 7 deletions test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import {
downloadAndUnzipVSCode,
resolveCliArgsFromVSCodeExecutablePath,
runTests,
} from "@vscode/test-electron";
import * as cp from "child_process";
import * as path from "path";

import { downloadAndUnzipVSCode, runTests } from "@vscode/test-electron";

async function main() {
try {
const extensionDevelopmentPath = path.resolve(__dirname, "..", "..");
const extensionTestsPath = path.resolve(__dirname, "index");
const vscodeExecutablePath = await downloadAndUnzipVSCode("insiders");

// Add the dependent extension for test coverage preview functionality
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
cp.spawnSync(cli, [...args, "--install-extension", "ms-vscode.live-server"], {
encoding: "utf-8",
stdio: "inherit",
});

await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
"example/example.code-workspace",
"--disable-extensions",
"--disable-telemetry",
],
launchArgs: ["example/example.code-workspace"],
vscodeExecutablePath,
});

Expand Down

0 comments on commit 5c3c19b

Please sign in to comment.