From 9678354c92570bf31038a91ebd5fdcfc27f0187e Mon Sep 17 00:00:00 2001 From: silas Date: Thu, 27 Sep 2018 13:57:36 +0200 Subject: [PATCH] =?UTF-8?q?=C3=BCbertrag=20zu=20laptop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 31 +++++++------ .../Application/pwa/js/site/LevelSite.js | 31 +++++++------ test/test.testcafe.js | 43 +++++++++++++------ 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index d5d0476..4f73511 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -5971,18 +5971,18 @@ class LevelSite extends WordRotatorBaseSite { let soundManager = SoundManager.getInstance(); let audioOptions = soundManager.get(SoundManager.CHANNELS.SOUND); - this.coinPromise = Promise.all([new Promise((r) => { - setTimeout(() => { - r(continueButton.fadeIn()); - }, 500); - }), audioOptions.loadedPromise.catch(e => { - console.error(e); - }), - this.coinPromise.then(() => { - coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0")); - localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel)); - }) - ]); + this.coinPromise = this.coinPromise.then(() => { + coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0")); + localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel)); + }).then(() => { + return Promise.all([new Promise((r) => { + setTimeout(() => { + r(continueButton.fadeIn()); + }, 500); + }), audioOptions.loadedPromise.catch(e => { + console.error(e); + })]); + }); this.wonParams.aborted = false; @@ -6003,13 +6003,18 @@ class LevelSite extends WordRotatorBaseSite { this.coinAction.redraw(); } }, timeout / 2); + setTimeout(r, timeout); + } + else { + r(); } //Always do the next promise for garbage collection - setTimeout(r, timeout); }) }); } + this.coinPromise = this.coinPromise.catch((e) => {console.error(e);}); + this.wonTextScaler(); this.continueButtonScaler(); this.levelScaler(); diff --git a/src/module/Application/pwa/js/site/LevelSite.js b/src/module/Application/pwa/js/site/LevelSite.js index a9c4df0..1066245 100755 --- a/src/module/Application/pwa/js/site/LevelSite.js +++ b/src/module/Application/pwa/js/site/LevelSite.js @@ -227,18 +227,18 @@ export class LevelSite extends WordRotatorBaseSite { let soundManager = SoundManager.getInstance(); let audioOptions = soundManager.get(SoundManager.CHANNELS.SOUND); - this.coinPromise = Promise.all([new Promise((r) => { - setTimeout(() => { - r(continueButton.fadeIn()); - }, 500) - }), audioOptions.loadedPromise.catch(e => { - console.error(e) - }), - this.coinPromise.then(() => { - coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0")); - localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel)); - }) - ]); + this.coinPromise = this.coinPromise.then(() => { + coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0")); + localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel)); + }).then(() => { + return Promise.all([new Promise((r) => { + setTimeout(() => { + r(continueButton.fadeIn()); + }, 500) + }), audioOptions.loadedPromise.catch(e => { + console.error(e) + })]); + }); this.wonParams.aborted = false; @@ -259,13 +259,18 @@ export class LevelSite extends WordRotatorBaseSite { this.coinAction.redraw(); } }, timeout / 2); + setTimeout(r, timeout); + } + else { + r(); } //Always do the next promise for garbage collection - setTimeout(r, timeout); }) }); } + this.coinPromise = this.coinPromise.catch((e) => {console.error(e)}); + this.wonTextScaler(); this.continueButtonScaler(); this.levelScaler(); diff --git a/test/test.testcafe.js b/test/test.testcafe.js index ea103b8..df16fdb 100644 --- a/test/test.testcafe.js +++ b/test/test.testcafe.js @@ -23,7 +23,7 @@ async function afterEachTest(t) { return await t.eval(() => indexedDB.deleteDatabase('wordRotator')); } -let isLocal = false; +let isLocal = true; if (isLocal) { fixture`Play` .page`https://127.0.0.1/pwa/wordRotator/publicTest/`.beforeEach(async t => { @@ -46,6 +46,7 @@ else { }); } +const extraCoins = 50; const coinsPerLevel = 5; const dragDimen = 250; const helpCost = 25; @@ -74,18 +75,32 @@ const SEGMENT = { TWENTYONE: 20 }; -test('Play', async t => { +test.only('Play', async t => { await t //Main Menu .click(Selector('#play-button')) + //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) + .click(Selector('.segment-parent').nth(SEGMENT.THREE)) + .expect(Selector('#continue-button').visible).eql(true) + .wait(3500) + .click(Selector('#continue-button')) + //first Level .expect(Selector('.segment.segment-parent.rotate-90').nth(0).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)") .expect(Selector('.segment.segment-parent.rotate-90').nth(1).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)") .expect(Selector('.segment.segment-parent.rotate-270').getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('#won-text').visible).eql(false) .expect(Selector('#continue-button').visible).eql(false) - .expect(Selector('#level-number').textContent).eql("1") + .expect(Selector('#level-number').textContent).eql("2") + .click(Selector("#help-button")) .click(Selector('.segment-parent').nth(SEGMENT.THREE)) .expect(Selector('.segment.segment-parent.rotate-360').getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)") .click(Selector('.segment-parent').nth(SEGMENT.ONE)) @@ -98,7 +113,7 @@ test('Play', async t => { .expect(Selector('#won-text').visible).eql(true) .expect(Selector('#continue-button').visible).eql(true) .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel*2+extraCoins-helpCost)) //TWOLevel .expect(Selector('.segment.segment-parent.rotate-270').nth(0).textContent).eql("BOAL") @@ -110,7 +125,7 @@ test('Play', async t => { .expect(Selector('.segment.segment-parent.rotate-360').getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)") .expect(Selector('.segment.segment-parent.rotate-270').nth(1).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('#continue-button').visible).eql(false) - .expect(Selector('#level-number').textContent).eql("2") + .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)) @@ -122,7 +137,7 @@ test('Play', async t => { .expect(Selector('#won-text').visible).eql(true) .expect(Selector('#continue-button').visible).eql(true) .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 2) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 3+extraCoins-helpCost)) //THREE Level .expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("ZEHO") @@ -139,7 +154,7 @@ test('Play', async t => { .click(Selector('.segment-parent').nth(SEGMENT.FOUR)) .click(Selector('.segment-parent').nth(SEGMENT.FIVE)) .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 3) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 4+extraCoins-helpCost)) //4. Level .expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("FERÜINCKPHREYSSI") @@ -194,11 +209,13 @@ test('Play', async t => { .click(Selector('.segment-parent').nth(SEGMENT.SIX)) .expect(Selector('#continue-button').visible).eql(true) .expect(Selector('#won-text').visible).eql(true) + .wait(1000) + .debug() .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 4) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 5+extraCoins-helpCost)) //5. Level - .expect(Selector('#level-number').textContent).eql("5") + .expect(Selector('#level-number').textContent).eql("6") .expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("BEANTOBEALBALEUM") .expect(Selector('.segment-parent').nth(SEGMENT.SIX).textContent).eql("NUTUNGNGRGHAIEUS") .expect(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)") @@ -229,11 +246,11 @@ test('Play', async t => { .expect(Selector('#won-text').visible).eql(true) .expect(Selector('#continue-button').visible).eql(true) .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 5) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 6+extraCoins-helpCost)) //Level 6 - .expect(Selector('#level-number').textContent).eql("6") + .expect(Selector('#level-number').textContent).eql("7") .expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("FEGEHLISARBEBERE") .expect(Selector('.segment-parent').nth(SEGMENT.ONE).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.TEN).getStyleProperty('transform')).eql("matrix(-1, 0, 0, -1, 0, 0)") @@ -281,7 +298,7 @@ test('Play', async t => { .expect(Selector('#continue-button').visible).eql(true) .expect(Selector('#won-text').visible).eql(true) .click(Selector('#continue-button')) - .expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 6) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 7+extraCoins-helpCost)) //Level 7 @@ -326,7 +343,7 @@ test('Play', async t => { // .click(Selector('.segment-parent').nth(SEGMENT.THIRTEEN)) .click(Selector('#help-button')) .wait(5000) - .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 7 - helpCost)) + .expect(Selector('.coin-counter').innerText).eql("" + (coinsPerLevel * 8 - helpCost+extraCoins-helpCost)) .expect(Selector('#won-text').visible).eql(true) .expect(Selector('#continue-button').visible).eql(true)