Skip to content

Commit

Permalink
Add vscode e2e testing (#6714)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Jan 30, 2024
1 parent 02e711e commit 8128ad3
Show file tree
Hide file tree
Showing 7 changed files with 10,354 additions and 6,984 deletions.
4 changes: 3 additions & 1 deletion firebase-vscode/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
dist/
*.scss.d.ts
resources/dist
.vscode-test
.vscode-test
.wdio-vscode-service
logs
17,248 changes: 10,268 additions & 6,980 deletions firebase-vscode/package-lock.json

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion firebase-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
"test-compile": "npm run copyfiles && webpack --config src/test/webpack.test.js",
"pretest": "npm run test-compile && npm run lint && tsc -p src/test/tsconfig.test.json",
"lint": "eslint src --ext ts",
"test": "node ./dist/test/firebase-vscode/src/test/runTest.js"
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "node ./dist/test/firebase-vscode/src/test/runTest.js",
"test:e2e": "TS_NODE_PROJECT=\"./src/test/tsconfig.test.json\" wdio run ./src/test/wdio.conf.ts"
},
"dependencies": {
"@preact/signals-react": "^1.3.6",
Expand All @@ -118,6 +120,10 @@
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@vscode/test-electron": "^2.2.0",
"@wdio/cli": "^8.27.1",
"@wdio/local-runner": "^8.27.0",
"@wdio/mocha-framework": "^8.27.0",
"@wdio/spec-reporter": "^8.27.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"eslint": "^8.28.0",
Expand All @@ -132,6 +138,7 @@
"string-replace-loader": "^3.1.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.3",
"wdio-vscode-service": "^5.2.2",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-merge": "^5.8.0"
Expand Down
2 changes: 1 addition & 1 deletion firebase-vscode/src/core/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const currentProject = computed<FirebaseProjectMetadata | undefined>(
}

const wantProjectId =
currentProjectId.value || firebaseRC.value.projects["default"];
currentProjectId.value || firebaseRC.value?.projects["default"];
return userScopedProjects.value.find((p) => p.projectId === wantProjectId);
}
);
Expand Down
26 changes: 26 additions & 0 deletions firebase-vscode/src/test/integration/sidebar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { browser, expect } from "@wdio/globals";
import { Workbench } from "wdio-vscode-service";

function openFirebaseSidebar() {
return $("a.codicon-mono-firebase").click();
}

async function switchToFirebaseSidebarFrame(workbench: Workbench) {
const sidebarView = await workbench.getWebviewByTitle("");
await browser.switchToFrame(sidebarView.elem);

const firebaseView = await $('iframe[title="Firebase"]');
await firebaseView.waitForDisplayed();
await browser.switchToFrame(firebaseView);

return firebaseView;
}

it("Supports opening empty projects", async function () {
const workbench = await browser.getWorkbench();

await openFirebaseSidebar();
await switchToFirebaseSidebarFrame(workbench);

await expect($("vscode-button=Try a Quickstart!")).toBeDisplayed();
});
3 changes: 2 additions & 1 deletion firebase-vscode/src/test/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"jsx": "react",
/* Cannot be enabled until we enable it in the root tsconfig.json */
"strict": false,
"skipLibCheck": true
"skipLibCheck": true,
"types": ["node", "expect-webdriverio", "wdio-vscode-service", "mocha"]
},
"exclude": ["**/*.test.ts"],
"include": ["../**/*", "../../common/**/*"]
Expand Down
46 changes: 46 additions & 0 deletions firebase-vscode/src/test/wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Options } from "@wdio/types";
import * as path from "path";

export const config: Options.Testrunner = {
runner: "local",
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
project: "./tsconfig.test.json",
transpileOnly: true,
},
},

specs: ["./integration/**/*.ts"],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],

// Redirect noisy chromedriver and browser logs to ./logs
outputDir: "./logs",

capabilities: [
{
browserName: "vscode",
browserVersion: "stable", // also possible: "insiders" or a specific version e.g. "1.80.0"
"wdio:vscodeOptions": {
// points to directory where extension package.json is located
extensionPath: path.join(__dirname, "..", ".."),
// optional VS Code settings
userSettings: {
"editor.fontSize": 14,
},
},
},
],

services: ["vscode"],
framework: "mocha",
reporters: ["spec"],

mochaOpts: {
ui: "bdd",
timeout: 60000,
},
};

0 comments on commit 8128ad3

Please sign in to comment.