mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem When users must grant access to an app they already added because its scopes changed, they should have a clear understanding of the changes ## Solution Show only the scopes differences by default <img width="844" height="962" alt="image" src="https://github.com/user-attachments/assets/6289f4cf-200f-4660-b9a1-aedbaaa963e3" /> ## Review instructions Try this UI with [`authorize?mock_scenario=reconsent`](https://studio-staging-git-gildasgarcia-oauth-apps-inte-6106b6-supabase.vercel.app/dashboard/authorize?mock_scenario=reconsent) --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import { screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import dayjs from 'dayjs'
|
|
import { mockAnimationsApi } from 'jsdom-testing-mocks'
|
|
import { describe, expect, test, vi } from 'vitest'
|
|
|
|
import { TimezoneSelection } from './TimezoneSelection'
|
|
import { findTimezoneByIana } from '@/lib/constants/timezones'
|
|
import { customRender } from '@/tests/lib/custom-render'
|
|
|
|
mockAnimationsApi()
|
|
|
|
describe('TimezoneSelection', () => {
|
|
test('updates Madrid offsets when the restore date crosses daylight saving time and preserves the selected timezone', async () => {
|
|
const madridTimezone = findTimezoneByIana('Europe/Madrid')
|
|
if (!madridTimezone) throw new Error('Madrid timezone is missing from the timezone catalog')
|
|
|
|
const user = userEvent.setup()
|
|
const onSelectTimezone = vi.fn()
|
|
const winterLabel = '(UTC+01:00) Brussels, Copenhagen, Madrid, Paris'
|
|
const summerLabel = '(UTC+02:00) Brussels, Copenhagen, Madrid, Paris'
|
|
const { rerender } = customRender(
|
|
<TimezoneSelection
|
|
selectedTimezone={madridTimezone}
|
|
date={dayjs('2026-01-15T12:00:00Z')}
|
|
onSelectTimezone={onSelectTimezone}
|
|
/>
|
|
)
|
|
|
|
const trigger = screen.getByRole('combobox')
|
|
expect(trigger).toHaveTextContent(winterLabel)
|
|
await user.click(trigger)
|
|
expect(await screen.findByRole('option', { name: winterLabel })).toBeVisible()
|
|
|
|
rerender(
|
|
<TimezoneSelection
|
|
selectedTimezone={madridTimezone}
|
|
date={dayjs('2026-07-15T12:00:00Z')}
|
|
onSelectTimezone={onSelectTimezone}
|
|
/>
|
|
)
|
|
|
|
expect(trigger).toHaveTextContent(summerLabel)
|
|
expect(screen.getByRole('option', { name: summerLabel })).toBeVisible()
|
|
expect(screen.queryByRole('option', { name: winterLabel })).not.toBeInTheDocument()
|
|
|
|
await user.type(screen.getByPlaceholderText('Search timezone...'), 'Madrid')
|
|
const matchingTimezones = screen.getAllByRole('option')
|
|
expect(matchingTimezones).toHaveLength(1)
|
|
await user.click(screen.getByRole('option', { name: summerLabel }))
|
|
|
|
expect(onSelectTimezone).toHaveBeenCalledTimes(1)
|
|
expect(onSelectTimezone.mock.calls[0][0]).toBe(madridTimezone)
|
|
expect(trigger).toHaveAttribute('aria-expanded', 'false')
|
|
}, 10_000)
|
|
})
|