|
| 1 | +/** |
| 2 | + * Copyright 2022 Design Barn Inc. |
| 3 | + */ |
| 4 | + |
| 5 | +import Lottie from "lottie-web"; |
| 6 | + |
| 7 | +context("Player controls", () => { |
| 8 | + beforeEach(() => { |
| 9 | + cy.visit("http://localhost:8080/controls"); |
| 10 | + }); |
| 11 | + |
| 12 | + it("clicks on play button and verifies animation is playing", function (done) { |
| 13 | + cy.wait(2000); |
| 14 | + cy.get("#container-one .lf-player-btn").eq(0).click({force: true}); |
| 15 | + |
| 16 | + cy.window().then( (win) => { |
| 17 | + if (!win.lottie.getRegisteredAnimations()[0].isPaused) |
| 18 | + done(); |
| 19 | + }); |
| 20 | + }); |
| 21 | + |
| 22 | + it("clicks on pause button and verifies animation is paused", function (done) { |
| 23 | + cy.wait(2000); |
| 24 | + cy.get("#container-two .lf-player-btn").eq(0).click({force: true}); |
| 25 | + |
| 26 | + cy.window().then( (win) => { |
| 27 | + if (win.lottie.getRegisteredAnimations()[1].isPaused) |
| 28 | + done(); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + it("clicks on stop button and verififes animation is stopped and at frame 0", function (done) { |
| 33 | + cy.wait(2000); |
| 34 | + cy.get("#container-three .lf-player-btn").eq(1).click({force: true}); |
| 35 | + |
| 36 | + cy.window().then( (win) => { |
| 37 | + if (win.lottie.getRegisteredAnimations()[2].isPaused && |
| 38 | + win.lottie.getRegisteredAnimations()[2].currentFrame === 0) |
| 39 | + done(); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + it("clicks on loop button and verififes animation loops", function (done) { |
| 44 | + cy.get("#container-four .lf-player-btn").eq(2).click(); |
| 45 | + |
| 46 | + cy.wait(3000); |
| 47 | + cy.window().then( (win) => { |
| 48 | + if (!win.lottie.getRegisteredAnimations()[3].loop || win.lottie.getRegisteredAnimations()[3].playCount > 1) |
| 49 | + done(); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + it.skip("clicks on color background choice and verifies background color", function () { |
| 54 | + cy.get("#player-five #lottie-controls").find("#lottie-bg-picker-button").click(); |
| 55 | + cy.get("#player-five #lottie-controls").find("#lottie-color-choice-4").click(); |
| 56 | + cy.get("#player-five lottie-player") |
| 57 | + .should("have.css", "background-color") |
| 58 | + .and("eq", "rgb(58, 146, 218)"); |
| 59 | + }); |
| 60 | +}); |
0 commit comments