trilium/code/spec/search/value_extractor.spec.js
VeKo0o 4902d66e63 Test adding an enum label type
styling fix

Added enum to promoted attribute definition parser

Fix for the dropdown

Added enumValues attr

Added support for task note type

Added support for swimlanes and swimlane dashboard

Some minor fixes regarding swimlanes

fixed a bug with ckeditor where pasting of links was not possible

restructured folders

folder-restructuring

some more restructuring

some folder restructuring

fixes for file restructuring

restored removed code

Sorted the swimlane lists by priority

sorting swimlanes and blinking based on priority

Added new func for commenting on tasks

fixed the workflow end to end

fixed the workflow end to end

Fixed the style for comments.

Added the functionality for marking tasks as Done

Added a file to track feature wish-list

Added status back to the task header. Also added relevant tags to the node_tree.

Fixed the status update on the note tree items. Also added deadline back

Adding tags to the Swimlane dashboard

Updating the dashboard view

Fixed the tags on the swimlane dashboard items

Fixed the hide/show for swimlane headers

Updated the dashboard, added the collapse and expand feature. Also added deadline to the dashboard and tasks

Prevented empty lines to be added as a comment. Also cleared task_deadline on a new task created

Adding swimlane props

Fixed the swimlane done/deprio, also added the subtasks for the tasks that have children

fixed the grouping on swimlanes, added bucket type for the main parent of tasks, added swimlane options to dashboard type, fixed deadlines, updates to how swimlanes are populated

Removed the db logs

Updated fancytree lib to the latest version

Updated gitignore

Test adding an enum label type

styling fix

Added enum to promoted attribute definition parser

Fix for the dropdown

Added enumValues attr

Added support for task note type

Added support for swimlanes and swimlane dashboard

Some minor fixes regarding swimlanes

fixed a bug with ckeditor where pasting of links was not possible

restructured folders

folder-restructuring

some more restructuring

some folder restructuring

fixes for file restructuring

restored removed code

Sorted the swimlane lists by priority

sorting swimlanes and blinking based on priority

Added new func for commenting on tasks

fixed the workflow end to end

fixed the workflow end to end

Fixed the style for comments.

Added the functionality for marking tasks as Done

Added a file to track feature wish-list

Added status back to the task header. Also added relevant tags to the node_tree.

Fixed the status update on the note tree items. Also added deadline back

Adding tags to the Swimlane dashboard

Updating the dashboard view

Fixed the tags on the swimlane dashboard items

Fixed the hide/show for swimlane headers

Updated the dashboard, added the collapse and expand feature. Also added deadline to the dashboard and tasks

Prevented empty lines to be added as a comment. Also cleared task_deadline on a new task created

Adding swimlane props

Fixed the swimlane done/deprio, also added the subtasks for the tasks that have children

all the updates as of Apr 24, 2024
2024-04-24 14:48:07 -04:00

90 lines
3.5 KiB
JavaScript

const {note} = require('./becca_mocking');
const ValueExtractor = require('../../src/services/search/value_extractor');
const becca = require('../../src/becca/becca');
const SearchContext = require("../../src/services/search/search_context");
const dsc = new SearchContext();
describe("Value extractor", () => {
beforeEach(() => {
becca.reset();
});
it("simple title extraction", async () => {
const europe = note("Europe").note;
const valueExtractor = new ValueExtractor(dsc, ["note", "title"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(europe)).toEqual("Europe");
});
it("label extraction", async () => {
const austria = note("Austria")
.label("Capital", "Vienna")
.note;
let valueExtractor = new ValueExtractor(dsc, ["note", "labels", "capital"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(austria)).toEqual("Vienna");
valueExtractor = new ValueExtractor(dsc, ["#capital"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(austria)).toEqual("Vienna");
});
it("parent/child property extraction", async () => {
const vienna = note("Vienna");
const europe = note("Europe")
.child(note("Austria")
.child(vienna));
let valueExtractor = new ValueExtractor(dsc, ["note", "children", "children", "title"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(europe.note)).toEqual("Vienna");
valueExtractor = new ValueExtractor(dsc, ["note", "parents", "parents", "title"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(vienna.note)).toEqual("Europe");
});
it("extract through relation", async () => {
const czechRepublic = note("Czech Republic").label("capital", "Prague");
const slovakia = note("Slovakia").label("capital", "Bratislava");
const austria = note("Austria")
.relation('neighbor', czechRepublic.note)
.relation('neighbor', slovakia.note);
let valueExtractor = new ValueExtractor(dsc, ["note", "relations", "neighbor", "labels", "capital"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(austria.note)).toEqual("Prague");
valueExtractor = new ValueExtractor(dsc, ["~neighbor", "labels", "capital"]);
expect(valueExtractor.validate()).toBeFalsy();
expect(valueExtractor.extract(austria.note)).toEqual("Prague");
});
});
describe("Invalid value extractor property path", () => {
it('each path must start with "note" (or label/relation)',
() => expect(new ValueExtractor(dsc, ["neighbor"]).validate()).toBeTruthy());
it("extra path element after terminal label",
() => expect(new ValueExtractor(dsc, ["~neighbor", "labels", "capital", "noteId"]).validate()).toBeTruthy());
it("extra path element after terminal title",
() => expect(new ValueExtractor(dsc, ["note", "title", "isProtected"]).validate()).toBeTruthy());
it("relation name and note property is missing",
() => expect(new ValueExtractor(dsc, ["note", "relations"]).validate()).toBeTruthy());
it("relation is specified but target note property is not specified",
() => expect(new ValueExtractor(dsc, ["note", "relations", "myrel"]).validate()).toBeTruthy());
});