Skip to content

Commit 8c17fd5

Browse files
committed
spectron: Adds Back Button test
Signed-off-by: tarun8718 <[email protected]>
1 parent 391c515 commit 8c17fd5

File tree

7 files changed

+41
-4
lines changed

7 files changed

+41
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint-js": "xo",
3232
"prettier-non-js": "prettier --check --ignore-path=.prettierignore.non-js --loglevel=warn .",
3333
"test": "tsc --noEmit && npm run lint-html && npm run lint-css && npm run lint-js && npm run prettier-non-js",
34-
"test-e2e": "tsc && tape 'tests/*.js'",
34+
"test-e2e": "tsc && tape 'tests/Spectron/*.js'",
3535
"pack": "tsc && electron-builder --dir",
3636
"dist": "tsc && electron-builder",
3737
"mas": "tsc && electron-builder --mac mas"
File renamed without changes.
File renamed without changes.

tests/setup.js renamed to tests/Spectron/setup.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function createApp() {
2424
path: path.join(
2525
__dirname,
2626
"..",
27+
"..",
2728
"node_modules",
2829
".bin",
2930
"electron" + (process.platform === "win32" ? ".cmd" : ""),
@@ -38,9 +39,9 @@ function createApp() {
3839
// Reads app package.json and updates the productName to config.TEST_APP_PRODUCT_NAME
3940
// We do this so that the app integration doesn't doesn't share the same appDataDir as the dev application
4041
function generateTestAppPackageJson() {
41-
const packageJson = require(path.join(__dirname, "../package.json"));
42+
const packageJson = require(path.join(__dirname, "..", "..", "package.json"));
4243
packageJson.productName = config.TEST_APP_PRODUCT_NAME;
43-
packageJson.main = "../app/main";
44+
packageJson.main = "../../app/main";
4445

4546
const testPackageJsonPath = path.join(__dirname, "package.json");
4647
fs.writeFileSync(
@@ -104,5 +105,5 @@ function getAppDataDir() {
104105
function resetTestDataDir() {
105106
const appDataDir = getAppDataDir();
106107
rimraf.sync(appDataDir);
107-
rimraf.sync(path.join(__dirname, "package.json"));
108+
rimraf.sync(path.join(__dirname, "../package.json"));
108109
}
File renamed without changes.

tests/Spectron/test-back-button.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"use strict";
2+
const test = require("tape");
3+
4+
const setup = require("./setup");
5+
6+
test("back button", async (t) => {
7+
t.timeoutAfter(50e3);
8+
setup.resetTestDataDir();
9+
const app = setup.createApp();
10+
try {
11+
await setup.waitForLoad(app, t);
12+
await app.client.windowByIndex(1); // Focus on webview
13+
await (await app.client.$(".setting-input-value")).setValue(
14+
"chat.zulip.org",
15+
);
16+
await (await app.client.$("#connect")).click();
17+
await setup.wait(5000);
18+
await app.client.windowByIndex(0); // Switch focus back to main win
19+
await app.client.windowByIndex(1); // Switch focus back to org webview
20+
await (await app.client.$("#id_username")).waitForExist();
21+
await (await app.client.$("#id_username")).setValue(
22+
23+
);
24+
await (await app.client.$("#id_password")).setValue("testzulipdesktop");
25+
await (await app.client.$(".full-width")).click();
26+
await setup.wait(5000);
27+
await (await app.client.$(".private_messages_header")).click();
28+
await setup.wait(5000);
29+
await app.client.windowByIndex(0);
30+
await (await app.client.$("#back-action")).click();
31+
await setup.wait(5000);
32+
await setup.endTest(app, t);
33+
} catch (error) {
34+
await setup.endTest(app, t, error || "error");
35+
}
36+
});
File renamed without changes.

0 commit comments

Comments
 (0)