Test angepasst
This commit is contained in:
parent
895cb36fea
commit
be130a99e8
@ -2,26 +2,34 @@ import {Selector} from 'testcafe';
|
||||
import {ClientFunction} from 'testcafe';
|
||||
|
||||
const goBack = ClientFunction(() => window.history.back());
|
||||
const testLocalStorageSet = ClientFunction((key, value) => { localStorage.setItem(key, value)});
|
||||
const testLocalStorageSet = ClientFunction((key, value) => {
|
||||
localStorage.setItem(key, value)
|
||||
});
|
||||
const replaceRandom = ClientFunction((sequence) => {
|
||||
window.index = 0;
|
||||
window.sequence =sequence;
|
||||
window.Math.random = function(){
|
||||
window.sequence = sequence;
|
||||
window.Math.random = function () {
|
||||
let res = sequence[window.index];
|
||||
window.index = (window.index+1)%sequence.length;
|
||||
window.index = (window.index + 1) % sequence.length;
|
||||
return res;
|
||||
}
|
||||
});
|
||||
|
||||
async function beforeEachTest(t){
|
||||
async function beforeEachTest(t) {
|
||||
// await replaceRandom();
|
||||
}
|
||||
|
||||
let isLocal = false;
|
||||
async function afterEachTest(t) {
|
||||
return await t.eval(() => indexedDB.deleteDatabase('wordRotator'));
|
||||
}
|
||||
|
||||
let isLocal = true;
|
||||
if (isLocal) {
|
||||
fixture`Play`
|
||||
.page`https://127.0.0.1/pwa/wordRotator/publicTest/`.beforeEach(async t => {
|
||||
await beforeEachTest(t);
|
||||
}).afterEach(async t => {
|
||||
await afterEachTest(t);
|
||||
});
|
||||
}
|
||||
else {
|
||||
@ -31,8 +39,10 @@ else {
|
||||
username: 'admin',
|
||||
password: '20luxl200'
|
||||
}).beforeEach(async t => {
|
||||
await beforeEachTest(t);
|
||||
await t.wait(20000);
|
||||
await beforeEachTest(t);
|
||||
await t.wait(20000);
|
||||
}).afterEach(async t => {
|
||||
await afterEachTest(t);
|
||||
});
|
||||
}
|
||||
|
||||
@ -46,9 +56,9 @@ const SEGMENT = {
|
||||
THREE: 2,
|
||||
FOUR: 3,
|
||||
FIVE: 4,
|
||||
SIX : 5,
|
||||
SIX: 5,
|
||||
SEVEN: 6,
|
||||
EIGHT : 7,
|
||||
EIGHT: 7,
|
||||
NINE: 8,
|
||||
TEN: 9,
|
||||
ELEVEN: 10,
|
||||
@ -58,10 +68,10 @@ const SEGMENT = {
|
||||
FIFTEEN: 14,
|
||||
SIXTEEN: 15,
|
||||
SEVENTEEN: 16,
|
||||
EIGHTEEN:17,
|
||||
EIGHTEEN: 17,
|
||||
NINETEEN: 18,
|
||||
TWENTY:19,
|
||||
TWENTYONE:20
|
||||
TWENTY: 19,
|
||||
TWENTYONE: 20
|
||||
};
|
||||
|
||||
test('Play', async t => {
|
||||
@ -88,7 +98,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)
|
||||
|
||||
//TWOLevel
|
||||
.expect(Selector('.segment.segment-parent.rotate-270').nth(0).textContent).eql("BOAL")
|
||||
@ -112,7 +122,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 * 2)
|
||||
|
||||
//THREE Level
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("ZEHO")
|
||||
@ -129,7 +139,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 * 3)
|
||||
|
||||
//4. Level
|
||||
.expect(Selector('.segment-parent').nth(SEGMENT.ONE).textContent).eql("FERÜINCKPHREYSSI")
|
||||
@ -159,7 +169,7 @@ test('Play', async t => {
|
||||
offsetY: 41
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE).find('div').withText('S'), 10, dragDimen, {
|
||||
offsetX: 64,
|
||||
offsetX: dragDimen,
|
||||
offsetY: 32
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, 4, {
|
||||
@ -185,7 +195,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*4)
|
||||
.expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 4)
|
||||
|
||||
//5. Level
|
||||
.expect(Selector('#level-number').textContent).eql("5")
|
||||
@ -205,21 +215,21 @@ test('Play', async t => {
|
||||
.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
|
||||
})
|
||||
// .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
|
||||
})
|
||||
// .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)
|
||||
.expect(Selector('.coin-counter').innerText).eql("" + coinsPerLevel * 5)
|
||||
|
||||
|
||||
//Level 6
|
||||
@ -271,7 +281,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 * 6)
|
||||
|
||||
|
||||
//Level 7
|
||||
@ -282,18 +292,17 @@ test('Play', async t => {
|
||||
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,
|
||||
offsetX: dragDimen,
|
||||
offsetY: 57
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
|
||||
offsetX: 50,
|
||||
offsetY: 73
|
||||
})
|
||||
// .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))
|
||||
@ -307,17 +316,17 @@ test('Play', async t => {
|
||||
.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,
|
||||
offsetX: dragDimen,
|
||||
offsetY: 57
|
||||
})
|
||||
.drag(Selector('.segment-parent').nth(SEGMENT.ONE), 4, dragDimen, {
|
||||
offsetX: 50,
|
||||
offsetY: 73
|
||||
})
|
||||
// .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('.coin-counter').innerText).eql("" + (coinsPerLevel * 7 - helpCost))
|
||||
|
||||
.expect(Selector('#won-text').visible).eql(true)
|
||||
.expect(Selector('#continue-button').visible).eql(true)
|
||||
@ -331,7 +340,7 @@ test('LoadLastLevel', async t => {
|
||||
.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()
|
||||
// .debug()
|
||||
}).before(async t => {
|
||||
await testLocalStorageSet("currentLevel", "{\"id\":15,\"rotations\":[0,0,270],\"locks\":[false,true,true]}");
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user