diff --git a/packages/com.sncommunity.advanced-checklist/src/common/utils.test.ts b/packages/com.sncommunity.advanced-checklist/src/common/utils.test.ts
index fcbef446..e63bacb9 100644
--- a/packages/com.sncommunity.advanced-checklist/src/common/utils.test.ts
+++ b/packages/com.sncommunity.advanced-checklist/src/common/utils.test.ts
@@ -92,18 +92,18 @@ describe('groupTasksByCompletedStatus', () => {
id: 'test-1',
description: 'Testing #1',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-2',
description: 'Testing #2',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-3',
description: 'Testing #3',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -124,13 +124,13 @@ describe('getTaskArrayFromGroupedTasks', () => {
{
id: 'test-b-1',
description: 'Test #1',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-b-2',
description: 'Test #2',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -138,13 +138,13 @@ describe('getTaskArrayFromGroupedTasks', () => {
{
id: 'test-c-1',
description: 'Test #3',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-c-2',
description: 'Test #4',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -190,13 +190,13 @@ describe('getPlainPreview', () => {
{
id: 'test-b-1',
description: 'Test #1',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-b-2',
description: 'Test #2',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -204,18 +204,18 @@ describe('getPlainPreview', () => {
{
id: 'test-c-1',
description: 'Test #3',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-c-2',
description: 'Test #4',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-c-3',
description: 'Test #5',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -263,19 +263,19 @@ describe('parseMarkdownTasks', () => {
id: expect.any(String),
description: 'Foo',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: expect.any(String),
description: 'Bar',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: expect.any(String),
description: 'Foobar',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
sections: DEFAULT_SECTIONS,
diff --git a/packages/com.sncommunity.advanced-checklist/src/common/utils.ts b/packages/com.sncommunity.advanced-checklist/src/common/utils.ts
index bbb8be71..6846183d 100644
--- a/packages/com.sncommunity.advanced-checklist/src/common/utils.ts
+++ b/packages/com.sncommunity.advanced-checklist/src/common/utils.ts
@@ -73,7 +73,7 @@ function createTaskFromLine(rawTask: string): TaskModel | undefined {
id: uuidv4(),
description,
completed: IS_COMPLETED.test(rawTask),
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
}
}
@@ -127,7 +127,7 @@ export function isLastActiveGroup(allGroups: GroupModel[], groupName: string): b
if (!current.lastActive) {
return prev
}
- return prev.lastActive > current.lastActive ? prev : current
+ return new Date(prev.lastActive) > new Date(current.lastActive) ? prev : current
})
return lastActiveGroup.name === groupName
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/MergeTaskGroups.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/MergeTaskGroups.test.tsx
index 5cd6b9f5..8c7aa8f6 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/MergeTaskGroups.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/MergeTaskGroups.test.tsx
@@ -21,7 +21,7 @@ it('renders the alert dialog when no groups are available to merge', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -54,7 +54,7 @@ it('renders the alert dialog when there are groups available to merge', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -65,7 +65,7 @@ it('renders the alert dialog when there are groups available to merge', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -76,7 +76,7 @@ it('renders the alert dialog when there are groups available to merge', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -117,7 +117,7 @@ it('should close the dialog if no group is selected and the Merge button is clic
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -128,7 +128,7 @@ it('should close the dialog if no group is selected and the Merge button is clic
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -139,7 +139,7 @@ it('should close the dialog if no group is selected and the Merge button is clic
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -180,7 +180,7 @@ it('should dispatch the action to merge groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -191,7 +191,7 @@ it('should dispatch the action to merge groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -202,7 +202,7 @@ it('should dispatch the action to merge groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/NotePreview.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/NotePreview.test.tsx
index 83801234..8f7969d5 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/NotePreview.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/NotePreview.test.tsx
@@ -6,13 +6,13 @@ const workTasks = [
{
id: 'test-b-1',
description: 'Test #1',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-b-2',
description: 'Test #2',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -20,13 +20,13 @@ const personalTasks = [
{
id: 'test-c-1',
description: 'Test #3',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-c-2',
description: 'Test #4',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -34,12 +34,12 @@ const miscTasks = [
{
id: 'test-d-1',
description: 'Test #5',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-d-2',
description: 'Test #6',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
]
@@ -123,7 +123,7 @@ it('should render a summary of the remaining group(s)', () => {
{
id: 'test-e-1',
description: 'Test #7',
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
sections: DEFAULT_SECTIONS,
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/RenameTaskGroups.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/RenameTaskGroups.test.tsx
index 81d99262..efdae7ab 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/RenameTaskGroups.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/RenameTaskGroups.test.tsx
@@ -21,7 +21,7 @@ it('renders the alert dialog with an input box', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -54,7 +54,7 @@ it('should dispatch the action to merge groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -65,7 +65,7 @@ it('should dispatch the action to merge groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -118,7 +118,7 @@ it('should dispatch the action to merge groups on Enter press', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -129,7 +129,7 @@ it('should dispatch the action to merge groups on Enter press', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskGroup.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskGroup.test.tsx
index 802362f3..49e259bd 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskGroup.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskGroup.test.tsx
@@ -12,13 +12,13 @@ const defaultGroup = {
id: 'test-1',
description: 'Testing',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-2',
description: 'Testing',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
sections: DEFAULT_SECTIONS,
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskItem.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskItem.test.tsx
index f3008151..45be6a54 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskItem.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskItem.test.tsx
@@ -9,7 +9,7 @@ const task: TaskModel = {
id: 'test-1',
description: 'Testing #1',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
}
it('renders a check box and textarea input', async () => {
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskSectionList.test.tsx b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskSectionList.test.tsx
index c6ba6506..8fede62a 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskSectionList.test.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/TaskSectionList.test.tsx
@@ -12,13 +12,13 @@ const defaultGroup: GroupModel = {
id: 'test-1',
description: 'Testing #1',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'test-2',
description: 'Testing #2',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
sections: [
@@ -53,7 +53,7 @@ it('renders the completed tasks section', () => {
id: 'test-3',
description: 'Testing #3',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
})
testRender()
@@ -91,7 +91,7 @@ it('renders default sections', () => {
id: 'test-3',
description: 'Testing #3',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
}
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/migrations/MigrationService.spec.ts b/packages/com.sncommunity.advanced-checklist/src/features/tasks/migrations/MigrationService.spec.ts
index 85070d50..1ee6733a 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/migrations/MigrationService.spec.ts
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/migrations/MigrationService.spec.ts
@@ -34,13 +34,13 @@ describe('MigrationService', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
collapsed: true,
@@ -52,7 +52,7 @@ describe('MigrationService', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -80,7 +80,7 @@ describe('MigrationService', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
collapsed: true,
@@ -92,7 +92,7 @@ describe('MigrationService', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -117,7 +117,7 @@ describe('MigrationService', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
collapsed: true,
@@ -129,7 +129,7 @@ describe('MigrationService', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.test.ts b/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.test.ts
index 35981e3e..b70190db 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.test.ts
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.test.ts
@@ -58,7 +58,7 @@ it('should handle a task being added to the existing tasks store', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -84,13 +84,13 @@ it('should handle a task being added to the existing tasks store', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -110,7 +110,7 @@ it('should handle an existing task being modified', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
sections: DEFAULT_SECTIONS,
@@ -137,8 +137,8 @@ it('should handle an existing task being modified', () => {
id: 'some-id',
description: 'Task description changed',
completed: false,
- createdAt: expect.any(Date),
- updatedAt: expect.any(Date),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
},
],
sections: DEFAULT_SECTIONS,
@@ -159,7 +159,7 @@ it('should not modify tasks if an invalid id is provided', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -185,7 +185,7 @@ it('should not modify tasks if an invalid id is provided', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -205,7 +205,7 @@ it('should keep completed field as-is, if task is modified', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -234,8 +234,8 @@ it('should keep completed field as-is, if task is modified', () => {
id: 'some-id',
description: 'New description',
completed: false,
- createdAt: expect.any(Date),
- updatedAt: expect.any(Date),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
},
],
},
@@ -255,7 +255,7 @@ it('should handle an existing task being toggled', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -273,9 +273,9 @@ it('should handle an existing task being toggled', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
- updatedAt: expect.any(Date),
- completedAt: expect.any(Date),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
+ completedAt: expect.any(String),
},
],
},
@@ -295,19 +295,19 @@ test('toggled tasks should be on top of the list', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'extra-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -325,21 +325,21 @@ test('toggled tasks should be on top of the list', () => {
id: 'another-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
- updatedAt: expect.any(Date),
- completedAt: expect.any(Date),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
+ completedAt: expect.any(String),
},
{
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'extra-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -359,7 +359,7 @@ it('should handle an existing completed task being toggled', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -377,8 +377,8 @@ it('should handle an existing completed task being toggled', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
- updatedAt: expect.any(Date),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
},
],
},
@@ -398,13 +398,13 @@ it('should handle an existing task being deleted', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -422,7 +422,7 @@ it('should handle an existing task being deleted', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -442,19 +442,19 @@ it('should handle opening all tasks that are marked as completed', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -472,19 +472,19 @@ it('should handle opening all tasks that are marked as completed', () => {
id: 'some-id',
description: 'A simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -504,19 +504,19 @@ it('should handle clear all completed tasks', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -534,7 +534,7 @@ it('should handle clear all completed tasks', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -554,7 +554,7 @@ it('should handle loading tasks into the tasks store, if an invalid payload is p
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -586,7 +586,7 @@ it('should initialize the storage with an empty object', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -618,19 +618,19 @@ it('should handle loading tasks into the tasks store, with a valid payload', ()
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -728,7 +728,7 @@ it('should handle adding an existing task group', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -750,19 +750,19 @@ it('should handle reordering tasks from the same section', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -790,19 +790,19 @@ it('should handle reordering tasks from the same section', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -822,19 +822,19 @@ it('should handle reordering tasks from different sections', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -862,19 +862,19 @@ it('should handle reordering tasks from different sections', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -883,7 +883,7 @@ it('should handle reordering tasks from different sections', () => {
})
it('should handle reordering task groups', () => {
- const defaultCreatedAt = new Date()
+ const defaultCreatedAt = new Date().toISOString()
const previousState: TasksState = {
schemaVersion: '1.0.0',
@@ -988,7 +988,7 @@ it('should handle deleting groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -999,7 +999,7 @@ it('should handle deleting groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1010,7 +1010,7 @@ it('should handle deleting groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1030,7 +1030,7 @@ it('should handle deleting groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1041,7 +1041,7 @@ it('should handle deleting groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1063,7 +1063,7 @@ it('should not merge the same group', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1074,7 +1074,7 @@ it('should not merge the same group', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1085,7 +1085,7 @@ it('should not merge the same group', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1109,7 +1109,7 @@ it('should handle merging groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1120,7 +1120,7 @@ it('should handle merging groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1131,7 +1131,7 @@ it('should handle merging groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1154,7 +1154,7 @@ it('should handle merging groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1165,13 +1165,13 @@ it('should handle merging groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
{
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1191,7 +1191,7 @@ it('should handle renaming a group', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1202,7 +1202,7 @@ it('should handle renaming a group', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1222,7 +1222,7 @@ it('should handle renaming a group', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1233,7 +1233,7 @@ it('should handle renaming a group', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1253,7 +1253,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1264,7 +1264,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1275,7 +1275,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1295,7 +1295,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1306,7 +1306,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1317,7 +1317,7 @@ it("should rename a group and preserve it's current order", () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1337,7 +1337,7 @@ it('should handle collapsing groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1348,7 +1348,7 @@ it('should handle collapsing groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1359,7 +1359,7 @@ it('should handle collapsing groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1382,7 +1382,7 @@ it('should handle collapsing groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1394,7 +1394,7 @@ it('should handle collapsing groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1405,7 +1405,7 @@ it('should handle collapsing groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1427,7 +1427,7 @@ it('should handle saving task draft for groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1438,7 +1438,7 @@ it('should handle saving task draft for groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1449,7 +1449,7 @@ it('should handle saving task draft for groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1469,7 +1469,7 @@ it('should handle saving task draft for groups', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1480,7 +1480,7 @@ it('should handle saving task draft for groups', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1492,7 +1492,7 @@ it('should handle saving task draft for groups', () => {
id: 'yet-another-id',
description: 'Yet another simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1514,7 +1514,7 @@ it('should handle setting a group as last active', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1525,7 +1525,7 @@ it('should handle setting a group as last active', () => {
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
},
],
},
@@ -1545,19 +1545,19 @@ it('should handle setting a group as last active', () => {
id: 'some-id',
description: 'A simple task',
completed: true,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
{
name: 'Testing',
- lastActive: expect.any(Date),
+ lastActive: expect.any(String),
tasks: [
{
id: 'another-id',
description: 'Another simple task',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
@@ -1579,9 +1579,116 @@ it('should detect and load legacy content', () => {
id: expect.any(String),
description: 'Foo bar',
completed: false,
- createdAt: expect.any(Date),
+ createdAt: expect.any(String),
},
],
},
})
})
+
+describe('Backward Compatibility - JSON Serialization Handling', () => {
+ it('should handle legacy notes that had Date objects (via JSON serialization)', () => {
+ const previousState: TasksState = {
+ schemaVersion: LATEST_SCHEMA_VERSION,
+ defaultSections: DEFAULT_SECTIONS,
+ groups: [],
+ }
+
+ // Simulate the actual scenario: old code created Date objects,
+ // but when saved/loaded through JSON, they become strings
+ const legacyDate = new Date('2023-01-15T10:30:00.000Z')
+
+ // This is what the old code would have created in memory
+ const legacyTasksInMemory = {
+ schemaVersion: LATEST_SCHEMA_VERSION,
+ groups: [
+ {
+ name: 'Legacy Tasks',
+ tasks: [
+ {
+ id: 'legacy-task-1',
+ description: 'Task created with old code',
+ completed: false,
+ createdAt: legacyDate, // Date object in old code
+ },
+ {
+ id: 'legacy-task-2',
+ description: 'Another legacy task',
+ completed: true,
+ createdAt: legacyDate,
+ updatedAt: legacyDate,
+ completedAt: legacyDate,
+ },
+ ],
+ lastActive: legacyDate,
+ },
+ ],
+ }
+
+ // But when saved and loaded, JSON.stringify/parse converts Date → string
+ const serializedPayload = JSON.stringify(legacyTasksInMemory)
+ const result = reducer(previousState, tasksLoaded(serializedPayload))
+
+ // Verify that the system handles this correctly
+ expect(result).toEqual({
+ schemaVersion: LATEST_SCHEMA_VERSION,
+ defaultSections: DEFAULT_SECTIONS,
+ groups: [
+ {
+ name: 'Legacy Tasks',
+ tasks: [
+ {
+ id: 'legacy-task-1',
+ description: 'Task created with old code',
+ completed: false,
+ createdAt: legacyDate.toISOString(), // Now a string
+ },
+ {
+ id: 'legacy-task-2',
+ description: 'Another legacy task',
+ completed: true,
+ createdAt: legacyDate.toISOString(),
+ updatedAt: legacyDate.toISOString(),
+ completedAt: legacyDate.toISOString(),
+ },
+ ],
+ lastActive: legacyDate.toISOString(),
+ },
+ ],
+ initialized: true,
+ })
+
+ // Explicitly verify that dates are strings, not Date objects
+ const loadedTask = result.groups[0].tasks[0]
+ expect(typeof loadedTask.createdAt).toBe('string')
+ expect(loadedTask.createdAt).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/)
+ expect(new Date(loadedTask.createdAt).getTime()).toBe(legacyDate.getTime())
+ })
+
+ it('should demonstrate that JSON serialization automatically converts Date objects', () => {
+ // This test documents the core mechanism that provides backward compatibility
+ const dataWithDateObjects = {
+ createdAt: new Date('2023-01-15T10:30:00.000Z'),
+ updatedAt: new Date('2023-02-20T15:45:30.123Z'),
+ }
+
+ // Verify initial state
+ expect(dataWithDateObjects.createdAt instanceof Date).toBe(true)
+ expect(typeof dataWithDateObjects.createdAt).toBe('object')
+
+ // Simulate the save/load cycle
+ const serialized = JSON.stringify(dataWithDateObjects)
+ const parsed = JSON.parse(serialized)
+
+ // Verify automatic conversion
+ expect(parsed.createdAt instanceof Date).toBe(false)
+ expect(typeof parsed.createdAt).toBe('string')
+ expect(parsed.createdAt).toBe('2023-01-15T10:30:00.000Z')
+ expect(parsed.updatedAt).toBe('2023-02-20T15:45:30.123Z')
+
+ // Verify that the strings are valid ISO dates
+ expect(new Date(parsed.createdAt).getTime()).toBe(dataWithDateObjects.createdAt.getTime())
+ expect(new Date(parsed.updatedAt).getTime()).toBe(dataWithDateObjects.updatedAt.getTime())
+ })
+})
+
diff --git a/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.ts b/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.ts
index 4b1712d3..af8dc50f 100644
--- a/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.ts
+++ b/packages/com.sncommunity.advanced-checklist/src/features/tasks/tasks-slice.ts
@@ -32,9 +32,9 @@ export type TaskModel = {
id: string
description: string
completed?: boolean
- createdAt: Date
- updatedAt?: Date
- completedAt?: Date
+ createdAt: string
+ updatedAt?: string
+ completedAt?: string
}
export type SectionModel = {
@@ -47,7 +47,7 @@ export type GroupModel = {
name: string
collapsed?: boolean
draft?: string
- lastActive?: Date
+ lastActive?: string
tasks: TaskModel[]
sections?: SectionModel[]
}
@@ -72,7 +72,7 @@ const tasksSlice = createSlice({
group.tasks.unshift({
...task,
completed: false,
- createdAt: new Date(),
+ createdAt: new Date().toISOString(),
})
},
taskModified(
@@ -92,7 +92,7 @@ const tasksSlice = createSlice({
return
}
currentTask.description = task.description
- currentTask.updatedAt = new Date()
+ currentTask.updatedAt = new Date().toISOString()
},
taskDeleted(state, action: PayloadAction<{ id: string; groupName: string }>) {
const { id, groupName } = action.payload
@@ -113,9 +113,9 @@ const tasksSlice = createSlice({
return
}
currentTask.completed = !currentTask.completed
- currentTask.updatedAt = new Date()
+ currentTask.updatedAt = new Date().toISOString()
if (currentTask.completed) {
- currentTask.completedAt = new Date()
+ currentTask.completedAt = new Date().toISOString()
} else {
delete currentTask.completedAt
}
@@ -289,7 +289,7 @@ const tasksSlice = createSlice({
if (!group) {
return
}
- group.lastActive = new Date()
+ group.lastActive = new Date().toISOString()
},
tasksLegacyContentMigrated(state, { payload }: PayloadAction<{ continue: boolean }>) {
if (!state.legacyContent) {
diff --git a/packages/com.sncommunity.advanced-checklist/src/index.tsx b/packages/com.sncommunity.advanced-checklist/src/index.tsx
index 39919bd0..2e2c81a7 100644
--- a/packages/com.sncommunity.advanced-checklist/src/index.tsx
+++ b/packages/com.sncommunity.advanced-checklist/src/index.tsx
@@ -1,7 +1,7 @@
import './stylesheets/main.scss'
import EditorKit, { EditorKitDelegate } from '@standardnotes/editor-kit'
-import React, { useCallback, useEffect, useRef } from 'react'
+import React, { useCallback, useEffect, useLayoutEffect, useRef } from 'react'
import ReactDOM from 'react-dom'
import { renderToString } from 'react-dom/server'
import { Provider } from 'react-redux'
@@ -86,7 +86,7 @@ const TaskEditor: React.FC = () => {
})
}, [dispatch])
- useEffect(() => {
+ useLayoutEffect(() => {
configureEditorKit()
}, [configureEditorKit])