diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx index f7a9ced157..9d65b6fdd7 100644 --- a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx +++ b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx @@ -9,6 +9,7 @@ import { FormProperties, PublicFormRecord } from "@lib/types"; import { RichText } from "@clientComponents/forms"; import { Button } from "@clientComponents/globals"; import { NextButton } from "@clientComponents/forms/NextButton/NextButton"; +import { ClosingNotice } from "@clientComponents/forms/ClosingNotice/ClosingNotice"; import { FormServerErrorCodes, @@ -39,12 +40,15 @@ export const Preview = ({ }) => { const { status } = useSession(); const { i18n } = useTranslation(["common", "confirmation"]); - const { id, getSchema, getIsPublished, getSecurityAttribute } = useTemplateStore((s) => ({ - id: s.id, - getSchema: s.getSchema, - getIsPublished: s.getIsPublished, - getSecurityAttribute: s.getSecurityAttribute, - })); + const { id, getSchema, getIsPublished, getSecurityAttribute, closingDate } = useTemplateStore( + (s) => ({ + id: s.id, + getSchema: s.getSchema, + getIsPublished: s.getIsPublished, + getSecurityAttribute: s.getSecurityAttribute, + closingDate: s.closingDate, + }) + ); const isPastClosingDate = useIsFormClosed(); @@ -170,6 +174,7 @@ export const Preview = ({ ) : (
{t("closingNotice.text1")}
diff --git a/lib/utils/date/utcToEst.vitest.ts b/lib/utils/date/utcToEst.vitest.ts
new file mode 100644
index 0000000000..a134658cc2
--- /dev/null
+++ b/lib/utils/date/utcToEst.vitest.ts
@@ -0,0 +1,36 @@
+import { describe, it, expect } from 'vitest';
+import { formClosingDateEst } from './utcToEst';
+
+describe('utcToEst', () => {
+ it('should convert UTC date to EST date in English', () => {
+ const utcDate = '2023-10-01T12:00:00Z';
+ const lang = 'en';
+ const result = formClosingDateEst(utcDate, lang);
+ expect(result).toStrictEqual({
+ "day": "01",
+ "hour": "08",
+ "minute": "00",
+ "month": "October",
+ "year": "2023",
+ });
+ });
+
+ it('should convert UTC date to EST date in French', () => {
+ const utcDate = '2023-10-01T12:00:00Z';
+ const lang = 'fr';
+ const result = formClosingDateEst(utcDate, lang);
+ expect(result).toStrictEqual({
+ "day": "01",
+ "hour": "08",
+ "minute": "00",
+ "month": "octobre",
+ "year": "2023",
+ });
+ });
+
+ it('should handle invalid date input', () => {
+ const utcDate = 'invalid-date';
+ const lang = 'en';
+ expect(() => formClosingDateEst(utcDate, lang)).toThrow();
+ });
+});
\ No newline at end of file
diff --git a/package.json b/package.json
index ae3407ea0f..f85fe1a0bb 100644
--- a/package.json
+++ b/package.json
@@ -40,6 +40,7 @@
"format:check": "prettier --check .",
"test": "jest",
"test:vitest": "vitest run",
+ "test:watch:vitest": "vitest --watch",
"test:watch": "DEBUG_PRINT_LIMIT=10000 jest --watch",
"cypress": "cypress open",
"cypress:run": "CYPRESS_DEBUG=true cypress run --browser chrome",
diff --git a/vitest.config.mts b/vitest.config.mts
index d78611a678..36519cc4f7 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -6,7 +6,7 @@ export default defineConfig({
test: {
globals: true, // migration from Jest - By default, vitest does not provide global APIs for explicitness
environment: "node",
- // TODO: remove include after complete Vitest migration
- include: ["__vitests__/**/*.test.ts", "lib/vitests/**/*.test.ts"],
+ // Note: The following pattern .vitest.ts has been added to avoid conflicts with jest tests co-located with the source code
+ include: ["__vitests__/**/*.test.ts", "lib/vitests/**/*.test.ts", "**/*.vitest.+(ts|tsx|js|jsx)"],
},
});