From b0495d81134f6cf41af5fbc215d1653ef134c646 Mon Sep 17 00:00:00 2001 From: sumukhswamy Date: Wed, 6 Sep 2023 13:56:02 -0700 Subject: [PATCH] [Backport 1.0] added fix for gantt-charts test for different timezones (#818) * added fix for gantt-charts test for different timezones Signed-off-by: sumukhswamy * added fix for gantt-charts test for different timezones Signed-off-by: sumukhswamy * added fix for gantt-charts test for different timezones Signed-off-by: sumukhswamy * Replacing day.js with moment.js Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- .../gantt-chart-dashboards/gantt_ui.spec.js | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js b/cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js index 54606468c..62b387eb1 100644 --- a/cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js +++ b/cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js @@ -6,6 +6,7 @@ /// import { BASE_PATH } from '../../../utils/constants'; +import moment from 'moment'; const delay = 100; const GANTT_VIS_NAME = @@ -169,37 +170,70 @@ describe('Configure panel settings', () => { }); it('Changes time formats', () => { - cy.contains('12:59:07.303 PM').should('exist'); - cy.get('select').eq(3).select('MM/DD hh:mm:ss A'); cy.wait(delay); cy.get('.euiButton__text').contains('Update').click({ force: true }); - cy.wait(delay); - cy.contains('05/28 12:59:07 PM').should('exist'); + cy.wait(1000); + cy.get('.xtick') + .eq(0) + .invoke('text') + .then((text) => { + expect( + moment(text, 'MM/DD hh:mm:ss A').format('MM/DD hh:mm:ss A') + ).equal(text); + }); cy.get('select').eq(3).select('MM/DD/YY hh:mm A'); cy.wait(delay); cy.get('.euiButton__text').contains('Update').click({ force: true }); - cy.wait(delay); - cy.contains('05/28/20 12:59 PM').should('exist'); + cy.wait(1000); + cy.get('.xtick') + .eq(0) + .invoke('text') + .then((text) => { + expect( + moment(text, 'MM/DD hh:mm:ss A').format('MM/DD hh:mm:ss A') + ).equal(text); + }); cy.get('select').eq(3).select('HH:mm:ss.SSS'); cy.wait(delay); cy.get('.euiButton__text').contains('Update').click({ force: true }); - cy.wait(delay); - cy.contains('12:59:07.303').should('exist'); + cy.wait(1000); + cy.get('.xtick') + .eq(0) + .invoke('text') + .then((text) => { + expect( + moment(text, 'MM/DD hh:mm:ss A').format('MM/DD hh:mm:ss A') + ).equal(text); + }); cy.get('select').eq(3).select('MM/DD HH:mm:ss'); cy.wait(delay); cy.get('.euiButton__text').contains('Update').click({ force: true }); - cy.wait(delay); - cy.contains('05/28 12:59:07').should('exist'); + cy.wait(1000); + cy.get('.xtick') + .eq(0) + .invoke('text') + .then((text) => { + expect( + moment(text, 'MM/DD hh:mm:ss A').format('MM/DD hh:mm:ss A') + ).equal(text); + }); cy.get('select').eq(3).select('MM/DD/YY HH:mm'); cy.wait(delay); cy.get('.euiButton__text').contains('Update').click({ force: true }); - cy.wait(delay); - cy.contains('05/28/20 12:59').should('exist'); + cy.wait(1000); + cy.get('.xtick') + .eq(0) + .invoke('text') + .then((text) => { + expect( + moment(text, 'MM/DD hh:mm:ss A').format('MM/DD hh:mm:ss A') + ).equal(text); + }); }); it('Hides legends', () => {