Browse Source
feat: implement multilingual support infrastructure and introduce profile interaction components
front-test-2
feat: implement multilingual support infrastructure and introduce profile interaction components
front-test-2
37 changed files with 3385 additions and 1285 deletions
-
3874package-lock.json
-
10package.json
-
9proxy.ts
-
23src/app/globals.css
-
76src/app/request-accepted/page.tsx
-
90src/components/Componentes/female-outcome-sheet.test.tsx
-
6src/components/Componentes/female-outcome-sheet.tsx
-
180src/components/Componentes/swipe-button.tsx
-
2src/lib/get-submit-path.ts
-
28src/lib/view-paddings.ts
-
11src/test/setup.ts
-
40src/translations/dictionaries.ts
-
9src/translations/locales/ar.json
-
9src/translations/locales/az.json
-
9src/translations/locales/bn.json
-
9src/translations/locales/da.json
-
9src/translations/locales/de.json
-
3src/translations/locales/en.json
-
9src/translations/locales/es.json
-
5src/translations/locales/fa.json
-
9src/translations/locales/fr.json
-
9src/translations/locales/gu.json
-
9src/translations/locales/ha.json
-
10src/translations/locales/he.json
-
9src/translations/locales/hi.json
-
10src/translations/locales/id.json
-
10src/translations/locales/ks.json
-
10src/translations/locales/pt.json
-
16src/translations/locales/ru.json
-
10src/translations/locales/sw.json
-
10src/translations/locales/tg.json
-
10src/translations/locales/tr.json
-
10src/translations/locales/ul.json
-
10src/translations/locales/ur.json
-
10src/translations/locales/uz.json
-
9src/translations/locales/zh.json
-
14vitest.config.ts
3874
package-lock.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,90 @@ |
|||||
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react"; |
||||
|
import userEvent from "@testing-library/user-event"; |
||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
||||
|
import { I18nProvider } from "@/translations/provider"; |
||||
|
import FemaleOutcomeSheet from "./female-outcome-sheet"; |
||||
|
|
||||
|
vi.mock("./swipe-button", () => ({ |
||||
|
default: ({ |
||||
|
disabled, |
||||
|
onSuccess, |
||||
|
text, |
||||
|
}: { |
||||
|
disabled?: boolean; |
||||
|
onSuccess: () => void; |
||||
|
text: string; |
||||
|
}) => ( |
||||
|
<button type="button" disabled={disabled} onClick={onSuccess}> |
||||
|
{text} |
||||
|
</button> |
||||
|
), |
||||
|
})); |
||||
|
|
||||
|
function renderSheet(onSubmit = vi.fn()) { |
||||
|
render( |
||||
|
<I18nProvider locale="en"> |
||||
|
<FemaleOutcomeSheet onSubmit={onSubmit} /> |
||||
|
</I18nProvider>, |
||||
|
); |
||||
|
|
||||
|
return onSubmit; |
||||
|
} |
||||
|
|
||||
|
describe("FemaleOutcomeSheet", () => { |
||||
|
afterEach(cleanup); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
vi.useRealTimers(); |
||||
|
}); |
||||
|
|
||||
|
it("keeps the profile unchanged when the acquaintance process is still ongoing", async () => { |
||||
|
const onSubmit = renderSheet(); |
||||
|
|
||||
|
await userEvent.click( |
||||
|
screen.getByRole("button", { name: "Continue" }), |
||||
|
); |
||||
|
|
||||
|
expect(onSubmit).toHaveBeenCalledWith("success"); |
||||
|
}); |
||||
|
|
||||
|
it("requires a cancellation reason and submits it as a failure", async () => { |
||||
|
const onSubmit = renderSheet(); |
||||
|
|
||||
|
await userEvent.click(screen.getByLabelText("Canceled")); |
||||
|
|
||||
|
const confirmation = screen.getByRole("button", { |
||||
|
name: "Confirm", |
||||
|
}); |
||||
|
expect(confirmation).toHaveProperty("disabled", true); |
||||
|
|
||||
|
await userEvent.click( |
||||
|
screen.getByRole("button", { name: "No mutual interest" }), |
||||
|
); |
||||
|
expect(confirmation).toHaveProperty("disabled", false); |
||||
|
|
||||
|
fireEvent.click(confirmation); |
||||
|
expect(onSubmit).toHaveBeenCalledWith("failure", "No mutual interest"); |
||||
|
}); |
||||
|
|
||||
|
it("requires a written note when the other cancellation reason is selected", async () => { |
||||
|
renderSheet(); |
||||
|
|
||||
|
await userEvent.click(screen.getByLabelText("Canceled")); |
||||
|
await userEvent.click( |
||||
|
screen.getByRole("button", { name: "Other reasons" }), |
||||
|
); |
||||
|
|
||||
|
const confirmation = screen.getByRole("button", { |
||||
|
name: "Confirm", |
||||
|
}); |
||||
|
expect(confirmation).toHaveProperty("disabled", true); |
||||
|
|
||||
|
await userEvent.type( |
||||
|
screen.getByPlaceholderText( |
||||
|
"Feel free to briefly explain your decision...", |
||||
|
), |
||||
|
"The families could not agree on the next steps.", |
||||
|
); |
||||
|
expect(confirmation).toHaveProperty("disabled", false); |
||||
|
}); |
||||
|
}); |
||||
@ -0,0 +1,11 @@ |
|||||
|
import "@testing-library/jest-dom/vitest"; |
||||
|
|
||||
|
Object.defineProperty(window, "requestAnimationFrame", { |
||||
|
value: (callback: FrameRequestCallback) => window.setTimeout(callback, 0), |
||||
|
}); |
||||
|
|
||||
|
Object.defineProperty(window, "cancelAnimationFrame", { |
||||
|
value: (id: number) => window.clearTimeout(id), |
||||
|
}); |
||||
|
|
||||
|
HTMLTextAreaElement.prototype.scrollIntoView = () => {}; |
||||
@ -0,0 +1,14 @@ |
|||||
|
import path from "node:path"; |
||||
|
import { defineConfig } from "vitest/config"; |
||||
|
|
||||
|
export default defineConfig({ |
||||
|
resolve: { |
||||
|
alias: { |
||||
|
"@": path.resolve(__dirname, "src"), |
||||
|
}, |
||||
|
}, |
||||
|
test: { |
||||
|
environment: "jsdom", |
||||
|
setupFiles: ["./src/test/setup.ts"], |
||||
|
}, |
||||
|
}); |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue