mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 10:50:37 -06:00
Chore: Fixed failing e2e due to day light saving time. (#41417)
This commit is contained in:
parent
bc432ef2b8
commit
dce851e396
@ -15,13 +15,13 @@ e2e.scenario({
|
||||
itName: 'Tests dashboard time zone scenarios',
|
||||
addScenarioDataSource: false,
|
||||
addScenarioDashBoard: false,
|
||||
skipScenario: true,
|
||||
skipScenario: false,
|
||||
scenario: () => {
|
||||
e2e.flows.openDashboard({ uid: '5SdHCasdf' });
|
||||
|
||||
const fromTimeZone = 'Coordinated Universal Time';
|
||||
const fromTimeZone = 'UTC';
|
||||
const toTimeZone = 'America/Chicago';
|
||||
const offset = -5;
|
||||
const offset = offsetBetweenTimeZones(toTimeZone, fromTimeZone);
|
||||
|
||||
const panelsToCheck = [
|
||||
'Random walk series',
|
||||
@ -53,8 +53,7 @@ e2e.scenario({
|
||||
e2e.components.TimeZonePicker.container()
|
||||
.should('be.visible')
|
||||
.within(() => {
|
||||
e2e.components.Select.singleValue().should('be.visible').should('have.text', fromTimeZone);
|
||||
|
||||
e2e.components.Select.singleValue().should('be.visible').should('have.text', 'Coordinated Universal Time');
|
||||
e2e.components.Select.input().should('be.visible').click();
|
||||
});
|
||||
|
||||
@ -99,3 +98,16 @@ const isTimeCorrect = (inUtc: string, inTz: string, offset: number): boolean =>
|
||||
|
||||
return diff <= Math.abs(offset * 60);
|
||||
};
|
||||
|
||||
const offsetBetweenTimeZones = (timeZone1: string, timeZone2: string, when: Date = new Date()): number => {
|
||||
const t1 = convertDateToAnotherTimeZone(when, timeZone1);
|
||||
const t2 = convertDateToAnotherTimeZone(when, timeZone2);
|
||||
return (t1.getTime() - t2.getTime()) / (1000 * 60 * 60);
|
||||
};
|
||||
|
||||
const convertDateToAnotherTimeZone = (date: Date, timeZone: string): Date => {
|
||||
const dateString = date.toLocaleString('en-US', {
|
||||
timeZone: timeZone,
|
||||
});
|
||||
return new Date(dateString);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user