From 4b1195560c5c37f00a48b0c9be657eacde2bef0a Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Sun, 29 Oct 2023 09:34:59 +0000 Subject: [PATCH] test: Convert custom filter samples from placeholders to query properties --- ...es.test.file_properties_task.file.folder_docs.approved.md | 5 ++--- ...est.file_properties_task.file.folder_results.approved.txt | 5 ++--- .../CustomFiltering/CustomFilteringExamples.test.ts | 5 ++--- .../ScriptingReference/VerifyFunctionFieldSamples.ts | 5 +++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_docs.approved.md b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_docs.approved.md index 7c56ef4f12..4839f6c5ff 100644 --- a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_docs.approved.md +++ b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_docs.approved.md @@ -15,14 +15,13 @@ filter by function task.file.folder.includes("Work/Projects/") - Find tasks in files in a specific folder **and any sub-folders**. ```javascript -filter by function task.file.folder.includes( '{{query.file.folder}}' ) +filter by function task.file.folder.includes( query.file.folder ) ``` - Find tasks in files in the folder that contains the query **and any sub-folders**. -- Note that the placeholder text is expanded to a raw string, so needs to be inside quotes. ```javascript -filter by function task.file.folder === '{{query.file.folder}}' +filter by function task.file.folder === query.file.folder ``` - Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**). diff --git a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_results.approved.txt b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_results.approved.txt index ea0916b978..2bbea7f10e 100644 --- a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_results.approved.txt +++ b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.file_properties_task.file.folder_results.approved.txt @@ -18,9 +18,8 @@ Find tasks in files in a specific folder **and any sub-folders**. ==================================================================================== -filter by function task.file.folder.includes( '{{query.file.folder}}' ) +filter by function task.file.folder.includes( query.file.folder ) Find tasks in files in the folder that contains the query **and any sub-folders**. -Note that the placeholder text is expanded to a raw string, so needs to be inside quotes. => - [ ] xyz in a/b.md - [ ] xyz in a/b/c.md @@ -31,7 +30,7 @@ Note that the placeholder text is expanded to a raw string, so needs to be insid ==================================================================================== -filter by function task.file.folder === '{{query.file.folder}}' +filter by function task.file.folder === query.file.folder Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**). => - [ ] xyz in a/b.md diff --git a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.ts b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.ts index c63bae476b..c39a444eb2 100644 --- a/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.ts +++ b/tests/Scripting/ScriptingReference/CustomFiltering/CustomFilteringExamples.test.ts @@ -235,12 +235,11 @@ describe('file properties', () => { 'Find tasks in files in a specific folder **and any sub-folders**', ], [ - "filter by function task.file.folder.includes( '{{query.file.folder}}' )", + 'filter by function task.file.folder.includes( query.file.folder )', 'Find tasks in files in the folder that contains the query **and any sub-folders**', - 'Note that the placeholder text is expanded to a raw string, so needs to be inside quotes.', ], [ - "filter by function task.file.folder === '{{query.file.folder}}'", + 'filter by function task.file.folder === query.file.folder', 'Find tasks in files in the folder that contains the query only (**not tasks in any sub-folders**)', ], [ diff --git a/tests/Scripting/ScriptingReference/VerifyFunctionFieldSamples.ts b/tests/Scripting/ScriptingReference/VerifyFunctionFieldSamples.ts index 293fd568fd..55fcf9f2df 100644 --- a/tests/Scripting/ScriptingReference/VerifyFunctionFieldSamples.ts +++ b/tests/Scripting/ScriptingReference/VerifyFunctionFieldSamples.ts @@ -85,13 +85,14 @@ export function verifyFunctionFieldFilterSamplesOnTasks(filters: QueryInstructio const instruction = filter[0]; const comment = filter.slice(1); - const expandedInstruction = preprocessSingleInstruction(instruction, 'a/b.md'); + const path = 'a/b.md'; + const expandedInstruction = preprocessSingleInstruction(instruction, path); const filterOrErrorMessage = new FunctionField().createFilterOrErrorMessage(expandedInstruction); expect(filterOrErrorMessage).toBeValid(); const filterFunction = filterOrErrorMessage.filterFunction!; const matchingTasks: string[] = []; - const searchInfo = SearchInfo.fromAllTasks(tasks); + const searchInfo = new SearchInfo(path, tasks); for (const task of tasks) { const matches = filterFunction(task, searchInfo); if (matches) {