From 97703083c707a77cb4ec28f8be6b9f3b39e5235f Mon Sep 17 00:00:00 2001 From: "Daniel W. Hieber" Date: Wed, 31 Jul 2024 13:35:07 -0500 Subject: [PATCH] NEW: Advanced Search: Source Gloss (#182) closes #182 --- data/Database.js | 12 ++++++++++++ pages/Search/Search.hbs | 15 +++++++++++++++ pages/Search/Search.test.js | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/data/Database.js b/data/Database.js index 6d3e3cdd..864b8593 100644 --- a/data/Database.js +++ b/data/Database.js @@ -13,6 +13,7 @@ function createMatchers(query, normalize) { const { caseSensitive, + gloss, regex, sourceForm, sourceUR, @@ -49,6 +50,17 @@ function createMatchers(query, normalize) { return createStringTester(`form`) }, + gloss() { + + const q = normalize(cleanSearch(gloss)) + const test = createSearchRegExp(q, { caseSensitive, regex }) + + return function testSourceForm(component) { + return component.tokens?.some(token => test(normalize(token.gloss))) + } + + }, + /** * NB: This function only runs when the "Language" setting is not `all`. */ diff --git a/pages/Search/Search.hbs b/pages/Search/Search.hbs index 266e78a3..8e011010 100644 --- a/pages/Search/Search.hbs +++ b/pages/Search/Search.hbs @@ -217,6 +217,21 @@ value='{{ query.sourceUR }}' > + + + diff --git a/pages/Search/Search.test.js b/pages/Search/Search.test.js index 33715422..3e97bf24 100644 --- a/pages/Search/Search.test.js +++ b/pages/Search/Search.test.js @@ -261,6 +261,14 @@ describe(`Search`, function() { cy.get(`.num-results`).should(`include.text`, `of 2.`) }) + it(`Sources: Glosses`, function() { + cy.visit(`/search`) + cy.contains(`label`, `Advanced Search`).click() + cy.get(`#gloss-box`).type(`by heat`) + cy.get(`#advanced-search-button`).click() + cy.get(`.num-results`).should(`include.text`, `of 62.`) + }) + it(`Option: Case Sensitive`, function() { cy.visit(`/search`) cy.contains(`label`, `Advanced Search`).click()