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();
}

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 {
    fixture`betaPlay`
        .page`http://beta.wordrotator.silas.link`
        .httpAuth({
            username: 'admin',
            password: '20luxl200'
        }).beforeEach(async t => {
        await beforeEachTest(t);
        await t.wait(20000);
    }).afterEach(async t => {
        await afterEachTest(t);
    });
}

const extraCoins = 50;
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
};

test('Play', async t => {
    let levelNumber = 1;

    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'));

    levelNumber++;
    //first Level
    await t.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("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))
        .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 * levelNumber + extraCoins - helpCost));

    levelNumber++;

    //TWOLevel
    await t.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("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(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 * 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).eql("" + (coinsPerLevel * levelNumber + extraCoins - helpCost));

    levelNumber++;
    // .click(Selector())
    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("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: dragDimen,
            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 * 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(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 * 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(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 * levelNumber + extraCoins - helpCost));

    levelNumber++;
        //Level 7
        await t.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: dragDimen,
            offsetY: 57
        })
        .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: dragDimen,
            offsetY: 57
        })
        .click(Selector('#help-button'))
        .wait(5000)
        .expect(Selector('.coin-counter').innerText).eql("" + (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('#site-content').childElementCount).eql(1);
});
test('LoadLastLevel', async 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)")
        .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)")
}).before(async t => {
    await testLocalStorageSet("currentLevel", "{\"id\":15,\"rotations\":[0,0,270],\"locks\":[false,true,true]}");
});

test.only('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(3750)
        .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("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))
        .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("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.9, 0.5]);
});