fix(i18n): initialize new applications on local today
This commit is contained in:
@@ -31,3 +31,13 @@ Actual MUI browser interaction, screenshots, native devices and provider/API ser
|
||||
The Jobs table similarly formats a literal deadline through local `Date`, and its current test expects that expression. Edit's retained `toDateInputValue` can also move an unspecified midnight timestamp back a day in positive zones. These are separate legacy precision/loading findings. This fix does not claim their closure or reconstruct missing timezone metadata.
|
||||
|
||||
Rollback reverts the two wrapper changes and their regression package. Existing persisted dates are not rewritten.
|
||||
|
||||
## Follow-up local-today default
|
||||
|
||||
From isolated checkpoint `f7c3617e`, Add's `getTodayIso` still selected the UTC date for initialization and a successful form reset. It now uses the already imported `format` with the browser's local Date. No persisted record is rewritten.
|
||||
|
||||
Two new component cases fix the UTC clock at `2026-11-23T00:30:00Z` and `2026-11-23T23:30:00Z`. Each timezone's red run had one failure and one pass, with the earlier five cases skipped. The final full suite passed seven cases in each of Los Angeles, Oslo and Kiritimati. That is seven distinct cases repeated in three environments, including the five earlier picker cases. TypeScript and two-file lint passed. The earlier 21-case nearby run belongs to the preceding checkpoint and was not rerun for this one-line follow-up.
|
||||
|
||||
The new cases cover initial creation, Create and add another resetting the default, and closing/reopening the resulting draft. Closing and reopening the same mounted dialog preserves its existing step and draft. It does not reset every open. The initial test draft assumed otherwise and was corrected to exercise the actual successful reset path. The only write is the explicit mocked creation request, whose selected date is asserted. API server, actual browser, export build and native checks remain unexecuted.
|
||||
|
||||
Follow-up receipts are in `evidence/date-picker-local-today/`. The legacy loading and Companies contract findings above remain open.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx
|
||||
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 7 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 8.432 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx.
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx
|
||||
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 7 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 8.287 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx.
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx
|
||||
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 7 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 8.955 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx.
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx -t Add defaults and successful reset
|
||||
|
||||
FAIL src/job-date-picker-calendar.test.tsx
|
||||
● Add defaults and successful reset use local today at 2026-11-23T00:30:00Z
|
||||
|
||||
expect(element).toHaveTextContent()
|
||||
|
||||
Expected element to have text content:
|
||||
2026-11-22
|
||||
Received:
|
||||
2026-11-23
|
||||
|
||||
43 | const view = render(form(true));
|
||||
44 | fireEvent.click(screen.getByRole("button", { name: translations.en.addJobModalEnterManually }));
|
||||
> 45 | expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
| ^
|
||||
46 | fireEvent.click(screen.getByRole("button", { name: `${translations.en.addJobModalDateApplied} choose` }));
|
||||
47 | fireEvent.change(screen.getByRole("combobox", { name: translations.en.company }), { target: { value: "Synthetic school" } });
|
||||
48 | fireEvent.change(screen.getByLabelText(translations.en.addJobModalJobTitle), { target: { value: "Teacher" } });
|
||||
|
||||
at toHaveTextContent (src/job-date-picker-calendar.test.tsx:45:73)
|
||||
|
||||
Test Suites: 1 failed, 1 total
|
||||
Tests: 1 failed, 5 skipped, 1 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 4.694 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx with tests matching "Add defaults and successful reset".
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx -t Add defaults and successful reset
|
||||
|
||||
FAIL src/job-date-picker-calendar.test.tsx
|
||||
● Add defaults and successful reset use local today at 2026-11-23T23:30:00Z
|
||||
|
||||
expect(element).toHaveTextContent()
|
||||
|
||||
Expected element to have text content:
|
||||
2026-11-24
|
||||
Received:
|
||||
2026-11-23
|
||||
|
||||
43 | const view = render(form(true));
|
||||
44 | fireEvent.click(screen.getByRole("button", { name: translations.en.addJobModalEnterManually }));
|
||||
> 45 | expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
| ^
|
||||
46 | fireEvent.click(screen.getByRole("button", { name: `${translations.en.addJobModalDateApplied} choose` }));
|
||||
47 | fireEvent.change(screen.getByRole("combobox", { name: translations.en.company }), { target: { value: "Synthetic school" } });
|
||||
48 | fireEvent.change(screen.getByLabelText(translations.en.addJobModalJobTitle), { target: { value: "Teacher" } });
|
||||
|
||||
at toHaveTextContent (src/job-date-picker-calendar.test.tsx:45:73)
|
||||
|
||||
Test Suites: 1 failed, 1 total
|
||||
Tests: 1 failed, 5 skipped, 1 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 4.977 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx with tests matching "Add defaults and successful reset".
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 test
|
||||
> jest --runInBand job-date-picker-calendar.test.tsx -t Add defaults and successful reset
|
||||
|
||||
FAIL src/job-date-picker-calendar.test.tsx
|
||||
● Add defaults and successful reset use local today at 2026-11-23T23:30:00Z
|
||||
|
||||
expect(element).toHaveTextContent()
|
||||
|
||||
Expected element to have text content:
|
||||
2026-11-24
|
||||
Received:
|
||||
2026-11-23
|
||||
|
||||
43 | const view = render(form(true));
|
||||
44 | fireEvent.click(screen.getByRole("button", { name: translations.en.addJobModalEnterManually }));
|
||||
> 45 | expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
| ^
|
||||
46 | fireEvent.click(screen.getByRole("button", { name: `${translations.en.addJobModalDateApplied} choose` }));
|
||||
47 | fireEvent.change(screen.getByRole("combobox", { name: translations.en.company }), { target: { value: "Synthetic school" } });
|
||||
48 | fireEvent.change(screen.getByLabelText(translations.en.addJobModalJobTitle), { target: { value: "Teacher" } });
|
||||
|
||||
at toHaveTextContent (src/job-date-picker-calendar.test.tsx:45:73)
|
||||
|
||||
Test Suites: 1 failed, 1 total
|
||||
Tests: 1 failed, 5 skipped, 1 passed, 7 total
|
||||
Snapshots: 0 total
|
||||
Time: 4.542 s
|
||||
Ran all test suites matching job-date-picker-calendar.test.tsx with tests matching "Add defaults and successful reset".
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
> job-tracker-ui@0.1.0 typecheck
|
||||
> tsc --noEmit --incremental false
|
||||
|
||||
@@ -74,7 +74,7 @@ const FIELD_SX = { "& .MuiInputBase-root": { minHeight: 56 } };
|
||||
const PICKER_TEXT_FIELD_PROPS = { fullWidth: true, sx: FIELD_SX };
|
||||
|
||||
function getTodayIso() {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
return format(new Date(), "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
function parsePickerDate(value?: string | null): Date | null {
|
||||
|
||||
@@ -32,6 +32,32 @@ beforeEach(() => {
|
||||
client.post.mockImplementation((url) => Promise.resolve({ data: String(url) === "/jobimport/preview"
|
||||
? { success: true, title: "Teacher", company: "Synthetic school", deadline: "2026-11-23" } : { id: 1 } } as any));
|
||||
});
|
||||
afterEach(() => { jest.useRealTimers(); });
|
||||
|
||||
test.each(["2026-11-23T00:30:00Z", "2026-11-23T23:30:00Z"])("Add defaults and successful reset use local today at %s", async clock => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(clock));
|
||||
const localNow = new Date(clock);
|
||||
const expected = `${localNow.getFullYear()}-${String(localNow.getMonth() + 1).padStart(2, "0")}-${String(localNow.getDate()).padStart(2, "0")}`;
|
||||
const form = (open: boolean) => wrap(<AddJobModal open={open} onClose={jest.fn()} onCreated={jest.fn()} />);
|
||||
const view = render(form(true));
|
||||
fireEvent.click(screen.getByRole("button", { name: translations.en.addJobModalEnterManually }));
|
||||
expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
fireEvent.click(screen.getByRole("button", { name: `${translations.en.addJobModalDateApplied} choose` }));
|
||||
fireEvent.change(screen.getByRole("combobox", { name: translations.en.company }), { target: { value: "Synthetic school" } });
|
||||
fireEvent.change(screen.getByLabelText(translations.en.addJobModalJobTitle), { target: { value: "Teacher" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: translations.en.continue }));
|
||||
for (let step = 0; step < 3; step++) fireEvent.click(screen.getByRole("button", { name: translations.en.skipAndContinue }));
|
||||
fireEvent.click(screen.getByRole("button", { name: translations.en.createAndAddAnother }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: translations.en.addJobModalEnterManually }));
|
||||
expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
view.rerender(form(false));
|
||||
view.rerender(form(true));
|
||||
expect(screen.getByLabelText(translations.en.addJobModalDateApplied)).toHaveTextContent(expected);
|
||||
expect(client.post).toHaveBeenCalledTimes(1);
|
||||
expect(client.post).toHaveBeenCalledWith("/jobapplications", expect.objectContaining({ dateApplied: "2026-11-23" }));
|
||||
expect(client.put).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test.each(["en", "nb"] as const)("%s Add date-only picker round trip retains the selected day and existing creation payload", async language => {
|
||||
localStorage.setItem("uiLanguage", language);
|
||||
|
||||
Reference in New Issue
Block a user