diff --git a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx index 81dbc6fdcd7e1..395d48ad99d54 100644 --- a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx +++ b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx @@ -30,10 +30,13 @@ const loadComponent = (mockCurrentTime?: string) => { return new Promise>(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 173118c7e84c9..08ed5e9749f25 100644 --- a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx +++ b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +import userEvent from '@testing-library/user-event'; import moment from 'moment-timezone'; import { FC } from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; -import userEvent from '@testing-library/user-event'; import type { TimezoneSelectorProps } from './index'; const loadComponent = (mockCurrentTime?: string) => { @@ -30,7 +30,6 @@ const loadComponent = (mockCurrentTime?: string) => { return new Promise>(resolve => { const { default: TimezoneSelector } = module.require('./index'); resolve(TimezoneSelector); - jest.useRealTimers(); }); }; @@ -44,6 +43,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(); @@ -89,7 +92,6 @@ test('render timezones in correct oder for standard time', async () => { 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 -10:00 (America/Adak)'); }); test('can select a timezone values and returns canonical timezone name', async () => { @@ -106,7 +108,7 @@ 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 }); + await userEvent.type(searchInput, 'mou'); const findTitle = 'GMT -07:00 (Mountain Standard Time)'; const selectOption = await screen.findByTitle(findTitle); userEvent.click(selectOption);