mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-24 00:43:29 +10:00
chore: add missing translations
This commit is contained in:
@@ -42,6 +42,7 @@ vi.mock("pdfjs-dist", () => {
|
||||
vi.mock("pdfjs-dist/legacy/build/pdf.mjs", () => pdfjsMock.legacyModule);
|
||||
|
||||
const pdfCanvasModule = import("./pdf-canvas");
|
||||
const pdfCanvasModuleTimeoutMs = 15_000;
|
||||
|
||||
describe("PDF.js browser entrypoints", () => {
|
||||
beforeEach(() => {
|
||||
@@ -60,18 +61,22 @@ describe("PDF.js browser entrypoints", () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("loads the canvas preview renderer from the legacy PDF.js runtime", async () => {
|
||||
await expect(pdfCanvasModule).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
PdfCanvasDocument: expect.any(Function),
|
||||
PdfCanvasPage: expect.any(Function),
|
||||
}),
|
||||
);
|
||||
it(
|
||||
"loads the canvas preview renderer from the legacy PDF.js runtime",
|
||||
async () => {
|
||||
await expect(pdfCanvasModule).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
PdfCanvasDocument: expect.any(Function),
|
||||
PdfCanvasPage: expect.any(Function),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(pdfjsMock.legacyModule.GlobalWorkerOptions.workerSrc).toContain(
|
||||
"pdfjs-dist/legacy/build/pdf.worker.min.mjs",
|
||||
);
|
||||
});
|
||||
expect(pdfjsMock.legacyModule.GlobalWorkerOptions.workerSrc).toContain(
|
||||
"pdfjs-dist/legacy/build/pdf.worker.min.mjs",
|
||||
);
|
||||
},
|
||||
pdfCanvasModuleTimeoutMs,
|
||||
);
|
||||
|
||||
it("creates thumbnails with the legacy PDF.js runtime", async () => {
|
||||
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue({} as CanvasRenderingContext2D);
|
||||
|
||||
@@ -11,6 +11,18 @@ const previewMock = vi.hoisted(() => ({
|
||||
toBlob: vi.fn(async () => new Blob(["%PDF"], { type: "application/pdf" })),
|
||||
}));
|
||||
|
||||
type PdfCanvasDocumentProps = {
|
||||
children: (document: { numPages: number }) => React.ReactNode;
|
||||
onLoadSuccess: (document: { numPages: number }) => void;
|
||||
};
|
||||
|
||||
type PdfCanvasPageProps = {
|
||||
onLoadSuccess: (pageNumber: number, pageSize: { height: number; width: number }) => void;
|
||||
onRenderSuccess?: () => void;
|
||||
pageNumber: number;
|
||||
totalPages: number;
|
||||
};
|
||||
|
||||
const resumeDataWithPageCount = (pageCount: number): ResumeData => ({
|
||||
...sampleResumeData,
|
||||
metadata: {
|
||||
@@ -35,30 +47,14 @@ vi.mock("./pdf-canvas", async () => {
|
||||
const pdfDocument = { numPages: 1 };
|
||||
|
||||
return {
|
||||
PdfCanvasDocument: ({
|
||||
children,
|
||||
onLoadSuccess,
|
||||
}: {
|
||||
children: (document: typeof pdfDocument) => React.ReactNode;
|
||||
onLoadSuccess: (document: typeof pdfDocument) => void;
|
||||
}) => {
|
||||
PdfCanvasDocument: ({ children, onLoadSuccess }: PdfCanvasDocumentProps) => {
|
||||
React.useEffect(() => {
|
||||
onLoadSuccess(pdfDocument);
|
||||
}, [onLoadSuccess]);
|
||||
|
||||
return React.createElement(React.Fragment, null, children(pdfDocument));
|
||||
},
|
||||
PdfCanvasPage: ({
|
||||
onLoadSuccess,
|
||||
onRenderSuccess,
|
||||
pageNumber,
|
||||
totalPages,
|
||||
}: {
|
||||
onLoadSuccess: (pageNumber: number, pageSize: { height: number; width: number }) => void;
|
||||
onRenderSuccess?: () => void;
|
||||
pageNumber: number;
|
||||
totalPages: number;
|
||||
}) => {
|
||||
PdfCanvasPage: ({ onLoadSuccess, onRenderSuccess, pageNumber, totalPages }: PdfCanvasPageProps) => {
|
||||
React.useEffect(() => {
|
||||
onLoadSuccess(pageNumber, { height: 200, width: 100 });
|
||||
onRenderSuccess?.();
|
||||
|
||||
@@ -8,11 +8,16 @@ import { i18n } from "@lingui/core";
|
||||
import { I18nProvider } from "@lingui/react";
|
||||
import { sampleResumeData } from "@reactive-resume/schema/resume/sample";
|
||||
|
||||
type PdfViewerProps = {
|
||||
className?: string;
|
||||
data: ResumeData;
|
||||
};
|
||||
|
||||
const publicResumeMock = vi.hoisted(() => ({
|
||||
createResumePdfBlob: vi.fn(async () => new Blob(["%PDF"], { type: "application/pdf" })),
|
||||
downloadWithAnchor: vi.fn(),
|
||||
generateFilename: vi.fn((name: string, extension: string) => `${name}.${extension}`),
|
||||
PdfViewer: vi.fn<(_props: { className?: string; data: ResumeData }) => ReactNode>(() => null),
|
||||
PdfViewer: vi.fn<(_props: PdfViewerProps) => ReactNode>(() => null),
|
||||
resume: undefined as
|
||||
| undefined
|
||||
| {
|
||||
|
||||
@@ -23,6 +23,10 @@ import { orpc } from "@/libs/orpc/client";
|
||||
type SavedProvider = RouterOutput["aiProviders"]["list"][number];
|
||||
type AIProviderOption = ComboboxOption<AIProvider> & { defaultBaseURL: string };
|
||||
|
||||
type ProviderRowProps = {
|
||||
provider: SavedProvider;
|
||||
};
|
||||
|
||||
const providerOptions: AIProviderOption[] = [
|
||||
{
|
||||
value: "openai",
|
||||
@@ -110,7 +114,7 @@ function isAiProviderConfigError(error: unknown) {
|
||||
return status === "PRECONDITION_FAILED" || status === 412;
|
||||
}
|
||||
|
||||
function ProviderRow({ provider }: { provider: SavedProvider }) {
|
||||
function ProviderRow({ provider }: ProviderRowProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: orpc.aiProviders.list.queryKey() });
|
||||
const { mutate: testProvider, isPending: isTesting } = useMutation(orpc.aiProviders.test.mutationOptions());
|
||||
|
||||
Reference in New Issue
Block a user