Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint-js": "xo",
"prettier-non-js": "prettier --check --ignore-path=.prettierignore.non-js --loglevel=warn .",
"test": "tsc --noEmit && npm run lint-html && npm run lint-css && npm run lint-js && npm run prettier-non-js",
"test-e2e": "tsc && tape 'tests/*.js'",
"test-e2e": "tsc && tape 'tests/spectron/*.js'",
"pack": "tsc && electron-builder --dir",
"dist": "tsc && electron-builder",
"mas": "tsc && electron-builder --mac mas"
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js → tests/spectron/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
const test = require("tape");

const setup = require("./setup");
const setup = require("../spectron_lib/common");

test("app runs", async (t) => {
t.timeoutAfter(10e3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
const test = require("tape");

const setup = require("./setup");
const setup = require("../spectron_lib/common");

test("add-organization", async (t) => {
t.timeoutAfter(50e3);
Expand Down
36 changes: 36 additions & 0 deletions tests/spectron/test-back-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";
const test = require("tape");

const setup = require("../spectron_lib/common");

test("back button", async (t) => {
t.timeoutAfter(50e3);
setup.resetTestDataDir();
const app = setup.createApp();
try {
await setup.waitForLoad(app, t);
await app.client.windowByIndex(1); // Focus on webview
await (await app.client.$(".setting-input-value")).setValue(
"chat.zulip.org",
);
await (await app.client.$("#connect")).click();
await setup.wait(5000);
await app.client.windowByIndex(0); // Switch focus back to main win
await app.client.windowByIndex(1); // Switch focus back to org webview
await (await app.client.$("#id_username")).waitForExist();
await (await app.client.$("#id_username")).setValue(
"testzulipdesktop@gmail.com",
);
await (await app.client.$("#id_password")).setValue("testzulipdesktop");
await (await app.client.$(".full-width")).click();
await setup.wait(5000);
await (await app.client.$(".private_messages_header")).click();
await setup.wait(5000);
await app.client.windowByIndex(0);
await (await app.client.$("#back-action")).click();
await setup.wait(5000);
await setup.endTest(app, t);
} catch (error) {
await setup.endTest(app, t, error || "error");
}
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
const test = require("tape");

const setup = require("./setup");
const setup = require("../spectron_lib/common");

// Create new org link should open in the default browser [WIP]

Expand Down
19 changes: 19 additions & 0 deletions tests/spectron/test-reload-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
const test = require("tape");

const setup = require("../spectron_lib/common");

test("Reload", async (t) => {
t.timeoutAfter(50e3);
setup.resetTestDataDir();
const app = setup.createApp();
try {
await setup.waitForLoad(app, t);
await app.client.windowByIndex(0);
await (await app.client.$("#reload-action")).click();
await setup.wait(5000);
await setup.endTest(app, t);
} catch (error) {
await setup.endTest(app, t, error || "error");
}
});
60 changes: 60 additions & 0 deletions tests/spectron/test-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"use strict";
const test = require("tape");

const setup = require("../spectron_lib/common");

test("Settings", async (t) => {
t.timeoutAfter(50e3);
setup.resetTestDataDir();
const app = setup.createApp();
try {
await setup.waitForLoad(app, t);
await app.client.windowByIndex(0);
await (await app.client.$("#settings-action")).click();
await app.client.windowByIndex(1);
await (await app.client.$("#tray-option")).waitForExist();
await setup.wait(1000);
await (
await await (await app.client.$("#tray-option")).$(".setting-control")
).click();
await setup.wait(1000);
await (
await await (await app.client.$("#tray-option")).$(".setting-control")
).click();
await setup.wait(1000);
if (process.platform !== "darwin") {
await (
await await (await app.client.$("#menubar-option")).$(
".setting-control",
)
).click();
await setup.wait(1000);
await (
await await (await app.client.$("#menubar-option")).$(
".setting-control",
)
).click();
await setup.wait(1000);
}

await (
await await (await app.client.$("#sidebar-option")).$(".setting-control")
).click();
await setup.wait(1000);
await (
await await (await app.client.$("#sidebar-option")).$(".setting-control")
).click();
await setup.wait(1000);
await (
await await (await app.client.$("#badge-option")).$(".setting-control")
).click();
await setup.wait(1000);
await (
await await (await app.client.$("#badge-option")).$(".setting-control")
).click();
await setup.wait(1000);
await setup.endTest(app, t);
} catch (error) {
await setup.endTest(app, t, error || "error");
}
});
7 changes: 4 additions & 3 deletions tests/setup.js → tests/spectron_lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function createApp() {
path: path.join(
__dirname,
"..",
"..",
"node_modules",
".bin",
"electron" + (process.platform === "win32" ? ".cmd" : ""),
Expand All @@ -38,9 +39,9 @@ function createApp() {
// Reads app package.json and updates the productName to config.TEST_APP_PRODUCT_NAME
// We do this so that the app integration doesn't doesn't share the same appDataDir as the dev application
function generateTestAppPackageJson() {
const packageJson = require(path.join(__dirname, "../package.json"));
const packageJson = require(path.join(__dirname, "..", "..", "package.json"));
packageJson.productName = config.TEST_APP_PRODUCT_NAME;
packageJson.main = "../app/main";
packageJson.main = "../../app/main";

const testPackageJsonPath = path.join(__dirname, "package.json");
fs.writeFileSync(
Expand Down Expand Up @@ -108,5 +109,5 @@ function getAppDataDir() {
function resetTestDataDir() {
const appDataDir = getAppDataDir();
rimraf.sync(appDataDir);
rimraf.sync(path.join(__dirname, "package.json"));
rimraf.sync(path.join(__dirname, "../package.json"));
}
File renamed without changes.