[v11.0.x] Time Zones: Fix relative time when using UTC timezone (#85779)

Time Zones: Fix relative time when using UTC timezone (#85637)

add UTC case to e2e test + let UTC pass through to moment.tz

(cherry picked from commit 4b5b738646)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
pull/85786/head
grafana-delivery-bot[bot] 1 year ago committed by GitHub
parent ee8bb9e3d4
commit d56f75eb5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 35
      e2e/dashboards-suite/dashboard-time-zone.spec.ts
  2. 4
      packages/grafana-data/src/datetime/moment_wrapper.ts

@ -112,6 +112,41 @@ describe('Dashboard time zone support', () => {
// Need to wait for 2 calls as there's 2 panels // Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']); cy.wait(['@dataQuery', '@dataQuery']);
e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});
e2e.components.Panels.Panel.title('Panel in timezone')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});
// Test UTC timezone
e2e.flows.setTimeRange({
from: 'now-6h',
to: 'now',
zone: 'Coordinated Universal Time',
});
// Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']);
e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});
// Today so far, still in UTC timezone
e2e.flows.setTimeRange({
from: 'now/d',
to: 'now',
});
// Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']);
e2e.components.Panels.Panel.title('Panel with relative time override') e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible') .should('be.visible')
.within(() => { .within(() => {

@ -126,10 +126,6 @@ export const dateTimeForTimeZone = (
input?: DateTimeInput, input?: DateTimeInput,
formatInput?: FormatInput formatInput?: FormatInput
): DateTime => { ): DateTime => {
if (timezone === 'utc') {
return toUtc(input, formatInput);
}
if (timezone && timezone !== 'browser') { if (timezone && timezone !== 'browser') {
let result: moment.Moment; let result: moment.Moment;

Loading…
Cancel
Save