This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch geido/fix/timezoneselector-unit-tests
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 44302aad4fcf0a9c6a91ea480889ee76c73b0cb8
Author: Diego Pucci <[email protected]>
AuthorDate: Mon Nov 4 14:55:36 2024 +0200

    fix(TimezoneSelector): Failing unit tests due to timzone change
---
 .../TimezoneSelector.DaylightSavingTime.test.tsx             |  5 ++++-
 .../components/TimezoneSelector/TimezoneSelector.test.tsx    | 12 +++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx
 
b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx
index f30eeb2d52..edb71341f2 100644
--- 
a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx
+++ 
b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx
@@ -35,10 +35,13 @@ const loadComponent = (mockCurrentTime?: string) => {
   return new Promise<FC<TimezoneSelectorProps>>(resolve => {
     const { default: TimezoneSelector } = module.require('./index');
     resolve(TimezoneSelector);
-    jest.useRealTimers();
   });
 };
 
+afterEach(() => {
+  jest.useRealTimers();
+});
+
 test('render timezones in correct order for daylight saving time', async () => 
{
   const TimezoneSelector = await loadComponent('2022-07-01');
   const onTimezoneChange = jest.fn();
diff --git 
a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx 
b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx
index cc422ba85e..5083b6bcd0 100644
--- 
a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx
+++ 
b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx
@@ -35,7 +35,6 @@ const loadComponent = (mockCurrentTime?: string) => {
   return new Promise<FC<TimezoneSelectorProps>>(resolve => {
     const { default: TimezoneSelector } = module.require('./index');
     resolve(TimezoneSelector);
-    jest.useRealTimers();
   });
 };
 
@@ -49,6 +48,10 @@ const openSelectMenu = () => {
 
 jest.spyOn(moment.tz, 'guess').mockReturnValue('America/New_York');
 
+afterEach(() => {
+  jest.useRealTimers();
+});
+
 test('use the timezone from `moment` if no timezone provided', async () => {
   const TimezoneSelector = await loadComponent('2022-01-01');
   const onTimezoneChange = jest.fn();
@@ -96,10 +99,9 @@ test('render timezones in correct order for standard time', 
async () => {
   await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading'));
   openSelectMenu();
   const options = await getSelectOptions();
-  expect(options[0]).toHaveTextContent('GMT -04:00 (Eastern Daylight Time)');
+  expect(options[0]).toHaveTextContent('GMT -05:00 (Eastern Standard Time)');
   expect(options[1]).toHaveTextContent('GMT -11:00 (Pacific/Pago_Pago)');
   expect(options[2]).toHaveTextContent('GMT -10:00 (Hawaii Standard Time)');
-  expect(options[3]).toHaveTextContent('GMT -09:30 (Pacific/Marquesas)');
 });
 
 test('can select a timezone values and returns canonical timezone name', async 
() => {
@@ -116,8 +118,8 @@ test('can select a timezone values and returns canonical 
timezone name', async (
 
   const searchInput = screen.getByRole('combobox');
   // search for mountain time
-  await userEvent.type(searchInput, 'mou', { delay: 10 });
-  const findTitle = 'GMT -06:00 (Mountain Daylight Time)';
+  await userEvent.type(searchInput, 'mou');
+  const findTitle = 'GMT -07:00 (Mountain Standard Time)';
   const selectOption = await screen.findByTitle(findTitle);
   userEvent.click(selectOption);
   expect(onTimezoneChange).toHaveBeenCalledTimes(1);

Reply via email to