Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add option to login at beginning of smoke tests

Gerhard Schlagerc83ae9a79f5e
diff --git a/test/smoke_test.js b/test/smoke_test.js
index 81464046b40..833e99fbfab 100644
--- a/test/smoke_test.js
+++ b/test/smoke_test.js
@@ -87,6 +87,40 @@ const path = require("path");
});
}
+ const login = async function() {
+ await exec("open login modal", () => {
+ return page.click(".login-button");
+ });
+
+ await exec("login modal is open", () => {
+ return page.waitForSelector(".login-modal", { visible: true });
+ });
+
+ await exec("type in credentials & log in", () => {
+ let promise = page.type(
+ "#login-account-name",
+ process.env.DISCOURSE_USERNAME || "smoke_user"
+ );
+
+ promise = promise.then(() => {
+ return page.type(
+ "#login-account-password",
+ process.env.DISCOURSE_PASSWORD || "P4ssw0rd"
+ );
+ });
+
+ promise = promise.then(() => {
+ return page.click(".login-modal .btn-primary");
+ });
+
+ return promise;
+ });
+
+ await exec("is logged in", () => {
+ return page.waitForSelector(".current-user", { visible: true });
+ });
+ };
+
await exec("go to site", () => {
return page.goto(url);
});
@@ -95,6 +129,10 @@ const path = require("path");
return page.waitForSelector("header .login-button", { visible: true });
});
+ if (process.env.LOGIN_AT_BEGINNING) {
+ await login();
+ }
+
await exec("go to latest page", () => {
return page.goto(path.join(url, "latest"));
});
@@ -128,42 +166,20 @@ const path = require("path");
});
if (!process.env.READONLY_TESTS) {
- await exec("open login modal", () => {
- return page.click(".login-button");
- });
-
- await exec("login modal is open", () => {
- return page.waitForSelector(".login-modal", { visible: true });
- });
-
- await exec("type in credentials & log in", () => {
- let promise = page.type(
- "#login-account-name",
- process.env.DISCOURSE_USERNAME || "smoke_user"
- );
+ if (!process.env.LOGIN_AT_BEGINNING) {
+ await login();
+ }
- promise = promise.then(() => {
- return page.type(
- "#login-account-password",
- process.env.DISCOURSE_PASSWORD || "P4ssw0rd"
- );
- });
+ await exec("go home", () => {
+ let promise = page.waitForSelector("#site-logo, #site-text-logo", { visible: true });
promise = promise.then(() => {
- return page.click(".login-modal .btn-primary");
+ return page.click("#site-logo, #site-text-logo");
});
return promise;
});
- await exec("is logged in", () => {
- return page.waitForSelector(".current-user", { visible: true });
- });
-
- await exec("go home", () => {
- return page.click("#site-logo, #site-text-logo");
- });
-
await exec("it shows a topic list", () => {
return page.waitForSelector(".topic-list", { visible: true });
});