2 Commits
0e14a66f95
...
ee238ad8cf
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
ee238ad8cf |
perf(config): optimize caching strategy and font loading
- Update `next.config.ts` to use `stale-while-revalidate` for application HTML shells to improve WebView rendering speed. - Implement immutable caching for static assets in `/assets/fonts/`. - Add `.woff2` versions of various fonts to `public/assets/fonts/` and `public/fonts/` to improve performance and reduce payload size. - Update `globals.css` to prioritize `.woff2` font formats. - Increase `staleTime` from 30s to 3m for various marriage-related queries in `use-form-schema.ts` and client components to reduce redundant network requests. - Refactor `QuestionSheet` to use CSS-based `min-h-[52px]` instead of dynamic inline style calculations for option buttons, improving layout stability and simplifying the component. - Improve loading state handling in `QuestionDetailClient` by incorporating `isPending` from TanStack Query. - Update test assertions in `question-sheet.test.tsx` to reflect the shift from inline styles to Tailwind CSS classes. |
2 weeks ago |
|
|
2569ed4033 |
perf(information-sheet): render inline play icon synchronously for answer pace sheet to eliminate late load delay
|
2 weeks ago |
28 changed files with 414 additions and 69 deletions
-
18next.config.ts
-
BINpublic/assets/fonts/ArabicYekanXRegular.woff2
-
BINpublic/assets/fonts/Faminela.woff2
-
BINpublic/assets/fonts/NotoNastaliqUrdu.woff2
-
BINpublic/assets/fonts/SegoeUIBold.woff2
-
BINpublic/assets/fonts/YekanXFaNum-R.woff2
-
BINpublic/assets/fonts/faminela.woff2
-
BINpublic/assets/fonts/segoeui.woff2
-
BINpublic/fonts/Amiri/Amiri-Bold.woff2
-
BINpublic/fonts/Amiri/Amiri-BoldItalic.woff2
-
BINpublic/fonts/Amiri/Amiri-Italic.woff2
-
BINpublic/fonts/Amiri/Amiri-Regular.woff2
-
BINpublic/fonts/Faminela/Faminela.woff2
-
BINpublic/fonts/segoeui/SegoeUIBold.woff2
-
BINpublic/fonts/segoeui/segoeui.woff2
-
BINpublic/fonts/urdu/NotoNastaliqUrdu.woff2
-
BINpublic/fonts/yekanx-arabic/ArabicYekanXRegular.woff2
-
BINpublic/fonts/yekanx/YekanXFaNum-R.woff2
-
19src/app/globals.css
-
87src/app/questions-list/[slug]/answer-pace-sheet.test.tsx
-
20src/app/questions-list/[slug]/question-detail-client.tsx
-
11src/app/questions-list/questions-list-client.tsx
-
108src/components/Componentes/information-sheet.test.tsx
-
131src/components/Componentes/information-sheet.tsx
-
18src/components/Componentes/question-sheet.test.tsx
-
7src/components/Componentes/question-sheet.tsx
-
32src/components/Componentes/ui-icon.tsx
-
8src/hooks/marriage/use-form-schema.ts
@ -0,0 +1,87 @@ |
|||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"; |
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
|||
import AnswerPaceSheet, { |
|||
isAnswerPaceSheetSeen, |
|||
markAnswerPaceSheetSeen, |
|||
} from "./answer-pace-sheet"; |
|||
|
|||
vi.mock("@/translations/provider", () => ({ |
|||
useI18n: vi.fn(() => ({ |
|||
locale: "fa", |
|||
dictionary: { |
|||
"Information sheet": "شیت اطلاعات", |
|||
Close: "بستن", |
|||
}, |
|||
})), |
|||
})); |
|||
|
|||
vi.mock("@/lib/first-entry-helper", () => ({ |
|||
isFirstEntryCompleted: vi.fn(() => false), |
|||
})); |
|||
|
|||
describe("AnswerPaceSheet", () => { |
|||
beforeEach(() => { |
|||
window.localStorage.clear(); |
|||
}); |
|||
|
|||
afterEach(() => { |
|||
cleanup(); |
|||
window.localStorage.clear(); |
|||
}); |
|||
|
|||
it("does not render when activeQuestionIndex is less than 3", () => { |
|||
render( |
|||
<AnswerPaceSheet |
|||
activeQuestionIndex={2} |
|||
title="با آرامش پاسخ دهید" |
|||
description="میتوانید هر زمان نظرسنجی را متوقف کرده و بعداً ادامه دهید." |
|||
continueLabel="متوجه شدم" |
|||
/>, |
|||
); |
|||
|
|||
expect(screen.queryByRole("dialog")).toBeNull(); |
|||
}); |
|||
|
|||
it("renders when activeQuestionIndex >= 3 and displays inline play icon synchronously without network img tag", () => { |
|||
render( |
|||
<AnswerPaceSheet |
|||
activeQuestionIndex={3} |
|||
title="با آرامش پاسخ دهید" |
|||
description="میتوانید هر زمان نظرسنجی را متوقف کرده و بعداً ادامه دهید." |
|||
continueLabel="متوجه شدم" |
|||
/>, |
|||
); |
|||
|
|||
const dialog = screen.getByRole("dialog"); |
|||
expect(dialog).toBeDefined(); |
|||
expect(screen.getByText("با آرامش پاسخ دهید")).toBeDefined(); |
|||
expect( |
|||
screen.getByText( |
|||
"میتوانید هر زمان نظرسنجی را متوقف کرده و بعداً ادامه دهید.", |
|||
), |
|||
).toBeDefined(); |
|||
|
|||
// Critical: must render inline SVG play icon instantly with NO <img> tag
|
|||
expect(dialog.querySelector("img")).toBeNull(); |
|||
const playSvg = dialog.querySelector('svg[aria-label="Play"]'); |
|||
expect(playSvg).not.toBeNull(); |
|||
expect(playSvg?.getAttribute("viewBox")).toBe("0 0 50 50"); |
|||
}); |
|||
|
|||
it("marks sheet as seen and closes on button click", async () => { |
|||
render( |
|||
<AnswerPaceSheet |
|||
activeQuestionIndex={3} |
|||
title="با آرامش پاسخ دهید" |
|||
description="میتوانید هر زمان نظرسنجی را متوقف کرده و بعداً ادامه دهید." |
|||
continueLabel="متوجه شدم" |
|||
/>, |
|||
); |
|||
|
|||
const continueBtn = screen.getByRole("button", { name: "متوجه شدم" }); |
|||
fireEvent.click(continueBtn); |
|||
await waitFor(() => { |
|||
expect(isAnswerPaceSheetSeen()).toBe(true); |
|||
}); |
|||
}); |
|||
}); |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue