import { fireEvent, render, screen } from '@testing-library/react';
import { MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
import { describe, expect, it } from 'vitest';
import { LegacyPluginRedirect } from '@/pages/Plugins/legacy-plugin-redirect';
import { getGuardedAiModuleForPath, isProgrammingProviderRoute } from '@/lib/ai-modules';
function LocationProbe() {
const location = useLocation();
const navigate = useNavigate();
return (
);
}
describe('plugin navigation cutover', () => {
it.each([
['/plugin-marketplace', '/plugins?scope=all&source=official'],
['/my-plugins', '/plugins?scope=all&state=mine'],
['/project-plugins', '/plugins?scope=project'],
] as const)('replace-redirects %s to %s', async (legacy, canonical) => {
render(
} />
} />
previous} />
,
);
expect(await screen.findByTestId('location')).toHaveTextContent(canonical);
fireEvent.click(screen.getByRole('button', { name: '返回' }));
expect(await screen.findByTestId('previous')).toBeVisible();
});
it('classifies the canonical page as Code without making it provider-gated', () => {
expect(getGuardedAiModuleForPath('/plugins')).toBe('programming');
expect(isProgrammingProviderRoute('/plugins')).toBe(false);
});
});