Synchronisation im Hintegrund

This commit is contained in:
silas
2018-10-02 18:32:36 +02:00
parent b5da034687
commit da2252fc11
4 changed files with 83 additions and 39 deletions

View File

@@ -17,13 +17,23 @@ const replaceRandom = ClientFunction((sequence) => {
async function beforeEachTest(t) {
// await replaceRandom();
await waitForMainMenu(t);
}
async function afterEachTest(t) {
return await t.eval(() => indexedDB.deleteDatabase('wordRotator'));
}
let isLocal = false;
async function waitForMainMenu(t) {
while (!(await Selector("#play-button").exists)) {
// console.log("nextIterate");
await t.wait(100);
}
await t.wait(2000);
}
let isLocal = true;
if (isLocal) {
fixture`Play`
.page`https://127.0.0.1/pwa/wordRotator/publicTest/`.beforeEach(async t => {
@@ -40,7 +50,7 @@ else {
password: '20luxl200'
}).beforeEach(async t => {
await beforeEachTest(t);
await t.wait(25000);
// await t.wait(25000);
}).afterEach(async t => {
await afterEachTest(t);
});
@@ -78,6 +88,7 @@ const SEGMENT = {
test('Play', async t => {
let levelNumber = 1;
await waitForMainMenu(t);
await t
//Main Menu
.click(Selector('#play-button'))
@@ -369,6 +380,7 @@ test('Play', async t => {
.expect(Selector('#site-content').childElementCount).eql(1);
});
test('LoadLastLevel', async t => {
await waitForMainMenu(t);
await t.click(Selector('#play-button'))
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).hasClass('locked')).ok()
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
@@ -378,11 +390,12 @@ test('LoadLastLevel', async t => {
await testLocalStorageSet("currentLevel", "{\"id\":15,\"rotations\":[0,0,270],\"locks\":[false,true,true]}");
});
test('LevelRotation', async t => {
await 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))
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.wait(3000)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.wait(3500)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
@@ -397,7 +410,8 @@ test('LevelRotation', async t => {
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.wait(4000)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.wait(3500)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
@@ -412,26 +426,34 @@ test('LevelRotation', async t => {
await replaceRandom([0.9, 0.5]);
});
test('SendUserstats', async t => {
await waitForMainMenu(t);
let matomoCheck = ClientFunction(() => {
return fetch("//matomo.silas.link/index.php?module=API&method=AjaxOptOut.isTracked", {
"mode": "cors",
"credentials": "include",
}).then(res => res.text()).then(text => (new window.DOMParser()).parseFromString(text, "text/xml")).then((xml => {
let textContent = xml.firstChild.textContent;
console.log(textContent);
return (textContent === "1")
}));
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()
.expect(await matomoCheck()).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);
let res = await matomoCheck();
res = await matomoCheck();
await t.expect(res).eql(false)
.click(Selector(".switch [data-translation='track']"))
.expect(Selector("#track-switch").checked).ok();
@@ -442,7 +464,7 @@ test('SendUserstats', async t => {
});
test('Themes', async t => {
await testLocalStorageSet("currentTheme", "dark");
await waitForMainMenu(t);
await t
.expect(Selector("body.dark").visible).ok()
.click(Selector(".action [data-translation-title='settings']"))
@@ -453,5 +475,5 @@ test('Themes', async t => {
.expect(Selector("#theme-name").innerText).eql("Grün")
.expect(Selector("body.green").visible).ok()
}).before(async t => {
testLocalStorageSet("currentTheme", "dark");
await testLocalStorageSet("currentTheme", "dark");
});