Startseite und Tests geupdated

This commit is contained in:
silas 2018-09-24 19:58:37 +02:00
parent 11fe3628a2
commit c8c5ccf737
15 changed files with 403 additions and 39601 deletions

View File

@ -15,3 +15,10 @@
2018-09-24T12:26:01+02:00 ERR (3):
2018-09-24T12:26:07+02:00 ERR (3):
2018-09-24T12:46:47+02:00 ERR (3):
2018-09-24T18:00:03+02:00 ERR (3):
2018-09-24T18:08:09+02:00 ERR (3):
2018-09-24T18:15:13+02:00 ERR (3):
2018-09-24T18:48:11+02:00 ERR (3):
2018-09-24T18:48:21+02:00 ERR (3):
2018-09-24T19:08:22+02:00 ERR (3):
2018-09-24T19:47:41+02:00 ERR (3):

View File

@ -15,3 +15,10 @@
2018-09-24T12:26:01+02:00 ERR (3):
2018-09-24T12:26:07+02:00 ERR (3):
2018-09-24T12:46:47+02:00 ERR (3):
2018-09-24T18:00:03+02:00 ERR (3):
2018-09-24T18:08:09+02:00 ERR (3):
2018-09-24T18:15:13+02:00 ERR (3):
2018-09-24T18:48:11+02:00 ERR (3):
2018-09-24T18:48:21+02:00 ERR (3):
2018-09-24T19:08:22+02:00 ERR (3):
2018-09-24T19:47:41+02:00 ERR (3):

View File

@ -1 +1,7 @@
single_coin_on_concrete https://www.freesfx.co.uk/
single_coin_on_concrete https://www.freesfx.co.uk/
Bright And Beautiful - GEMAfreie Musik von https://audeeyah.de
Licensed under Creative Commons: By Attribution 4.0 International (CC BY 4.0)
http://creativecommons.org/licenses/by/4.0/
Angepasst (geschnitten) für diese App

View File

@ -872,10 +872,12 @@ class Helper {
}
static nonNull(val1, val2) {
if (Helper.isNotNull(val1)) {
return val1;
for (let i = 0; i < arguments.length; i++) {
if (Helper.isNotNull(arguments[i])) {
return arguments[i];
}
}
return val2;
return null;
}
static notEmpty(value) {
@ -4663,6 +4665,123 @@ class ScaleHelper {
}
}
class SoundManager {
static getInstance() {
if (Helper.isNull(SoundManager.instance)) {
SoundManager.instance = new SoundManager();
}
return SoundManager.instance;
}
constructor() {
this.channels = {};
}
set(options, channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
let audioObject = Helper.nonNull(this.channels[channel], {});
if (typeof options === "string") {
options = {audio: options};
}
let audio = options.audio;
if (Helper.isNotNull(audio)) {
let src = null;
if (typeof audio === "string") {
src = audio;
audio = new Audio();
audioObject.loadedPromise = new Promise((resolve, reject) => {
audio.addEventListener("loadeddata", () => {
resolve();
});
audio.addEventListener("error", (e) => {
console.warn(e);
reject(e);
});
});
audio.src = Helper.basePath(src);
}
else {
audioObject.loadedPromise = Promise.resolve();
}
this.stop(channel);
audioObject.audio = audio;
// audio.addEventListener('timeupdate', () => {
// let buffer = 10;
// if (this.channels[channel].audio === audio && this.channels[channel].loop) {
// if (audio.currentTime > audio.duration - buffer) {
// console.log("reset");
// audio.currentTime = 0;
// audio.play();
// }
// }
// }, false);
}
audioObject.muted = Helper.nonNull(options.muted, audioObject.muted, false);
audioObject.volume = Helper.nonNull(options.volume, audioObject.volume, 1);
audioObject.loop = Helper.nonNull(options.loop, audioObject.loop, false);
audioObject.timeOffset = Helper.nonNull(options.timeOffset, audioObject.timeOffset, 0);
this.channels[channel] = audioObject;
this._update(channel);
return this.channels[channel];
}
play(channel, audioOrOptions) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
if (Helper.isNull(audioOrOptions)) {
audioOrOptions = {};
} else if (!(typeof audioOrOptions === "object")) {
audioOrOptions = {
audio: audioOrOptions
};
}
audioOrOptions.timeOffset = Helper.nonNull(audioOrOptions.timeOffset, 0);
this.stop(channel);
this.set(audioOrOptions, channel);
// this._update(channel);
if (!this.channels[channel].muted) {
this.channels[channel].audio.play();
}
return this.channels[channel];
}
stop(channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
let oldAudio = this.channels[channel];
if (oldAudio != null) {
oldAudio.audio.pause();
}
}
_update(channel) {
let audioObject = this.channels[channel];
audioObject.audio.currentTime = Helper.nonNull(audioObject.timeOffset, audioObject.audio.currentTime);
audioObject.audio.loop = Helper.nonNull(audioObject.loop, audioObject.audio.loop);
audioObject.audio.volume = Helper.nonNull(audioObject.volume, audioObject.audio.volume);
if (audioObject.muted) {
this.stop(channel);
}
}
get(channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
return this.channels[channel];
}
}
SoundManager.CHANNELS = {
MUSIC: "music",
SOUND: "sound",
DEFAULT: "default"
};
class Code {
constructor(args) {
if (typeof args === "string") {
@ -4792,6 +4911,35 @@ WordRotatorDb.OBJECT_STORE = {
};
WordRotatorDb.instance = null;
class TemplateContainer{
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate){
this.leafTemplate = leafTemplate;
this.parentTemplate = parentTemplate;
this.rowTemplate = rowTemplate;
this.triangleTemplate = triangleTemplate;
}
copyLeafTemplate()
{
return Helper.cloneNode(this.leafTemplate);
}
copyParentTemplate()
{
return Helper.cloneNode(this.parentTemplate);
}
copyRowTemplate()
{
return Helper.cloneNode(this.rowTemplate);
}
copyTriangleTemplate()
{
return Helper.cloneNode(this.triangleTemplate);
}
}
class Segment{
constructor(element){
this.rotation = 0;
@ -4853,6 +5001,29 @@ class Segment{
}
}
class LeafSegment extends Segment {
constructor(element, leaf) {
super(element);
this.leaf = 'A';
if (Helper.isNotNull(leaf)) {
this.setLeaf(leaf);
}
}
sameAs(otherSegment) {
return (otherSegment instanceof LeafSegment && otherSegment.leaf === this.leaf);
}
setLeaf(leaf) {
this.leaf = leaf;
}
_updateElement() {
this.element.querySelector(".leaf-element").removeAllChildren().appendChild(document.createTextNode(this.leaf));
}
}
class ParentSegment extends Segment {
static initListener() {
window.addEventListener("mousedown", (e) => {
@ -5056,58 +5227,6 @@ class ParentSegment extends Segment {
ParentSegment.initListener();
class LeafSegment extends Segment {
constructor(element, leaf) {
super(element);
this.leaf = 'A';
if (Helper.isNotNull(leaf)) {
this.setLeaf(leaf);
}
}
sameAs(otherSegment) {
return (otherSegment instanceof LeafSegment && otherSegment.leaf === this.leaf);
}
setLeaf(leaf) {
this.leaf = leaf;
}
_updateElement() {
this.element.querySelector(".leaf-element").removeAllChildren().appendChild(document.createTextNode(this.leaf));
}
}
class TemplateContainer{
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate){
this.leafTemplate = leafTemplate;
this.parentTemplate = parentTemplate;
this.rowTemplate = rowTemplate;
this.triangleTemplate = triangleTemplate;
}
copyLeafTemplate()
{
return Helper.cloneNode(this.leafTemplate);
}
copyParentTemplate()
{
return Helper.cloneNode(this.parentTemplate);
}
copyRowTemplate()
{
return Helper.cloneNode(this.rowTemplate);
}
copyTriangleTemplate()
{
return Helper.cloneNode(this.triangleTemplate);
}
}
class Level {
constructor(templateContainer) {
this.rootSegment = null;
@ -5636,16 +5755,10 @@ class LevelSite extends WordRotatorBaseSite {
this.wonParams = {
aborted: false,
coinCounterTimer: null,
audio: new Audio()
};
this.wonParams.audioPromise = Promise.race([new Promise(resolve => {
this.wonParams.audio.addEventListener('loadeddata', resolve);
}),
new Promise(resolve => {
this.wonParams.audio.addEventListener('error', resolve);
})
]);
this.wonParams.audio.src = Helper.basePath("sound/single_coin_fall_on_concrete_.mp3");
let soundManager = SoundManager.getInstance();
soundManager.set("sound/single_coin_fall_on_concrete_.mp3", SoundManager.CHANNELS.SOUND);
return super.onConstruct(args);
}
@ -5825,15 +5938,17 @@ class LevelSite extends WordRotatorBaseSite {
let coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"));
localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel));
let soundManager = SoundManager.getInstance();
let audioOptions = soundManager.get(SoundManager.CHANNELS.SOUND);
let coinPromise = Promise.all([new Promise((r) => {
setTimeout(() => {
r(continueButton.fadeIn());
}, 500);
}), this.wonParams.audioPromise]);
}), audioOptions.loadedPromise.catch(e => {console.error(e);})]);
this.wonParams.aborted = false;
let audio = this.wonParams.audio;
for (let i = 0; i < coinsPerLevel; i++) {
let coinElem = Helper.cloneNode(this.coinTemplate);
this.coinContainer.appendChild(coinElem);
@ -5843,11 +5958,7 @@ class LevelSite extends WordRotatorBaseSite {
if (!this.wonParams.aborted) {
coinElem.fadeIn(timeout / 1000);
if (audio !== null) {
audio.pause();
audio.currentTime = 0;
audio.play();
}
soundManager.play(SoundManager.CHANNELS.SOUND);
this.wonParams.coinCounterTimer = setTimeout(() => {
if (!this.wonParams.aborted) {
@ -5931,7 +6042,6 @@ class MenuSite extends WordRotatorBaseSite {
level.createSegments();
level.getWonPromise().then(() => {
console.log("won!");
this.startSite(LevelSite);
});
@ -5964,6 +6074,7 @@ class MenuSite extends WordRotatorBaseSite {
if (index === indexBlocked) {
index = (index + 1) % rotationsSegments.length;
}
rotationsSegments[index].rotate();
randomRotationFunction();
}, timeout);
@ -5984,7 +6095,7 @@ class MenuSite extends WordRotatorBaseSite {
playButton.style.width = levelStyle.getPropertyValue("width");
scaleHelper.scaleToFull(playButton.children[0], playButton, null, null, null, null, null, false);
await scaleHelper.scaleTo(0.15, levelNumber.parentElement, levelNumber.parentElement.parentElement, null, null, null, 10, null, false);
await scaleHelper.scaleTo(0.17, levelNumber.parentElement, levelNumber.parentElement.parentElement, null, null, null, 10, null, false);
scaleHelper.scaleToFull(levelNumber, levelNumber.parentElement, false, false, 8, null, null, false);
};
@ -6173,6 +6284,9 @@ LoginSite.addLoginAction = false;
InitPromise.resolve(app).then(function(){
SettingsSite.settingsAction.showFor = MenuAction.SHOW_ALWAYS;
let soundManager = SoundManager.getInstance();
soundManager.play(SoundManager.CHANNELS.MUSIC, {audio: "sound/brightAndBeautifull__.mp3", loop: true, volume: 0.3});
app.start(SynchronizeSite);
Translator.setLanguage("de");
});

Binary file not shown.

View File

@ -23,6 +23,7 @@ applyPolyfills();
import {WordRotatorSettingFragment} from "../module/Application/pwa/js/Fragment/WordRotatorSettingFragment";
import './settings'
import {SoundManager} from "./lib/pwa-assets";
ThemeManager.addTheme(new Theme('red', ''));
ThemeManager.addTheme(new Theme("blue", "blue"));
@ -57,6 +58,9 @@ LoginSite.addLoginAction = false;
InitPromise.resolve(app).then(function(){
SettingsSite.settingsAction.showFor = MenuAction.SHOW_ALWAYS;
let soundManager = SoundManager.getInstance();
soundManager.play(SoundManager.CHANNELS.MUSIC, {audio: "sound/brightAndBeautifull__.mp3", loop: true, volume: 0.3});
app.start(SynchronizeSite);
Translator.setLanguage("de");
});

View File

@ -109,6 +109,123 @@ class ScaleHelper {
}
}
class SoundManager {
static getInstance() {
if (Helper.isNull(SoundManager.instance)) {
SoundManager.instance = new SoundManager();
}
return SoundManager.instance;
}
constructor() {
this.channels = {};
}
set(options, channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
let audioObject = Helper.nonNull(this.channels[channel], {});
if (typeof options === "string") {
options = {audio: options};
}
let audio = options.audio;
if (Helper.isNotNull(audio)) {
let src = null;
if (typeof audio === "string") {
src = audio;
audio = new Audio();
audioObject.loadedPromise = new Promise((resolve, reject) => {
audio.addEventListener("loadeddata", () => {
resolve();
});
audio.addEventListener("error", (e) => {
console.warn(e);
reject(e);
});
});
audio.src = Helper.basePath(src);
}
else {
audioObject.loadedPromise = Promise.resolve();
}
this.stop(channel);
audioObject.audio = audio;
// audio.addEventListener('timeupdate', () => {
// let buffer = 10;
// if (this.channels[channel].audio === audio && this.channels[channel].loop) {
// if (audio.currentTime > audio.duration - buffer) {
// console.log("reset");
// audio.currentTime = 0;
// audio.play();
// }
// }
// }, false);
}
audioObject.muted = Helper.nonNull(options.muted, audioObject.muted, false);
audioObject.volume = Helper.nonNull(options.volume, audioObject.volume, 1);
audioObject.loop = Helper.nonNull(options.loop, audioObject.loop, false);
audioObject.timeOffset = Helper.nonNull(options.timeOffset, audioObject.timeOffset, 0);
this.channels[channel] = audioObject;
this._update(channel);
return this.channels[channel];
}
play(channel, audioOrOptions) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
if (Helper.isNull(audioOrOptions)) {
audioOrOptions = {};
} else if (!(typeof audioOrOptions === "object")) {
audioOrOptions = {
audio: audioOrOptions
};
}
audioOrOptions.timeOffset = Helper.nonNull(audioOrOptions.timeOffset, 0);
this.stop(channel);
this.set(audioOrOptions, channel);
// this._update(channel);
if (!this.channels[channel].muted) {
this.channels[channel].audio.play();
}
return this.channels[channel];
}
stop(channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
let oldAudio = this.channels[channel];
if (oldAudio != null) {
oldAudio.audio.pause();
}
}
_update(channel) {
let audioObject = this.channels[channel];
audioObject.audio.currentTime = Helper.nonNull(audioObject.timeOffset, audioObject.audio.currentTime);
audioObject.audio.loop = Helper.nonNull(audioObject.loop, audioObject.audio.loop);
audioObject.audio.volume = Helper.nonNull(audioObject.volume, audioObject.audio.volume);
if (audioObject.muted) {
this.stop(channel);
}
}
get(channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
return this.channels[channel];
}
}
SoundManager.CHANNELS = {
MUSIC: "music",
SOUND: "sound",
DEFAULT: "default"
};
class TabbedFragment extends Fragment {
constructor(site) {
super(site, 'pwaAssets/html/fragment/tabbedFragment.html');
@ -174,4 +291,4 @@ class TabbedFragment extends Fragment {
}
}
export { DelayPromise, RotateHelper, ScaleHelper, TabbedFragment };
export { DelayPromise, RotateHelper, ScaleHelper, SoundManager, TabbedFragment };

View File

@ -872,10 +872,12 @@ class Helper {
}
static nonNull(val1, val2) {
if (Helper.isNotNull(val1)) {
return val1;
for (let i = 0; i < arguments.length; i++) {
if (Helper.isNotNull(arguments[i])) {
return arguments[i];
}
}
return val2;
return null;
}
static notEmpty(value) {

View File

@ -1,11 +1,8 @@
import {FlashMessenger, Helper, Menu, MenuAction, SystemSettings} from "../../../../../js/lib/pwa-lib";
import {ParentSegment} from "../wordrotator/Segment/ParentSegment";
import {LeafSegment} from "../wordrotator/Segment/LeafSegment";
import {TemplateContainer} from "../wordrotator/Segment/TemplateContainer";
import {SimpleLevel} from "../wordrotator/Level/SimpleLevel";
import {LevelHelper} from "../wordrotator/Level/LevelHelper";
import {WordRotatorDb} from "../WordRotatorDb";
import {ScaleHelper} from "../../../../../js/lib/pwa-assets";
import {ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-assets";
import {EndSite} from "./EndSite";
import {WordRotatorBaseSite} from "./WordRotatorBaseSite";
@ -34,16 +31,10 @@ export class LevelSite extends WordRotatorBaseSite {
this.wonParams = {
aborted: false,
coinCounterTimer: null,
audio: new Audio()
};
this.wonParams.audioPromise = Promise.race([new Promise(resolve => {
this.wonParams.audio.addEventListener('loadeddata', resolve);
}),
new Promise(resolve => {
this.wonParams.audio.addEventListener('error', resolve);
})
]);
this.wonParams.audio.src = Helper.basePath("sound/single_coin_fall_on_concrete_.mp3");
let soundManager = SoundManager.getInstance();
soundManager.set("sound/single_coin_fall_on_concrete_.mp3", SoundManager.CHANNELS.SOUND);
return super.onConstruct(args);
}
@ -223,15 +214,17 @@ export class LevelSite extends WordRotatorBaseSite {
let coinsBefore = parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"));
localStorage.setItem("coins", coinsBefore + parseInt(coinsPerLevel));
let soundManager = SoundManager.getInstance();
let audioOptions = soundManager.get(SoundManager.CHANNELS.SOUND);
let coinPromise = Promise.all([new Promise((r) => {
setTimeout(() => {
r(continueButton.fadeIn());
}, 500)
}), this.wonParams.audioPromise]);
}), audioOptions.loadedPromise.catch(e => {console.error(e)})]);
this.wonParams.aborted = false;
let audio = this.wonParams.audio;
for (let i = 0; i < coinsPerLevel; i++) {
let coinElem = Helper.cloneNode(this.coinTemplate);
this.coinContainer.appendChild(coinElem);
@ -241,11 +234,7 @@ export class LevelSite extends WordRotatorBaseSite {
if (!this.wonParams.aborted) {
coinElem.fadeIn(timeout / 1000);
if (audio !== null) {
audio.pause();
audio.currentTime = 0;
audio.play();
}
soundManager.play(SoundManager.CHANNELS.SOUND);
this.wonParams.coinCounterTimer = setTimeout(() => {
if (!this.wonParams.aborted) {

View File

@ -52,6 +52,7 @@ export class MenuSite extends WordRotatorBaseSite {
if (index === indexBlocked) {
index = (index + 1) % rotationsSegments.length;
}
rotationsSegments[index].rotate();
randomRotationFunction();
}, timeout);
@ -72,7 +73,7 @@ export class MenuSite extends WordRotatorBaseSite {
playButton.style.width = levelStyle.getPropertyValue("width");
scaleHelper.scaleToFull(playButton.children[0], playButton, null, null, null, null, null, false);
await scaleHelper.scaleTo(0.15, levelNumber.parentElement, levelNumber.parentElement.parentElement, null, null, null, 10, null, false);
await scaleHelper.scaleTo(0.17, levelNumber.parentElement, levelNumber.parentElement.parentElement, null, null, null, 10, null, false);
scaleHelper.scaleToFull(levelNumber, levelNumber.parentElement, false, false, 8, null, null, false);
};

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
import { Selector } from 'testcafe';
import {loadLastLevelTest, mainTest} from "./test";
fixture `betaPlay`
.page `http://beta.wordrotator.silas.link`
.httpAuth({
username: 'admin',
password: '20luxl200'
});
test('Play', async t => {
await t.wait(20000);
await mainTest(t);
});
test('LoadLastLevel', async t => {
await t.wait(20000);
await loadLastLevelTest(t);
});

File diff suppressed because it is too large Load Diff

View File

@ -1,298 +0,0 @@
import { Selector } from 'testcafe';
export async function mainTest(t){
const coinsPerLevel = 5;
const dragDimen = 250;
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
};
await t
//Main Menu
.click(Selector('#play-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")
.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))
.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(Selector('.segment.segment-parent.rotate-360').nth(1).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.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)
//TWOLevel
.expect(Selector('.segment.segment-parent.rotate-270').nth(0).textContent).eql("BOAL")
.expect(Selector('.segment.segment-parent.rotate-180').textContent).eql("DEAR")
.expect(Selector('.segment.segment-parent.rotate-360').textContent).eql("NSMR")
.expect(Selector('.segment.segment-parent.rotate-270').nth(1).textContent).eql("EEUF")
.expect(Selector('.segment.segment-parent.rotate-270').nth(0).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.expect(Selector('.segment.segment-parent.rotate-180').getStyleProperty('transform')).eql("matrix(-1, 0, 0, -1, 0, 0)")
.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('#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(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.click(Selector('.segment-parent').nth(SEGMENT.TWO))
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.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)
//THREE Level
.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).eql(""+coinsPerLevel*3)
//4. Level
.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("BEHE")
.expect(Selector('.segment-parent').nth(SEGMENT.SEVEN).textContent).eql("RARZ")
.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("IKDEERNZTULANGND")
.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("TULA")
.expect(Selector('.segment-parent').nth(SEGMENT.FOURTEEN).textContent).eql("NGND")
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, 4, {
offsetX: 54,
offsetY: 17
})
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), dragDimen, 3, {
offsetX: 54,
offsetY: 17
})
.drag(Selector('.segment-parent').nth(SEGMENT.TEN).find('div').withText('I'), dragDimen, 4, {
offsetX: 27,
offsetY: 41
})
.drag(Selector('.segment-parent').nth(SEGMENT.ONE).find('div').withText('S'), 10, dragDimen, {
offsetX: 64,
offsetY: 32
})
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, 4, {
offsetX: 27,
offsetY: 41
})
.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).eql(""+coinsPerLevel*4)
//5. Level
.expect(Selector('#level-number').textContent).eql("5")
.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)")
.expect(Selector('.segment-parent').nth(SEGMENT.SIX).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.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).find('div').withText('U'), 3, dragDimen, {
offsetX: 69,
offsetY: 150
})
.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))
.drag(Selector('.segment-parent').nth(SEGMENT.SIX), 3, dragDimen, {
offsetX: 86,
offsetY: 133
})
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.FOUR))
.click(Selector('.segment-parent').nth(SEGMENT.SEVEN))
.drag(Selector('.segment-parent').nth(SEGMENT.SIX), 10, dragDimen, {
offsetX: 60,
offsetY: 137
})
.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)
//Level 6
.expect(Selector('#level-number').textContent).eql("6")
.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)")
.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: 33,
offsetY: 18
})
.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).find('div').withText('P'), dragDimen, -3, {
offsetX: 22,
offsetY: 16
})
.expect(Selector('div').withText('P').nth(11).find('.segment.segment-parent.layer-2.rotate-360').getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.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)
//Level 7
.expect(Selector('.segment-parent').nth(SEGMENT.SIX).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.expect(Selector('.segment-row > .child-container').childElementCount).eql(3)
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
offsetX: 50,
offsetY: 73
})
.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: 55,
offsetY: 57
})
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
offsetX: 50,
offsetY: 73
})
.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.THIRTEEN))
.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: 55,
offsetY: 57
})
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
offsetX: 50,
offsetY: 73
})
// .click(Selector('.segment-parent').nth(SEGMENT.THIRTEEN))
.click(Selector('#help-button'))
.wait(5000)
.expect(Selector('.coin-counter').innerText).eql(""+(coinsPerLevel*7-helpCost))
.expect(Selector('#won-text').visible).eql(true)
.expect(Selector('#continue-button').visible).eql(true)
.click(Selector('#continue-button'))
.expect(Selector('#site-content').childElementCount).eql(1);
}
export async function beforeLoadLastLevelTest(){
}
export async function loadLastLevelTest(t){
}

View File

@ -1,10 +1,28 @@
import {Selector} from 'testcafe';
import {ClientFunction} from 'testcafe';
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();
}
let isLocal = true;
if (isLocal) {
fixture`Play`
.page`https://127.0.0.1/pwa/wordRotator/publicTest/`;
.page`https://127.0.0.1/pwa/wordRotator/publicTest/`.beforeEach(async t => {
await beforeEachTest(t);
});
}
else {
fixture`betaPlay`
@ -13,12 +31,11 @@ else {
username: 'admin',
password: '20luxl200'
}).beforeEach(async t => {
await beforeEachTest(t);
await t.wait(20000);
});
}
const testLocalStorageSet = ClientFunction((key, value) => { localStorage.setItem(key, value)});
const coinsPerLevel = 5;
const dragDimen = 250;
const helpCost = 25;
@ -308,12 +325,48 @@ test('Play', async t => {
.expect(Selector('#site-content').childElementCount).eql(1);
});
test('LoadLastLevel', async t => {
// await t.debug();
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)")
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).getStyleProperty('transform')).eql("matrix(1, 0, 0, 1, 0, 0)")
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
// .debug()
}).before(async t => {
// await t.
await testLocalStorageSet("currentLevel", "{\"id\":15,\"rotations\":[0,0,270],\"locks\":[false,true,true]}");
});
test('LevelRotation', async t => {
await 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)")
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.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("ARCH")
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("CHAR")
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("IVME");
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))
.wait(4000)
.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))
.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("ARCH")
.expect(Selector('.segment-parent').nth(SEGMENT.TWO).textContent).eql("CHAR")
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("IVME");
}).before(async t => {
await replaceRandom([0.9, 0.5]);
});