new version
This commit is contained in:
78
tests/lib/PromiseElement.js
Normal file
78
tests/lib/PromiseElement.js
Normal file
@@ -0,0 +1,78 @@
|
||||
let PromiseElementList = null;
|
||||
|
||||
class PromiseElement {
|
||||
|
||||
constructor(promiseResolvingToElement) {
|
||||
this._internalPromise = promiseResolvingToElement;
|
||||
}
|
||||
|
||||
$(selector){
|
||||
return new PromiseElement(this.getPromise().then(elem => elem.$(selector)));
|
||||
}
|
||||
|
||||
$$(selector){
|
||||
return new PromiseElementList(this.getPromise().then(elem => elem.$$(selector)));
|
||||
}
|
||||
|
||||
async getPromise(){
|
||||
return await this._internalPromise;
|
||||
}
|
||||
|
||||
async isDisplayed(){
|
||||
let elem = await this.getPromise();
|
||||
return elem.isDisplayed();
|
||||
}
|
||||
|
||||
async isExisting(){
|
||||
return (await this.getPromise()).isExisting();
|
||||
}
|
||||
|
||||
async isDisplayedInViewport(){
|
||||
return (await this.getPromise()).isDisplayedInViewport();
|
||||
}
|
||||
|
||||
async click(){
|
||||
return (await this.getPromise()).click();
|
||||
}
|
||||
|
||||
async getText(){
|
||||
return (await this.getPromise()).getText();
|
||||
}
|
||||
|
||||
async getAttribute(attr){
|
||||
return (await this.getPromise()).getAttribute(attr);
|
||||
}
|
||||
|
||||
async setValue(value){
|
||||
return (await this.getPromise()).setValue(value);
|
||||
}
|
||||
|
||||
async getTagName(){
|
||||
return (await this.getPromise()).getTagName();
|
||||
}
|
||||
|
||||
async isTag(tag){
|
||||
return (await this.getTagName() === tag);
|
||||
}
|
||||
|
||||
async isSelected(){
|
||||
return (await this.getPromise()).isSelected();
|
||||
}
|
||||
|
||||
async selectByAttribute(attribute, value){
|
||||
return (await this.getPromise()).selectByAttribute(attribute, value);
|
||||
}
|
||||
|
||||
async getValue(){
|
||||
return (await this.getPromise()).getValue();
|
||||
}
|
||||
|
||||
pause(miliseconds){
|
||||
return new PromiseElement(this.getPromise().then(async res => {
|
||||
await browser.pause(miliseconds);
|
||||
return res;
|
||||
}));
|
||||
}
|
||||
}
|
||||
module.exports = PromiseElement;
|
||||
PromiseElementList = require("./PromiseElementList");
|
||||
61
tests/lib/PromiseElementList.js
Normal file
61
tests/lib/PromiseElementList.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const PromiseElement = require("./PromiseElement");
|
||||
|
||||
class PromiseElementList extends PromiseElement {
|
||||
async getLength() {
|
||||
return (await this.getPromise()).length;
|
||||
}
|
||||
|
||||
get(index) {
|
||||
return new PromiseElement(this.getPromise().then(res => res[index]));
|
||||
}
|
||||
|
||||
filter(filterFunc) {
|
||||
return new PromiseElementList(this.getPromise().then(async res => {
|
||||
let results = [];
|
||||
res.forEach(elem => {
|
||||
results.push(new Promise(res => {
|
||||
res(filterFunc(new PromiseElement(elem)));
|
||||
}).catch((e) => {
|
||||
console.error(e);
|
||||
return false
|
||||
}));
|
||||
});
|
||||
results = await Promise.all(results);
|
||||
let filteredRes = [];
|
||||
|
||||
results.forEach((result, i) => {
|
||||
if (result) {
|
||||
filteredRes.push(res[i]);
|
||||
}
|
||||
});
|
||||
return filteredRes;
|
||||
}));
|
||||
}
|
||||
|
||||
async forEach(callback, simultaneously) {
|
||||
const length = await this.getLength();
|
||||
let promises = []
|
||||
for (let i = 0; i < length; i++) {
|
||||
const promise = callback(await this.get(i));
|
||||
if (simultaneously !== false){
|
||||
await promise;
|
||||
}
|
||||
else {
|
||||
promises.push(promise);
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
async click() {
|
||||
return this.forEach(e => e.click());
|
||||
}
|
||||
|
||||
filterOne(filterFunc) {
|
||||
return this.filter(filterFunc).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PromiseElementList;
|
||||
20
tests/lib/PromiseSelector.js
Normal file
20
tests/lib/PromiseSelector.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const PromiseElement = require("./PromiseElement");
|
||||
const PromiseElementList = require("./PromiseElementList");
|
||||
|
||||
function find(selector) {
|
||||
return new PromiseElement($(selector));
|
||||
}
|
||||
|
||||
function findCustom(strategy, selector) {
|
||||
return new PromiseElement(custom$(strategy, selector));
|
||||
}
|
||||
|
||||
function findMultiple(selector) {
|
||||
return new PromiseElementList($$(selector, 200));
|
||||
}
|
||||
|
||||
function findMultipleCustom(strategy, selector) {
|
||||
return new PromiseElementList(custom$$(strategy, selector));
|
||||
}
|
||||
|
||||
module.exports = {one: find, multiple: findMultiple, oneCustom: findCustom, multipleCustom: findMultipleCustom};
|
||||
241
tests/lib/functions.js
Normal file
241
tests/lib/functions.js
Normal file
@@ -0,0 +1,241 @@
|
||||
const find = require("../lib/PromiseSelector");
|
||||
const $ = find.one;
|
||||
const fs = require("fs");
|
||||
|
||||
async function login(email, password) {
|
||||
await browser.url(await getBaseUrl() + "?s=login");
|
||||
|
||||
await browser.waitUntil(async () => {
|
||||
let element = $("#main-content");
|
||||
return await element.isDisplayed()
|
||||
});
|
||||
await acceptCookies();
|
||||
|
||||
await browser.pause(1000);
|
||||
await $("input[name=email]").setValue(email);
|
||||
await $("input[name=password]").setValue(password);
|
||||
await $("button=Login").click();
|
||||
await browser.pause(3000);
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await $(".footer .icon.home").click();
|
||||
await $("span=Logout").click();
|
||||
}
|
||||
|
||||
async function pause(delay) {
|
||||
await browser.pause(delay * browser.config.delayFactor);
|
||||
}
|
||||
|
||||
async function queryDatabase(query) {
|
||||
|
||||
let mysql = browser.config.mysqlConnection;
|
||||
return new Promise(resolve => {
|
||||
mysql.query(query, function (err, result) {
|
||||
if (!err) {
|
||||
resolve(result);
|
||||
} else {
|
||||
console.error(err);
|
||||
resolve(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function setCurrentDate(date) {
|
||||
|
||||
if (!(date instanceof Date)) {
|
||||
date = new Date(2019, 5, 26, 14, 30, 42);
|
||||
}
|
||||
|
||||
const time = date.getTime();
|
||||
await browser.execute((time) => {
|
||||
const OldDate = window["Date"];
|
||||
|
||||
class Date extends OldDate {
|
||||
constructor(...args) {
|
||||
if (arguments.length === 0) {
|
||||
super(time);
|
||||
} else {
|
||||
super(...arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window["Date"] = Date;
|
||||
}, time);
|
||||
}
|
||||
|
||||
async function setFormValues(values, useSelector) {
|
||||
if (useSelector === undefined) {
|
||||
useSelector = false;
|
||||
}
|
||||
|
||||
let promise = Promise.resolve();
|
||||
Object.keys(values).forEach(selector => {
|
||||
promise = promise.then(async () => {
|
||||
let elem;
|
||||
if (useSelector) {
|
||||
elem = $(selector)
|
||||
} else {
|
||||
elem = $("[name=" + selector + "]");
|
||||
}
|
||||
|
||||
if (await elem.isTag("select")) {
|
||||
await elem.selectByAttribute("value", values[selector]);
|
||||
} else if (await elem.getAttribute("type") === "checkbox" || await elem.getAttribute("type") === "radio") {
|
||||
if (!await elem.isSelected()) {
|
||||
return elem.click();
|
||||
}
|
||||
} else {
|
||||
return elem.setValue(values[selector]);
|
||||
}
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function acceptCookies() {
|
||||
if (!browser.config.isMobile) {
|
||||
try {
|
||||
await $("#accept-all").click();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyFormValues(values, useSelector) {
|
||||
if (useSelector === undefined) {
|
||||
useSelector = false;
|
||||
}
|
||||
|
||||
let promise = Promise.resolve();
|
||||
Object.keys(values).forEach(selector => {
|
||||
promise = promise.then(async () => {
|
||||
if (useSelector) {
|
||||
expect(await $(selector).getValue()).toEqual(values[selector]);
|
||||
} else {
|
||||
expect(await $("[name=" + selector + "]").getValue()).toEqual(values[selector]);
|
||||
}
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function addCustomChildSelector() {
|
||||
await browser.addLocatorStategy("selectParent", (parentSelector, childSelector) => {
|
||||
let children = document.querySelectorAll(childSelector);
|
||||
let parents = [];
|
||||
children.forEach(child => {
|
||||
let parent = child.closest(parentSelector);
|
||||
if (parent) {
|
||||
parents.push(parent);
|
||||
}
|
||||
});
|
||||
return parents;
|
||||
});
|
||||
}
|
||||
|
||||
async function getBaseUrl() {
|
||||
if (browser.config.baseUrl.trim() !== "") {
|
||||
return browser.config.baseUrl;
|
||||
} else {
|
||||
return browser.getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
async function acceptAlert() {
|
||||
if (browser.config.hasAlertDialogs !== false) {
|
||||
try {
|
||||
await pause(1500);
|
||||
await browser.acceptAlert();
|
||||
await pause(500);
|
||||
// await browser.acceptAlert();
|
||||
// await pause(500);
|
||||
} catch (e) {
|
||||
if (e.message !== "An attempt was made to operate on a modal dialog when one was not open." && !e.message.startsWith("no such alert")) {
|
||||
expect(e.message).toEqual("error message");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function compareFiles(originalPath, expectedPath) {
|
||||
let filePromises = [
|
||||
new Promise((res, rej) => fs.readFile(originalPath, (err, data) => err ? rej(err) : res(data))),
|
||||
new Promise((res, rej) => fs.readFile(expectedPath, (err, data) => err ? rej(err) : res(data)))
|
||||
];
|
||||
|
||||
let fileData = await Promise.all(filePromises);
|
||||
expect(fileData[0]).toEqual(fileData[1]);
|
||||
}
|
||||
|
||||
async function deactivateTranslationLogging() {
|
||||
await browser.execute(() => {
|
||||
window["shouldConsoleMissingTranslation"] = false;
|
||||
});
|
||||
}
|
||||
|
||||
async function logErrors() {
|
||||
await browser.execute(() => {
|
||||
window["loggedErrors"] = [];
|
||||
window.addEventListener("error", event => {
|
||||
window["loggedErrors"].push(event.message);
|
||||
}, true);
|
||||
window.onunhandledrejection = (e) => {
|
||||
window["loggedErrors"].push(e.reason);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function getLoggedErrors() {
|
||||
return await browser.execute(() => {
|
||||
return window["loggedErrors"];
|
||||
});
|
||||
}
|
||||
|
||||
async function asyncExecute(func, ...args){
|
||||
// console.log(func+"");
|
||||
|
||||
let index = await browser.execute((funcString, args) => {
|
||||
let func = eval(funcString);
|
||||
let res = func(...args);
|
||||
if (!window["testValIndex"]){
|
||||
window["testValIndex"] = 0;
|
||||
}
|
||||
window["testValIndex"]++;
|
||||
let index = window["testValIndex"];
|
||||
Promise.resolve(res).then(r => window["test-res-"+index] = r);
|
||||
return index;
|
||||
// return args;
|
||||
}, func+"", args);
|
||||
|
||||
// console.log(index);
|
||||
|
||||
//
|
||||
await pause(1000);
|
||||
return await browser.execute((i) => window["test-res-"+i], index);
|
||||
// return index;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
login: login,
|
||||
logout: logout,
|
||||
queryDatabase: queryDatabase,
|
||||
setCurrentDate: setCurrentDate,
|
||||
setFormValues: setFormValues,
|
||||
verifyFormValues: verifyFormValues,
|
||||
addCustomChildSelector: addCustomChildSelector,
|
||||
getBaseUrl: getBaseUrl,
|
||||
pause: pause,
|
||||
acceptAlert: acceptAlert,
|
||||
acceptCookies: acceptCookies,
|
||||
compareFiles: compareFiles,
|
||||
deactivateTranslationLogging: deactivateTranslationLogging,
|
||||
logErrors: logErrors,
|
||||
getLoggedErrors: getLoggedErrors,
|
||||
asyncExecute: asyncExecute,
|
||||
};
|
||||
BIN
tests/misc/chromedriver
Executable file
BIN
tests/misc/chromedriver
Executable file
Binary file not shown.
104
tests/setup.js
Normal file
104
tests/setup.js
Normal file
@@ -0,0 +1,104 @@
|
||||
const mysql = require("mysql");
|
||||
const childProcess = require("child_process");
|
||||
const fs = require("fs");
|
||||
|
||||
let db = "wordrotator_test";
|
||||
let pw = "123456";
|
||||
let mysqlConn = mysql.createConnection({
|
||||
host: "localhost",
|
||||
"user": "root",
|
||||
"password": pw,
|
||||
"database": db,
|
||||
"multipleStatements": true
|
||||
});
|
||||
|
||||
let child = null;
|
||||
|
||||
async function setup() {
|
||||
await generateDb();
|
||||
await startTestServer();
|
||||
}
|
||||
|
||||
async function tearDown() {
|
||||
if (child){
|
||||
//TODO kill for real!
|
||||
console.log("killing child...");
|
||||
child.kill("SIGKILL");
|
||||
}
|
||||
}
|
||||
|
||||
async function startTestServer() {
|
||||
return new Promise((resolve, reject) => {
|
||||
child = childProcess.exec("npm run server", {
|
||||
env: Object.assign({}, process.env,{
|
||||
MYSQL_PASSWORD: pw,
|
||||
MYSQL_DATABASE: db,
|
||||
JWT_SECRET: "123456",
|
||||
PEPPER: "123456"
|
||||
}),
|
||||
stdio: "pipe"
|
||||
}, reject);
|
||||
child.stdout.on("data", data => {
|
||||
console.log("[SERVER]", data);
|
||||
if (data.indexOf("Server started on Port: ") !== -1){
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
async function generateDb() {
|
||||
|
||||
let sqlSchema = fs.readFileSync(__dirname + '/structure.sql', 'utf-8');
|
||||
let sqlData = fs.readFileSync(__dirname + '/setup.sql', 'utf-8');
|
||||
|
||||
// console.log(sqlStrings);
|
||||
// sqlStrings = sqlStrings.split(";");
|
||||
|
||||
let mysqlPromise = Promise.resolve();
|
||||
// sqlStrings.forEach((sql) => {
|
||||
// if (sql.trim() !== "") {
|
||||
mysqlPromise = mysqlPromise.then(() => new Promise(r => {
|
||||
mysqlConn.query(sqlSchema + ";", function (err, result) {
|
||||
if (!err) {
|
||||
r(new Promise(r => {
|
||||
mysqlConn.query(sqlData + ";", function (err, result) {
|
||||
if (!err){
|
||||
r(result);
|
||||
}
|
||||
else{
|
||||
debugger;
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}));
|
||||
// }
|
||||
// });
|
||||
await mysqlPromise;
|
||||
console.log("mysqlPromise resolved!");
|
||||
return true;
|
||||
}
|
||||
|
||||
class InitService {
|
||||
async onPrepare(config, capabilities) {
|
||||
console.log("onPrepare", config, capabilities, new Date());
|
||||
await setup();
|
||||
console.log("onPrepare2", new Date());
|
||||
}
|
||||
|
||||
async onComplete(exitCode, config, capabilities) {
|
||||
console.log("onComplete", exitCode, config, capabilities, new Date());
|
||||
await tearDown();
|
||||
console.log("onComplete2", new Date());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {setup: setup, tearDown: tearDown, service: InitService, mysqlConnection: mysqlConn};
|
||||
33226
tests/setup.sql
Normal file
33226
tests/setup.sql
Normal file
File diff suppressed because it is too large
Load Diff
110
tests/specs/shared/playLevels.js
Normal file
110
tests/specs/shared/playLevels.js
Normal file
@@ -0,0 +1,110 @@
|
||||
const find = require("../../lib/PromiseSelector");
|
||||
const $ = find.one;
|
||||
const $$ = find.multiple;
|
||||
const functions = require("../../lib/functions.js");
|
||||
|
||||
async function solveLevel() {
|
||||
await functions.pause(500);
|
||||
await browser.executeAsync(async (delayFactor, done) => {
|
||||
const delay = 100*delayFactor;
|
||||
|
||||
let promise = Promise.resolve();
|
||||
document.querySelectorAll(".segment.segment-parent.rotate-270").forEach(elem => {
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
});
|
||||
document.querySelectorAll(".segment.segment-parent.rotate-180").forEach(elem => {
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
});
|
||||
document.querySelectorAll(".segment.segment-parent.rotate-90").forEach(elem => {
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
promise = promise.then(() => new Promise(r => {
|
||||
elem.dispatchEvent(new MouseEvent("mousedown", {
|
||||
bubbles: true
|
||||
}));
|
||||
elem.dispatchEvent(new MouseEvent("mouseup"));
|
||||
setTimeout(r, delay);
|
||||
}))
|
||||
});
|
||||
promise.then(() => done());
|
||||
}, browser.config.delayFactor)
|
||||
|
||||
await find.one("#won-text").isDisplayed();
|
||||
await find.one("#continue-button").click();
|
||||
}
|
||||
|
||||
describe("fsj suite", () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3*60*60 * 1000 ;
|
||||
|
||||
let baseUrl = null;
|
||||
beforeAll(async () => {
|
||||
|
||||
if (browser.config.baseUrl.trim() !== "") {
|
||||
baseUrl = browser.config.baseUrl;
|
||||
} else {
|
||||
baseUrl = await browser.getUrl();
|
||||
}
|
||||
|
||||
await browser.setTimeout({
|
||||
implicit: 5000
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
||||
await browser.url(baseUrl);
|
||||
|
||||
await browser.waitUntil(async () => {
|
||||
let element = $("#main-content");
|
||||
return await element.isDisplayed()
|
||||
});
|
||||
|
||||
// await functions.acceptCookies();
|
||||
|
||||
await find.one("#play-button").click();
|
||||
});
|
||||
|
||||
it("play all levels", async function () {
|
||||
|
||||
await find.one("#level .segment").isDisplayed();
|
||||
await solveLevel();
|
||||
await find.one(".help-action").click();
|
||||
while (await find.one("#level").isDisplayed()) {
|
||||
await solveLevel();
|
||||
}
|
||||
|
||||
// await functions.pause(5000);
|
||||
|
||||
});
|
||||
});
|
||||
30
tests/structure.sql
Normal file
30
tests/structure.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
DROP TABLE IF EXISTS Access;
|
||||
DROP TABLE IF EXISTS AuthToken;
|
||||
DROP TABLE IF EXISTS ChangeEmailCode;
|
||||
DROP TABLE IF EXISTS Code;
|
||||
DROP TABLE IF EXISTS Cronjob;
|
||||
DROP TABLE IF EXISTS Level;
|
||||
DROP TABLE IF EXISTS Rating;
|
||||
DROP TABLE IF EXISTS RegistrationCode;
|
||||
DROP TABLE IF EXISTS RequestNewPasswordCode;
|
||||
DROP TABLE IF EXISTS Role;
|
||||
DROP TABLE IF EXISTS RoleAccess;
|
||||
DROP TABLE IF EXISTS RoleChildren;
|
||||
DROP TABLE IF EXISTS User;
|
||||
DROP TABLE IF EXISTS UserAccess;
|
||||
DROP TABLE IF EXISTS UserCode;
|
||||
DROP TABLE IF EXISTS UserSetting;
|
||||
DROP TABLE IF EXISTS Word;
|
||||
DROP TABLE IF EXISTS access;
|
||||
DROP TABLE IF EXISTS level_data;
|
||||
DROP TABLE IF EXISTS migrations;
|
||||
DROP TABLE IF EXISTS `role`;
|
||||
DROP TABLE IF EXISTS roleAccess;
|
||||
DROP TABLE IF EXISTS roleChildren;
|
||||
DROP TABLE IF EXISTS `user`;
|
||||
DROP TABLE IF EXISTS userRole;
|
||||
DROP TABLE IF EXISTS user_access;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
780
tests/test.testcafe.js
Normal file
780
tests/test.testcafe.js
Normal file
@@ -0,0 +1,780 @@
|
||||
import {Selector} from 'testcafe';
|
||||
import {ClientFunction} from 'testcafe';
|
||||
|
||||
let isLocal = false;
|
||||
let isMobile = false;
|
||||
|
||||
const checkMatrix = async (matrixStringSelector, shouldValues, timeout) => {
|
||||
let delta = 0.0001;
|
||||
let step = 100;
|
||||
timeout = (typeof timeout !== "undefined") ? timeout : 3000;
|
||||
let matrixString = await matrixStringSelector;
|
||||
let values = matrixString.substring(7, matrixString.length - 1).split(",");
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
if (typeof shouldValues[i] === "undefined") {
|
||||
shouldValues[i] = 0;
|
||||
}
|
||||
if (shouldValues[i] - delta > values[i] || shouldValues[i] + delta < values[i]) {
|
||||
if (timeout > 0) {
|
||||
await new Promise((r) => {
|
||||
setTimeout(r, step);
|
||||
});
|
||||
return await checkMatrix(matrixStringSelector._reExecute(), shouldValues, timeout - step)
|
||||
}
|
||||
else {
|
||||
console.error(values[i] + " not " + shouldValues[i] + " with", values, shouldValues, i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const goBack = ClientFunction(() => window.history.back());
|
||||
const testLocalStorageSet = ClientFunction((key, value) => {
|
||||
localStorage.setItem(key, value)
|
||||
});
|
||||
const replaceRandom = ClientFunction((sequence) => {
|
||||
window.index = 0;
|
||||
window.sequence = sequence;
|
||||
window.Math.random = function () {
|
||||
let res = sequence[window.index];
|
||||
window.index = (window.index + 1) % sequence.length;
|
||||
return res;
|
||||
}
|
||||
});
|
||||
|
||||
async function beforeEachTest(t) {
|
||||
// await replaceRandom();
|
||||
await waitForMainMenu(t);
|
||||
}
|
||||
|
||||
async function afterEachTest(t) {
|
||||
return await t.eval(() => indexedDB.deleteDatabase('wordRotator'));
|
||||
}
|
||||
|
||||
async function waitForMainMenu(t) {
|
||||
|
||||
while (!(await Selector("#play-button").exists)) {
|
||||
// console.log("nextIterate");
|
||||
await t.wait(100);
|
||||
}
|
||||
await t.wait(1000);
|
||||
}
|
||||
|
||||
if (isLocal) {
|
||||
fixture`Play`
|
||||
.page`https://127.0.0.1/pwa/wordRotator/publicTest/`.beforeEach(async t => {
|
||||
// .page`https://192.168.0.51/pwa/wordRotator/publicTest/`.beforeEach(async t => {
|
||||
await beforeEachTest(t);
|
||||
}).afterEach(async t => {
|
||||
await afterEachTest(t);
|
||||
});
|
||||
}
|
||||
else {
|
||||
fixture`betaPlay`
|
||||
.page`http://beta.wordrotator.silas.link`
|
||||
.httpAuth({
|
||||
username: 'admin',
|
||||
password: '20luxl200'
|
||||
}).beforeEach(async t => {
|
||||
await beforeEachTest(t);
|
||||
// await t.wait(25000);
|
||||
}).afterEach(async t => {
|
||||
await afterEachTest(t);
|
||||
});
|
||||
}
|
||||
let dragDimen = 280;
|
||||
|
||||
if (isMobile) {
|
||||
dragDimen = 90;
|
||||
}
|
||||
|
||||
const extraCoins = 50;
|
||||
const coinsPerLevel = 5;
|
||||
const helpCost = 25;
|
||||
|
||||
const SEGMENT = {
|
||||
ONE: 0,
|
||||
TWO: 1,
|
||||
THREE: 2,
|
||||
FOUR: 3,
|
||||
FIVE: 4,
|
||||
SIX: 5,
|
||||
SEVEN: 6,
|
||||
EIGHT: 7,
|
||||
NINE: 8,
|
||||
TEN: 9,
|
||||
ELEVEN: 10,
|
||||
TWELVE: 11,
|
||||
THIRTEEN: 12,
|
||||
FOURTEEN: 13,
|
||||
FIFTEEN: 14,
|
||||
SIXTEEN: 15,
|
||||
SEVENTEEN: 16,
|
||||
EIGHTEEN: 17,
|
||||
NINETEEN: 18,
|
||||
TWENTY: 19,
|
||||
TWENTYONE: 20
|
||||
};
|
||||
|
||||
test('Play', async t => {
|
||||
let levelNumber = 1;
|
||||
|
||||
await waitForMainMenu(t);
|
||||
await t
|
||||
//Main Menu
|
||||
.click(Selector('#play-button')).wait(500)
|
||||
|
||||
//firstTutorial
|
||||
.expect(Selector('.tutorial-text .step-1').visible).eql(true)
|
||||
.expect(Selector('.tutorial-text .step-2').visible).eql(false)
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.expect(Selector('.tutorial-text .step-2').visible).eql(true)
|
||||
.expect(Selector('.tutorial-text .step-1').visible).eql(false)
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.expect(Selector('.tutorial-text .step-2').visible).eql(true);
|
||||
await t.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.wait(1000);
|
||||
|
||||
levelNumber++;
|
||||
//first Level
|
||||
await t.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-90').nth(0).getStyleProperty('transform'), [0, 1, -1, 0])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-90').nth(1).getStyleProperty('transform'), [0, 1, -1, 0])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-270').getStyleProperty('transform'), [0, -1, 1, 0])).ok()
|
||||
.expect(Selector('#won-text').visible).eql(false)
|
||||
.expect(Selector('#continue-button').visible).eql(false)
|
||||
.expect(Selector('#level-number').textContent).eql("2")
|
||||
.click(Selector("#help-button"))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
// .expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [1, 0, 0,1, 0])).ok()
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform'), [1, 0, 0, 1])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform'), [1, 0, 0, 1])).ok()
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
//TWOLevel
|
||||
await t.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("BRTH")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("AUER")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("ERAP")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).textContent).eql("EIIE")
|
||||
.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-270').nth(0).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-180').getStyleProperty('transform'), [-1, 0, 0, -1,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment.segment-parent.rotate-360').getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(Selector('#continue-button').visible).eql(false)
|
||||
.expect(Selector('#level-number').textContent).eql("3")
|
||||
.expect(Selector('#won-text').visible).eql(false)
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
//THREE Level
|
||||
await t.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("ZEHO")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("ITCH")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("STSA")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).textContent).eql("RAIS")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FIVE).textContent).eql("FEON")
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
await t
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.THREE), dragDimen, 4, {
|
||||
offsetX: 10,
|
||||
offsetY: 17
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
await t
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
await t
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.FIVE), -dragDimen, 4, {
|
||||
offsetX: dragDimen + 50,
|
||||
offsetY: 17
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
levelNumber++;
|
||||
|
||||
await t
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
await t.drag(Selector('.segment-parent').nth(SEGMENT.ONE), -dragDimen, 4, {
|
||||
offsetX: dragDimen + 50,
|
||||
offsetY: 17
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('#continue-button'));
|
||||
levelNumber++;
|
||||
|
||||
|
||||
//4. Level
|
||||
await t
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("FERÜINCKPHREYSSI")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("FERÜ")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("INCK")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).textContent).eql("PHRE")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FIVE).textContent).eql("YSSI")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.SIX).textContent).eql("BEKO")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.SEVEN).textContent).eql("RACH")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.EIGHT).textContent).eql("GUFA")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.NINE).textContent).eql("SSLL")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TEN).textContent).eql("IKDEERNZTUTONGPF")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ELEVEN).textContent).eql("IKDE")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWELVE).textContent).eql("ERNZ")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THIRTEEN).textContent).eql("TUTO")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.FOURTEEN).textContent).eql("NGPF")
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, 4, {
|
||||
offsetX: dragDimen / 5,
|
||||
offsetY: 10
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), dragDimen, 3, {
|
||||
offsetX: dragDimen / 5,
|
||||
offsetY: 10
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN).find('div').withText('I'), dragDimen, 4, {
|
||||
offsetX: dragDimen / 5,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE).find('div').withText('S'), 10, dragDimen, {
|
||||
offsetX: dragDimen,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, 4, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
|
||||
//5. Level
|
||||
await t.expect(Selector('#level-number').textContent).eql("" + levelNumber)
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("WADUHLNSWAPASSRK")
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
levelNumber++;
|
||||
|
||||
//5. Level
|
||||
await t.expect(Selector('#level-number').textContent).eql("" + levelNumber)
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.THREE), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.EIGHT), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
levelNumber++;
|
||||
|
||||
await t.expect(Selector('#level-number').textContent).eql("" + levelNumber)
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.SIX), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.SIX), dragDimen, 3, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
levelNumber++;
|
||||
|
||||
//5. Level
|
||||
await t.expect(Selector('#level-number').textContent).eql("" + levelNumber)
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("BEANTOBEALBALEUM")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.SIX).textContent).eql("NUTUNGNGRGHAIEUS")
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.SIX).getStyleProperty('transform'), [0, 1, -1, 0,])).ok()
|
||||
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.SIX), 3, dragDimen, {
|
||||
offsetX: 10,
|
||||
offsetY: dragDimen / 5
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
//Level 6
|
||||
await t.expect(Selector('#level-number').textContent).eql("" + levelNumber)
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("FEGEHLISARBEBERE")
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.TEN).getStyleProperty('transform'), [-1, 0, 0, -1,])).ok()
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TEN).textContent).eql("ITITSPSCIKARAROT")
|
||||
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN).find('div').withText('A'), dragDimen, -4, {
|
||||
offsetX: 10,
|
||||
offsetY: 10
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIX))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTY))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THIRTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTYONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.ELEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOURTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIXTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWELVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINETEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTYONE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTY))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THIRTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTY))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVENTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SIXTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOURTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINETEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWENTYONE))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, -3, {
|
||||
offsetX: 10,
|
||||
offsetY: 10
|
||||
})
|
||||
.expect(await checkMatrix(Selector('div').withText('P').nth(11).find('.segment.segment-parent.layer-2.rotate-360').getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));
|
||||
|
||||
levelNumber++;
|
||||
//Level 7
|
||||
await t.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.SIX).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(Selector('.segment-row > .child-container').childElementCount).eql(3)
|
||||
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
|
||||
offsetX: 10,
|
||||
offsetY: 10
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THIRTEEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ELEVEN), 14, dragDimen, {
|
||||
offsetX: 10,
|
||||
offsetY: 10
|
||||
})
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FIVE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.EIGHT))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.NINE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ELEVEN), 14, dragDimen, {
|
||||
offsetX: 10,
|
||||
offsetY: 10
|
||||
})
|
||||
.click(Selector('#help-button'))
|
||||
.wait(5000)
|
||||
.expect(Selector('.coin-counter').innerText).contains("" + (coinsPerLevel * levelNumber - helpCost + extraCoins - helpCost))
|
||||
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
.click(Selector('#continue-button'))
|
||||
.expect(Selector('#Sites-content').childElementCount).eql(1);
|
||||
});
|
||||
test('LoadLastLevel', async t => {
|
||||
await waitForMainMenu(t);
|
||||
await t.click(Selector('#play-button')).wait(500)
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).hasClass('locked')).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform'), [1, 0, 0, 1,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
}).before(async t => {
|
||||
await testLocalStorageSet("currentLevel", "{\"id\":15,\"rotations\":[0,0,270],\"locks\":[false,true,true]}");
|
||||
});
|
||||
test('LevelRotation', async t => {
|
||||
await waitForMainMenu(t);
|
||||
await t
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
.wait(1000)
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform'), [0, 1, -1, 0,])).ok()
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR)).wait(500)
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("AHAU")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("NUSB")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("NGAU");
|
||||
await goBack();
|
||||
await t
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
.wait(2000)
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform'), [0, -1, 1, 0,])).ok()
|
||||
.expect(await checkMatrix(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform'), [0, 1, -1, 0,])).ok()
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("AHAU")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("NUSB")
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("NGAU");
|
||||
|
||||
}).before(async t => {
|
||||
await replaceRandom([0.5]);
|
||||
});
|
||||
test('SendUserstats', async t => {
|
||||
await waitForMainMenu(t);
|
||||
let matomoCheck = ClientFunction(() => {
|
||||
return new Promise((resolve) => {
|
||||
function check() {
|
||||
window["_paq"].push([function () {
|
||||
resolve(!this["isUserOptedOut"]());
|
||||
}]);
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
check();
|
||||
});
|
||||
if (document.readyState === 'complete') {
|
||||
check();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await t
|
||||
.click(Selector(".action [data-translation-title='settings']"))
|
||||
.expect(Selector("#play-sound").checked).ok()
|
||||
.expect(Selector("#play-music").checked).ok()
|
||||
.expect(Selector("#track-switch").checked).ok();
|
||||
let res = await matomoCheck();
|
||||
await t.expect(res).ok()
|
||||
.click(Selector(".switch [data-translation='track']"))
|
||||
.expect(Selector("#track-switch").checked).eql(false);
|
||||
res = await matomoCheck();
|
||||
await t.expect(res).eql(false)
|
||||
.click(Selector(".switch [data-translation='track']"))
|
||||
.expect(Selector("#track-switch").checked).ok();
|
||||
res = await matomoCheck();
|
||||
await t.expect(res).ok()
|
||||
}).before(async t => {
|
||||
await testLocalStorageSet("matomoShouldTrack", "1");
|
||||
});
|
||||
|
||||
test('SendUserstatsInPrivacyPolicy', async t => {
|
||||
await waitForMainMenu(t);
|
||||
let matomoCheck = ClientFunction(() => {
|
||||
return new Promise((resolve) => {
|
||||
function check() {
|
||||
window["_paq"].push([function () {
|
||||
resolve(!this["isUserOptedOut"]());
|
||||
}]);
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
check();
|
||||
});
|
||||
if (document.readyState === 'complete') {
|
||||
check();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await t
|
||||
.click(Selector(".action [data-translation-title='settings']"))
|
||||
.click(Selector("#privacy-policy-button"))
|
||||
.expect(Selector("#track-switch").checked).ok();
|
||||
let res = await matomoCheck();
|
||||
await t.expect(res).ok()
|
||||
.click(Selector(".switch [data-translation='track']"))
|
||||
.expect(Selector("#track-switch").checked).eql(false);
|
||||
res = await matomoCheck();
|
||||
await t.expect(res).eql(false)
|
||||
.click(Selector(".switch [data-translation='track']"))
|
||||
.expect(Selector("#track-switch").checked).ok();
|
||||
res = await matomoCheck();
|
||||
await t.expect(res).ok()
|
||||
}).before(async t => {
|
||||
await testLocalStorageSet("matomoShouldTrack", "1");
|
||||
});
|
||||
|
||||
test('Themes', async t => {
|
||||
await waitForMainMenu(t);
|
||||
await t
|
||||
.expect(Selector("body.dark").visible).ok()
|
||||
.click(Selector(".action [data-translation-title='settings']"))
|
||||
.expect(Selector("#theme-name").innerText).eql("Dunkel")
|
||||
.click(Selector("#theme-name"))
|
||||
.click(Selector(".name [data-translation]").nth(3))
|
||||
.wait(100)
|
||||
.expect(Selector("#theme-name").innerText).eql("Grün")
|
||||
.expect(Selector("body.green").visible).ok()
|
||||
}).before(async t => {
|
||||
await testLocalStorageSet("currentTheme", "dark");
|
||||
});
|
||||
|
||||
test('Sharing', async t => {
|
||||
|
||||
let overrideWindowOpener = ClientFunction(() => {
|
||||
window.open = (url, blank, noopener) => {
|
||||
window.lastWindowOpened = [url, blank, noopener];
|
||||
}
|
||||
});
|
||||
|
||||
let getLastWindowOpened = ClientFunction(() => {
|
||||
return window.lastWindowOpened;
|
||||
});
|
||||
|
||||
|
||||
await waitForMainMenu(t);
|
||||
await overrideWindowOpener();
|
||||
|
||||
await t
|
||||
.expect(Selector(".share-icon").nth(0).exists).eql(false)
|
||||
.expect(Selector(".share-icon").nth(1).exists).eql(false)
|
||||
.click(Selector("#share-button"))
|
||||
.expect(Selector(".share-icon").nth(0).visible).ok()
|
||||
.expect(Selector(".share-icon").nth(1).visible).ok()
|
||||
.click(Selector(".share-icon").nth(0))
|
||||
.expect(Selector(".share-icon").nth(0).exists).eql(false)
|
||||
.expect(Selector(".share-icon").nth(1).exists).eql(false);
|
||||
if (isLocal) {
|
||||
console.log(await getLastWindowOpened());
|
||||
await t.expect(await getLastWindowOpened()).eql(["https://web.whatsapp.com/send?text=" + encodeURIComponent("127.0.0.1/pwa/wordRotator/publicTest/"), "_blank", "noopener"]);
|
||||
}
|
||||
else {
|
||||
console.log(await getLastWindowOpened());
|
||||
await t.expect(await getLastWindowOpened()).eql(["https://web.whatsapp.com/send?text=" + encodeURIComponent("beta.wordrotator.silas.link/"), "_blank", "noopener"]);
|
||||
}
|
||||
await t
|
||||
.click(Selector("#share-button"))
|
||||
.expect(Selector(".share-icon").nth(0).visible).ok()
|
||||
.expect(Selector(".share-icon").nth(1).visible).ok()
|
||||
.click(Selector(".share-icon").nth(1))
|
||||
.expect(Selector(".share-icon").nth(0).exists).eql(false)
|
||||
.expect(Selector(".share-icon").nth(1).exists).eql(false);
|
||||
if (isLocal) {
|
||||
console.log(await getLastWindowOpened());
|
||||
await t.expect(await getLastWindowOpened()).eql(["https://t.me/share/url?url=" + encodeURIComponent("127.0.0.1/pwa/wordRotator/publicTest/"), "_blank", "noopener"]);
|
||||
}
|
||||
else {
|
||||
console.log(await getLastWindowOpened());
|
||||
await t.expect(await getLastWindowOpened()).eql(["https://t.me/share/url?url=" + encodeURIComponent("beta.wordrotator.silas.link/"), "_blank", "noopener"]);
|
||||
}
|
||||
});
|
||||
106
tests/wdio.config.android.js
Normal file
106
tests/wdio.config.android.js
Normal file
@@ -0,0 +1,106 @@
|
||||
const Service = require("./setup");
|
||||
const path = require("path");
|
||||
|
||||
exports.config = {
|
||||
|
||||
// Where the files we are testing can be found.
|
||||
specs: ['./tests/specs/**/*.js'],
|
||||
|
||||
runner: "local",
|
||||
|
||||
// wdio will run your tests using the framework below. You can choose from several,
|
||||
// much like the reporters. The full list is at https://www.npmjs.com/search?q=wdio-framework
|
||||
framework: 'jasmine',
|
||||
|
||||
// By default, Jasmine times out within 10 seconds. This is not really enough time
|
||||
// for us as it takes a while for Appium to get set up.
|
||||
jasmineNodeOpts: {
|
||||
defaultTimeoutInterval: 90000
|
||||
},
|
||||
|
||||
sync: true,
|
||||
|
||||
// How much detail should be logged. The options are:
|
||||
// 'silent', 'verbose', 'command', 'data', 'result', 'error'
|
||||
logLevel: 'error',
|
||||
|
||||
mysqlConnection: Service.mysqlConnection,
|
||||
|
||||
deprecationWarnings: true,
|
||||
|
||||
bail: 0,
|
||||
|
||||
baseUrl: "",
|
||||
|
||||
waitforTimeout: 10000,
|
||||
|
||||
connectionRetryTimeout: 90000,
|
||||
|
||||
connectionRetryCount: 3,
|
||||
|
||||
delayFactor: 1,
|
||||
|
||||
// The reporter is what formats your test results on the command line. 'spec' lists
|
||||
// the names of the tests with a tick or X next to them. See
|
||||
// https://www.npmjs.com/search?q=wdio-reporter for a full list of reporters.
|
||||
reporters: ['spec'],
|
||||
|
||||
// Use the Appium plugin for Webdriver. Without this, we would need to run appium
|
||||
// separately on the command line.
|
||||
services: [
|
||||
'appium'
|
||||
],
|
||||
|
||||
// 4723 is the default port for Appium
|
||||
port: 4723,
|
||||
|
||||
appium: {
|
||||
args: {
|
||||
chromedriverExecutable: path.join(__dirname, "misc/chromedriver"),
|
||||
}
|
||||
},
|
||||
|
||||
// This defines which kind of device we want to test on, as well as how it should be
|
||||
// configured.
|
||||
capabilities: [{
|
||||
automationName: "UiAutomator2",
|
||||
// automationName: "Espresso",
|
||||
chromedriverExecutable: path.join(__dirname, "misc/chromedriver"),
|
||||
|
||||
// For Android, Appium uses the first device it finds using "adb devices". So, this
|
||||
// string simply needs to be non-empty.
|
||||
// For iOS, this must exactly match the device name as seen in Xcode.
|
||||
deviceName: 'any',
|
||||
|
||||
// 'Android' or 'iOS'
|
||||
platformName: 'Android',
|
||||
|
||||
// The version of the Android or iOS system
|
||||
platformVersion: '10',
|
||||
|
||||
orientation: "PORTRAIT",
|
||||
|
||||
maxInstances: 1,
|
||||
|
||||
// Where to find the .apk or .ipa file to install on the device. The exact location
|
||||
// of the file may change depending on your Cordova version.
|
||||
app: 'platforms/android/app/build/outputs/apk/debug/app-debug.apk',
|
||||
|
||||
// By default, Appium runs tests in the native context. By setting autoWebview to
|
||||
// true, it runs our tests in the Cordova context.
|
||||
autoWebview: true,
|
||||
|
||||
// When set to true, it will not show permission dialogs, but instead grant all
|
||||
// permissions automatically.
|
||||
autoGrantPermissions: true,
|
||||
deviceReadyTimeout: 30
|
||||
}],
|
||||
|
||||
onPrepare: async function(){
|
||||
await Service.setup();
|
||||
},
|
||||
onComplete: async function(){
|
||||
console.log("tearing down...");
|
||||
await Service.tearDown();
|
||||
}
|
||||
};
|
||||
68
tests/wdio.config.browser.js
Normal file
68
tests/wdio.config.browser.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const Service = require("./setup");
|
||||
|
||||
exports.config = {
|
||||
|
||||
// Where the files we are testing can be found.
|
||||
specs: ['./tests/specs/**/*.js'],
|
||||
// specs: ['./tests/specs/**/addExercise.js'],
|
||||
|
||||
runner: "local",
|
||||
|
||||
// wdio will run your tests using the framework below. You can choose from several,
|
||||
// much like the reporters. The full list is at https://www.npmjs.com/search?q=wdio-framework
|
||||
framework: 'jasmine',
|
||||
|
||||
delayFactor: 1,
|
||||
|
||||
// By default, Jasmine times out within 10 seconds. This is not really enough time
|
||||
// for us as it takes a while for Appium to get set up.
|
||||
jasmineNodeOpts: {
|
||||
defaultTimeoutInterval: 90000
|
||||
},
|
||||
|
||||
sync: true,
|
||||
|
||||
// How much detail should be logged. The options are:
|
||||
// 'silent', 'verbose', 'command', 'data', 'result', 'error'
|
||||
logLevel: 'error',
|
||||
|
||||
mysqlConnection: Service.mysqlConnection,
|
||||
|
||||
deprecationWarnings: true,
|
||||
|
||||
bail: 0,
|
||||
|
||||
baseUrl: "http://127.0.0.1:8000",
|
||||
|
||||
waitforTimeout: 10000,
|
||||
|
||||
connectionRetryTimeout: 90000,
|
||||
|
||||
connectionRetryCount: 3,
|
||||
|
||||
// The reporter is what formats your test results on the command line. 'spec' lists
|
||||
// the names of the tests with a tick or X next to them. See
|
||||
// https://www.npmjs.com/search?q=wdio-reporter for a full list of reporters.
|
||||
reporters: ['spec'],
|
||||
|
||||
// Use the Appium plugin for Webdriver. Without this, we would need to run appium
|
||||
// separately on the command line.
|
||||
services: [
|
||||
// 'appium'
|
||||
'selenium-standalone',
|
||||
// [Service.service,{}]
|
||||
],
|
||||
|
||||
capabilities: [{
|
||||
browserName: "chrome",
|
||||
maxInstances: 1,
|
||||
}],
|
||||
onPrepare: async function(){
|
||||
await Service.setup();
|
||||
},
|
||||
onComplete: async function(){
|
||||
console.log("tearing down...");
|
||||
await Service.tearDown();
|
||||
console.log("teared down!");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user