mirror of
https://github.com/callumalpass/tasknotes.git
synced 2026-07-22 12:50:26 +00:00
fix tests for nlp-core import and jsdom textencoder
This commit is contained in:
parent
51f85f3171
commit
b93380032d
6 changed files with 60 additions and 1417 deletions
|
|
@ -11,6 +11,7 @@ module.exports = {
|
|||
},
|
||||
setupFilesAfterEnv: ['<rootDir>/tests/test-setup.ts'],
|
||||
moduleNameMapper: {
|
||||
'^tasknotes-nlp-core$': '<rootDir>/../tasknotes-nlp-core/src/index.ts',
|
||||
'^obsidian$': '<rootDir>/tests/__mocks__/obsidian.ts',
|
||||
'^@fullcalendar/(.*)$': '<rootDir>/tests/__mocks__/fullcalendar.ts',
|
||||
// Keep mocks for complex/large libraries that benefit from controlled testing
|
||||
|
|
@ -40,4 +41,4 @@ module.exports = {
|
|||
testTimeout: 10000,
|
||||
clearMocks: true,
|
||||
restoreMocks: true
|
||||
};
|
||||
};
|
||||
|
|
|
|||
25
package-lock.json
generated
25
package-lock.json
generated
|
|
@ -23,6 +23,7 @@
|
|||
"obsidian-daily-notes-interface": "^0.9.4",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rrule": "^2.8.1",
|
||||
"tasknotes-nlp-core": "^0.1.0",
|
||||
"yaml": "^2.3.1",
|
||||
"zod": "^3.24.0"
|
||||
},
|
||||
|
|
@ -54,6 +55,19 @@
|
|||
"typescript": "^5.9.2"
|
||||
}
|
||||
},
|
||||
"../tasknotes-nlp-core": {
|
||||
"version": "0.1.0",
|
||||
"extraneous": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chrono-node": "^2.7.5",
|
||||
"date-fns": "^4.1.0",
|
||||
"rrule": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
|
||||
|
|
@ -13060,6 +13074,17 @@
|
|||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/tasknotes-nlp-core": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tasknotes-nlp-core/-/tasknotes-nlp-core-0.1.0.tgz",
|
||||
"integrity": "sha512-A8yw2D8VO9VD+h21c5rJ040VcIga+phUo5/XY49tFAfViahSYUNtZUPNCSZUci59DK9cFsZ0MB81arHJyQd5+Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chrono-node": "^2.7.5",
|
||||
"date-fns": "^4.1.0",
|
||||
"rrule": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/test-exclude": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
"typescript": "^5.9.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"tasknotes-nlp-core": "^0.1.0",
|
||||
"@codemirror/view": "^6.37.2",
|
||||
"@fullcalendar/core": "^6.1.17",
|
||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
||||
|
|
|
|||
|
|
@ -790,12 +790,15 @@ export function generateRecurringTaskInstances(
|
|||
const recurringDates = generateRecurringInstances(task, startDate, adjustedEndDate);
|
||||
|
||||
// Filter instances to only show those within the original visible date range
|
||||
const endDateTime = endDate.getTime();
|
||||
// Compare by date only (not time) since FullCalendar boundaries are at midnight local time
|
||||
// but RRule generates occurrences at the task's scheduled time in UTC (issue #1582)
|
||||
const endDateOnly = formatDateForStorage(endDate);
|
||||
for (const date of recurringDates) {
|
||||
const instanceDate = formatDateForStorage(date);
|
||||
|
||||
// Skip instances outside the original visible range (for yearly tasks with extended look-ahead)
|
||||
if (date.getTime() > endDateTime) {
|
||||
// Compare dates as strings (YYYY-MM-DD) to avoid timezone/time issues
|
||||
if (instanceDate > endDateOnly) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2,11 +2,20 @@
|
|||
* Global test setup for TaskNotes plugin tests
|
||||
* This file is run once before all tests
|
||||
*/
|
||||
import { TextDecoder, TextEncoder } from "util";
|
||||
|
||||
// Mock global objects and APIs that would normally be provided by Obsidian
|
||||
(global as any).window = global.window || {};
|
||||
(global as any).document = global.document || {};
|
||||
|
||||
if (!(global as any).TextEncoder) {
|
||||
(global as any).TextEncoder = TextEncoder;
|
||||
}
|
||||
|
||||
if (!(global as any).TextDecoder) {
|
||||
(global as any).TextDecoder = TextDecoder;
|
||||
}
|
||||
|
||||
// Store the original createElement to avoid recursion
|
||||
const originalCreateElement = document.createElement;
|
||||
|
||||
|
|
@ -226,4 +235,4 @@ export const TestUtils = {
|
|||
};
|
||||
|
||||
// Export for use in individual test files
|
||||
export default TestUtils;
|
||||
export default TestUtils;
|
||||
|
|
|
|||
Loading…
Reference in a new issue