From ff9e9c15fce181b1d9d8f410fc7dbaad6818b41d Mon Sep 17 00:00:00 2001 From: Nevio Di Gennaro Date: Thu, 14 Nov 2024 13:53:23 +0100 Subject: [PATCH] make test check if the quarter with aktuell label is actually the current quarter --- frontend/cypress/e2e/overview.cy.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/e2e/overview.cy.ts b/frontend/cypress/e2e/overview.cy.ts index 54ea0bae43..d396ad11bc 100644 --- a/frontend/cypress/e2e/overview.cy.ts +++ b/frontend/cypress/e2e/overview.cy.ts @@ -5,8 +5,27 @@ describe('OKR Overview', () => { cy.loginAsUser(users.gl); }); - it('should have the current quarter with label Aktuell', () => { - cy.getByTestId('quarterFilter').contains('Aktuell'); + it.only('should have the current quarter with label Aktuell', () => { + cy.getByTestId('quarterFilter') + .contains('Aktuell') + .invoke('text') + .then((text) => { + //Checks if the current quarter is displayed with the label Aktuell not sure if this is needed + const currentDate = new Date(); + const currentMonth = currentDate.getMonth(); + let quarter = Math.ceil((currentMonth + 1) / 3 + 1); + + if (quarter > 4) { + quarter -= 4; + } + + const businessYearStart = quarter > 2 ? currentDate.getFullYear() - 2001 : currentDate.getFullYear() - 2000; + const businessYearEnd = businessYearStart + 1; + + const expectedText = `GJ ${businessYearStart}/${businessYearEnd}-Q${quarter} Aktuell`; + + expect(text).to.contain(expectedText); + }); }); it('Check order of teams', () => {