mirror of
https://github.com/langgenius/dify.git
synced 2026-03-27 01:00:13 +08:00
Frontend: - Migrate deprecated imports: modal→dialog, toast→ui/toast, tooltip→tooltip-plus, portal-to-follow-elem→portal-to-follow-elem-plus, select→ui/select, confirm→alert-dialog - Replace next/* with @/next/* wrapper modules - Convert TypeScript enums to const objects (erasable-syntax-only) - Replace all `any` types with `unknown` or specific types in workflow types - Fix unused vars, react-hooks-extra, react-refresh/only-export-components - Extract InteractionMode to separate module, tool-block commands to commands.ts Backend: - Fix pyrefly errors: type narrowing, null guards, getattr patterns - Remove unused TYPE_CHECKING imports in LLM node - Add ignore_imports entries to .importlinter for dify_graph boundary violations Made-with: Cursor
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
import { redirect } from '@/next/navigation'
|
|
import Home from './page'
|
|
|
|
vi.mock('next/navigation', () => ({
|
|
redirect: vi.fn(),
|
|
}))
|
|
|
|
describe('Home page redirect', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('should redirect to /apps when search params are empty', async () => {
|
|
// Arrange
|
|
const props = {
|
|
searchParams: Promise.resolve({}),
|
|
}
|
|
|
|
// Act
|
|
await Home(props)
|
|
|
|
// Assert
|
|
expect(redirect).toHaveBeenCalledWith('/apps')
|
|
})
|
|
|
|
it('should preserve single query param when redirecting to /apps', async () => {
|
|
// Arrange
|
|
const props = {
|
|
searchParams: Promise.resolve({
|
|
oauth_redirect_url: 'https://example.com/callback',
|
|
}),
|
|
}
|
|
|
|
// Act
|
|
await Home(props)
|
|
|
|
// Assert
|
|
expect(redirect).toHaveBeenCalledWith('/apps?oauth_redirect_url=https%3A%2F%2Fexample.com%2Fcallback')
|
|
})
|
|
|
|
it('should preserve repeated query params when redirecting to /apps', async () => {
|
|
// Arrange
|
|
const props = {
|
|
searchParams: Promise.resolve({
|
|
scope: ['read:name', 'read:email'],
|
|
}),
|
|
}
|
|
|
|
// Act
|
|
await Home(props)
|
|
|
|
// Assert
|
|
expect(redirect).toHaveBeenCalledWith('/apps?scope=read%3Aname&scope=read%3Aemail')
|
|
})
|
|
|
|
it('should ignore undefined query values when building redirect url', async () => {
|
|
// Arrange
|
|
const props = {
|
|
searchParams: Promise.resolve({
|
|
client_id: 'abc',
|
|
state: undefined,
|
|
}),
|
|
}
|
|
|
|
// Act
|
|
await Home(props)
|
|
|
|
// Assert
|
|
expect(redirect).toHaveBeenCalledWith('/apps?client_id=abc')
|
|
})
|
|
})
|