From 2f174aa5cbda58f4a22e659a02ddb0c4f37b6495 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Tue, 21 Apr 2020 14:07:08 +1200 Subject: [PATCH] Add e2e tests for increase, decrease, and reset font size --- tests/e2e/specs/userprofile.js | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/e2e/specs/userprofile.js b/tests/e2e/specs/userprofile.js index eda150b9f3..5c48b71298 100644 --- a/tests/e2e/specs/userprofile.js +++ b/tests/e2e/specs/userprofile.js @@ -1,3 +1,9 @@ +import { + getCurrentFontSize, + expectedFontSize, + INITIAL_FONT_SIZE +} from '@/utils/font-size' + describe('User Profile', () => { it('Visits the user profile', () => { cy.visit('/#/user-profile') @@ -9,4 +15,44 @@ describe('User Profile', () => { .should('be.visible') .should('be.disabled') }) + it('Increases the font size', () => { + cy.visit('/#/user-profile') + expect(INITIAL_FONT_SIZE).to.be.equal(getCurrentFontSize()) + const clicks = 3 + const expectedNewSize = expectedFontSize(true, clicks) + for (let i = 0; i < clicks; i++) { + cy + .get('#increase-font-size-button') + .click() + } + expect(expectedNewSize).to.be.equal(getCurrentFontSize()) + }) + it('Decreases the font size', () => { + cy.visit('/#/user-profile') + expect(INITIAL_FONT_SIZE).to.be.equal(getCurrentFontSize()) + const clicks = 3 + const expectedNewSize = expectedFontSize(false, clicks) + for (let i = 0; i < clicks; i++) { + cy + .get('#decrease-font-size-button') + .click() + } + expect(expectedNewSize).to.be.equal(getCurrentFontSize()) + }) + it('Resets the font size', () => { + cy.visit('/#/user-profile') + expect(INITIAL_FONT_SIZE).to.be.equal(getCurrentFontSize()) + const clicks = 3 + const expectedNewSize = expectedFontSize(false, clicks) + for (let i = 0; i < clicks; i++) { + cy + .get('#decrease-font-size-button') + .click() + } + expect(expectedNewSize).to.be.equal(getCurrentFontSize()) + cy + .get('#reset-font-size-button') + .click() + expect(INITIAL_FONT_SIZE).to.be.equal(getCurrentFontSize()) + }) })