From 9b4efc773b9036d4d97b7600b973da92ee375b0b Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 7 Jul 2021 10:19:37 +0200 Subject: [PATCH] Fix home page tests --- cypress/integration/misc/home.spec.js | 35 +++++++++++++++++++ cypress/integration/user/login.spec.js | 1 + cypress/integration/user/registration.spec.js | 1 + 3 files changed, 37 insertions(+) create mode 100644 cypress/integration/misc/home.spec.js diff --git a/cypress/integration/misc/home.spec.js b/cypress/integration/misc/home.spec.js new file mode 100644 index 00000000..82cbeed2 --- /dev/null +++ b/cypress/integration/misc/home.spec.js @@ -0,0 +1,35 @@ +import '../../support/authenticateUser' + +const setHours = hours => { + const date = new Date() + date.setHours(hours) + cy.clock(+date) +} + +describe('Home Page', () => { + it('shows the right salutation in the night', () => { + setHours(4) + cy.visit('/') + cy.get('h2').should('contain', 'Good Night') + }) + it('shows the right salutation in the morning', () => { + setHours(8) + cy.visit('/') + cy.get('h2').should('contain', 'Good Morning') + }) + it('shows the right salutation in the day', () => { + setHours(13) + cy.visit('/') + cy.get('h2').should('contain', 'Hi') + }) + it('shows the right salutation in the night', () => { + setHours(20) + cy.visit('/') + cy.get('h2').should('contain', 'Good Evening') + }) + it('shows the right salutation in the night again', () => { + setHours(23) + cy.visit('/') + cy.get('h2').should('contain', 'Good Night') + }) +}) \ No newline at end of file diff --git a/cypress/integration/user/login.spec.js b/cypress/integration/user/login.spec.js index d1cde64e..ce6086ce 100644 --- a/cypress/integration/user/login.spec.js +++ b/cypress/integration/user/login.spec.js @@ -34,6 +34,7 @@ context('Login', () => { cy.get('input[id=password]').type(fixture.password) cy.get('.button').contains('Login').click() cy.url().should('include', '/') + cy.clock(1625656161057) // 13:00 cy.get('h2').should('contain', `Hi ${fixture.username}!`) }) diff --git a/cypress/integration/user/registration.spec.js b/cypress/integration/user/registration.spec.js index 37c238e3..3e7cf1f5 100644 --- a/cypress/integration/user/registration.spec.js +++ b/cypress/integration/user/registration.spec.js @@ -28,6 +28,7 @@ context('Registration', () => { cy.get('#password2').type(fixture.password) cy.get('#register-submit').click() cy.url().should('include', '/') + cy.clock(1625656161057) // 13:00 cy.get('h2').should('contain', `Hi ${fixture.username}!`) })