|
| 1 | +/** |
| 2 | + * Copyright 2022 Design Barn Inc. |
| 3 | + */ |
| 4 | + |
| 5 | +context("Player controls", () => { |
| 6 | + beforeEach(() => { |
| 7 | + cy.visit("http://localhost:8080/controls"); |
| 8 | + }); |
| 9 | + |
| 10 | + it("clicks on play button and verifies animation is playing", function (done) { |
| 11 | + cy.get("#player-one lottie-player").then(($el) => { |
| 12 | + const playerOne = $el.get(0); |
| 13 | + |
| 14 | + playerOne.addEventListener("play", () => { |
| 15 | + expect(playerOne.currentState).to.eq("playing"); |
| 16 | + done(); |
| 17 | + }, { once: true }); |
| 18 | + }); |
| 19 | + |
| 20 | + cy.get("#player-one").find("#lottie-play-button").click(); |
| 21 | + }); |
| 22 | + |
| 23 | + it("clicks on pause button and verifies animation is paused", function (done) { |
| 24 | + cy.get("#player-two lottie-player").then(($el) => { |
| 25 | + const playerTwo = $el.get(0); |
| 26 | + |
| 27 | + playerTwo.addEventListener("pause", () => { |
| 28 | + expect(playerTwo.currentState).to.eq("paused"); |
| 29 | + done(); |
| 30 | + }); |
| 31 | + }); |
| 32 | + cy.get("#player-two").find("#lottie-pause-button").click(); |
| 33 | + }); |
| 34 | + |
| 35 | + it("clicks on stop button and verififes animation is stopped and at frame 0", function (done) { |
| 36 | + cy.get("#player-three lottie-player").then(($el) => { |
| 37 | + const playerThree = $el.get(0); |
| 38 | + |
| 39 | + playerThree.addEventListener("stop", () => { |
| 40 | + expect(playerThree.currentState).to.eq("stopped"); |
| 41 | + expect(playerThree.getLottie().currentFrame).to.eq(0); |
| 42 | + done(); |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + cy.get("#player-three").find("#lottie-stop-button").click(); |
| 47 | + }); |
| 48 | + |
| 49 | + it("clicks on loop button and verififes animation loops", function (done) { |
| 50 | + cy.get("#player-four #lottie-controls").find("#lottie-toogle-loop-button").click(); |
| 51 | + cy.get("#player-four lottie-player").then(($el) => { |
| 52 | + const playerFour = $el.get(0); |
| 53 | + |
| 54 | + expect(playerFour.loop).to.eq(true); |
| 55 | + done(); |
| 56 | + }); |
| 57 | + }); |
| 58 | + |
| 59 | + it("clicks on color background choice and verifies background color", function () { |
| 60 | + cy.get("#player-five #lottie-controls").find("#lottie-bg-picker-button").click(); |
| 61 | + cy.get("#player-five #lottie-controls").find("#lottie-color-choice-4").click(); |
| 62 | + cy.get("#player-five lottie-player") |
| 63 | + .should("have.css", "background-color") |
| 64 | + .and("eq", "rgb(58, 146, 218)"); |
| 65 | + }); |
| 66 | +}); |
0 commit comments