dify/web/app/education/apply/__tests__/application-entry.spec.tsx
Joel 35132d6892
chore: reopen the education application flow (#40760)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-14 07:16:21 +00:00

44 lines
1.4 KiB
TypeScript

import { screen } from '@testing-library/react'
import { createConsoleQueryWrapper, seedFeatures } from '@/test/console/query-data'
import { render } from '@/test/console/render'
import EducationApplyRoute from '../application-entry'
const mockRedirect = vi.hoisted(() => vi.fn(() => null as never))
vi.mock('@/next/navigation', () => ({
redirect: mockRedirect,
}))
vi.mock('../application-form', () => ({
default: ({ token }: { token: string }) => <div>Application form: {token}</div>,
}))
describe('EducationApplyRoute', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('returns to home when the education plan is unavailable', () => {
const { queryClient, wrapper } = createConsoleQueryWrapper()
seedFeatures(queryClient, { education: { enabled: false } })
render(<EducationApplyRoute token="education-token" />, { wrapper })
expect(mockRedirect).toHaveBeenCalledWith('/')
})
it('renders the application form for a direct token URL', () => {
const { queryClient, wrapper } = createConsoleQueryWrapper({
educationStatus: { is_student: false },
})
seedFeatures(queryClient, {
billing: { subscription: { plan: 'sandbox' } },
education: { enabled: true },
})
render(<EducationApplyRoute token="education-token" />, { wrapper })
expect(screen.getByText('Application form: education-token')).toBeInTheDocument()
})
})