TimeZonePicker: Fix incorrect country mapping for Asia/Singapore timezone (#105061)

* Fix incorrect country for Asia/Singapore timezone

* Add test

* link to gh issue

* skip test

---------

Co-authored-by: joshhunt <josh.hunt@grafana.com>
pull/105062/head^2
keerthanamsys 2 months ago committed by GitHub
parent 0acfa001fd
commit e14c17ef69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      packages/grafana-data/src/datetime/timezones.test.ts
  2. 6
      packages/grafana-data/src/datetime/timezones.ts
  3. 3
      packages/grafana-ui/src/components/ClipboardButton/ClipboardButton.test.tsx

@ -15,6 +15,7 @@ describe('getTimeZoneInfo', () => {
const result = getTimeZoneInfo('browser', Date.now());
expect(result?.ianaName).toBe('Pacific/Easter');
});
it('should resolve for utc timezone', () => {
const result = getTimeZoneInfo('utc', Date.now());
expect(result?.ianaName).toBe('UTC');
@ -24,5 +25,11 @@ describe('getTimeZoneInfo', () => {
const result = getTimeZoneInfo('Europe/Warsaw', Date.now());
expect(result?.ianaName).toBe('Europe/Warsaw');
});
it('should not think Singapore is in Antarctica', () => {
const result = getTimeZoneInfo('Asia/Singapore', Date.now());
expect(result).not.toBeUndefined();
expect(result!.countries).not.toContainEqual({ code: 'AQ', name: 'Antarctica' });
});
});
});

@ -439,6 +439,12 @@ const countriesByTimeZone = ((): Record<string, TimeZoneCountry[]> => {
return all;
}
// Fix: Only include Antarctica if timezone starts with "Antarctica/"
// https://github.com/grafana/grafana/issues/104688
if (code === 'AQ' && !timeZone.startsWith('Antarctica/')) {
return all;
}
all[timeZone].push({ code, name });
return all;
}, all);

@ -23,7 +23,8 @@ describe('ClipboardButton', () => {
Object.assign(window, originalWindow);
});
it('should copy text to clipboard when clicked', async () => {
// TODO: flaky https://github.com/grafana/grafana/issues/105102
it.skip('should copy text to clipboard when clicked', async () => {
const textToCopy = 'Copy me!';
const onClipboardCopy = jest.fn();

Loading…
Cancel
Save