Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { useLocale } from '#i18n'
import { useSearchParams } from '@/next/navigation'
import { getBrowserTimezone } from '@/utils/timezone'
import SocialAuth from '../social-auth'
vi.mock('@/next/navigation', () => ({
useSearchParams: vi.fn(),
}))
vi.mock('#i18n', async (importOriginal) => ({
...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
vi.mock('@/utils/timezone', () => ({
getBrowserTimezone: vi.fn(),
}))
const mockUseSearchParams = vi.mocked(useSearchParams)
const mockUseLocale = vi.mocked(useLocale)
const mockGetBrowserTimezone = vi.mocked(getBrowserTimezone)
describe('SocialAuth', () => {
beforeEach(() => {
vi.clearAllMocks()
mockUseSearchParams.mockReturnValue(new URLSearchParams() as ReturnType<typeof useSearchParams>)
mockUseLocale.mockReturnValue('zh-Hans')
mockGetBrowserTimezone.mockReturnValue('Asia/Shanghai')
})
describe('OAuth params', () => {
it('should include browser timezone and locale in oauth links', () => {
render(<SocialAuth />)
expect(screen.getByRole('link', { name: 'login.withGitHub' })).toHaveAttribute(
'href',
expect.stringContaining('timezone=Asia%2FShanghai'),
)
expect(screen.getByRole('link', { name: 'login.withGitHub' })).toHaveAttribute(
'href',
expect.stringContaining('language=zh-Hans'),
)
expect(screen.getByRole('link', { name: 'login.withGoogle' })).toHaveAttribute(
'href',
expect.stringContaining('timezone=Asia%2FShanghai'),
)
expect(screen.getByRole('link', { name: 'login.withGoogle' })).toHaveAttribute(
'href',
expect.stringContaining('language=zh-Hans'),
)
})
it('should preserve invite token when adding timezone', () => {
mockUseSearchParams.mockReturnValue(
new URLSearchParams('invite_token=invite-123') as ReturnType<typeof useSearchParams>,
)
render(<SocialAuth />)
const githubLink = screen.getByRole('link', { name: 'login.withGitHub' })
expect(githubLink).toHaveAttribute('href', expect.stringContaining('invite_token=invite-123'))
expect(githubLink).toHaveAttribute(
'href',
expect.stringContaining('timezone=Asia%2FShanghai'),
)
expect(githubLink).toHaveAttribute('href', expect.stringContaining('language=zh-Hans'))
})
})
describe('Edge Cases', () => {
it('should omit timezone when browser timezone is unavailable', () => {
mockGetBrowserTimezone.mockReturnValue(undefined)
render(<SocialAuth />)
expect(
screen.getByRole('link', { name: 'login.withGitHub' }).getAttribute('href'),
).not.toContain('timezone=')
})
})
})