From 235899075072446c7aa06e626d4cf3f50f08281f Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Mon, 5 Jul 2021 22:51:50 +0300 Subject: [PATCH 1/4] ISAICP-6521: Update the test for the similar glossary terms. --- tests/features/glossary/glossary.feature | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/features/glossary/glossary.feature b/tests/features/glossary/glossary.feature index c356023fc0..3256e10eed 100644 --- a/tests/features/glossary/glossary.feature +++ b/tests/features/glossary/glossary.feature @@ -258,16 +258,17 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and | mod | moderator | | fac1 | | And the following collections: - | title | description | state | - | Collection With Glossary | The Battle of Evermore of the battle and the BATTLE. Call it everMore or EVERmore | validated | - | The Other Collection | desc | validated | + | title | description | state | + | Collection With Glossary | The Battle of Evermore of the batTle and the BATTLE. Call it everMore or EVERmore. Also, battleship. Why not? | validated | + | The Other Collection | desc | validated | And the following collection user membership: | collection | user | roles | | Collection With Glossary | fac | facilitator | | The Other Collection | fac1 | facilitator | And glossary content: - | title | synonyms | definition | collection | - | battle | evermore | def | Collection With Glossary | + | title | synonyms | definition | collection | + | battleship | | Not to be confused with a battle of sheep | Collection With Glossary | + | battle | evermore | def | Collection With Glossary | Given I am an anonymous user When I go to the "Collection With Glossary" collection @@ -304,7 +305,10 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and # Only the first occurrence should be highlighted. And I should see the link "Battle" And I should see the link "Evermore" - But I should not see the link "battle" + And I should see the link "battleship" + And the response should contain "Battle" + And the response should contain "battleship" + But I should not see the link "batTle" And I should not see the link "BATTLE" And I should not see the link "everMore" And I should not see the link "EVERmore" @@ -315,11 +319,12 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and # All terms should be highlighted. Then I should see the link "Battle" - And I should see the link "battle" + And I should see the link "batTle" And I should see the link "BATTLE" And I should see the link "Evermore" And I should see the link "everMore" And I should see the link "EVERmore" + And I should see the link "bat" When I click "Glossary" Then I should see the link "Glossary settings" From 8f6f54049e2361e98ba7145d910a7fbbdd671d22 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Mon, 5 Jul 2021 22:58:49 +0300 Subject: [PATCH 2/4] ISAICP-6521: Sort terms so that longer terms come first. --- .../custom/collection/src/Plugin/Filter/Glossary.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/modules/custom/collection/src/Plugin/Filter/Glossary.php b/web/modules/custom/collection/src/Plugin/Filter/Glossary.php index 1f46093ccc..6ccd79826a 100644 --- a/web/modules/custom/collection/src/Plugin/Filter/Glossary.php +++ b/web/modules/custom/collection/src/Plugin/Filter/Glossary.php @@ -104,6 +104,12 @@ public function process($text, $langcode): FilterProcessResult { /** @var \Drupal\Core\Cache\RefinableCacheableDependencyInterface $cache_metadata */ [$replacements, $cache_metadata] = $this->getReplacementsMap($collection); + // The reverse ksort will ensure that when, for any reason, there are terms + // that overlap together, like "exchange", "exchange currency" and "exchange + // platform", it is ensured, that terms with longer terms, are replaced + // first and the shorter terms are coming last. + krsort($replacements); + // This collection has no glossary term entries. if (empty($replacements)) { return $result->addCacheableDependency($cache_metadata); From 38fc512e579f45ac62ecc25866ebbd7df9c743ea Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Sun, 11 Jul 2021 17:38:37 +0300 Subject: [PATCH 3/4] ISAICP-6521: Write a test that does fail without a solution. --- tests/features/glossary/glossary.feature | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/features/glossary/glossary.feature b/tests/features/glossary/glossary.feature index 3256e10eed..1af692ac08 100644 --- a/tests/features/glossary/glossary.feature +++ b/tests/features/glossary/glossary.feature @@ -258,17 +258,17 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and | mod | moderator | | fac1 | | And the following collections: - | title | description | state | - | Collection With Glossary | The Battle of Evermore of the batTle and the BATTLE. Call it everMore or EVERmore. Also, battleship. Why not? | validated | - | The Other Collection | desc | validated | + | title | description | state | + | Collection With Glossary | The Battle of Evermore of the batTle and the BATTLE. Call it everMore or EVERmore. Also, battle again. | validated | + | The Other Collection | desc | validated | And the following collection user membership: | collection | user | roles | | Collection With Glossary | fac | facilitator | | The Other Collection | fac1 | facilitator | And glossary content: - | title | synonyms | definition | collection | - | battleship | | Not to be confused with a battle of sheep | Collection With Glossary | - | battle | evermore | def | Collection With Glossary | + | title | synonyms | definition | collection | + | battle | evermore | def | Collection With Glossary | + | battle again | | Not to be confused with a battle of sheep | Collection With Glossary | Given I am an anonymous user When I go to the "Collection With Glossary" collection @@ -305,9 +305,9 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and # Only the first occurrence should be highlighted. And I should see the link "Battle" And I should see the link "Evermore" - And I should see the link "battleship" + And I should see the link "battle again" And the response should contain "Battle" - And the response should contain "battleship" + And the response should contain "battle again" But I should not see the link "batTle" And I should not see the link "BATTLE" And I should not see the link "everMore" @@ -324,7 +324,7 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and And I should see the link "Evermore" And I should see the link "everMore" And I should see the link "EVERmore" - And I should see the link "bat" + And I should see the link "battle again" When I click "Glossary" Then I should see the link "Glossary settings" From 6b549b45c87d15ca284e8994c27b6f17a50368f5 Mon Sep 17 00:00:00 2001 From: Pieter Frenssen Date: Mon, 12 Jul 2021 14:29:27 +0300 Subject: [PATCH 4/4] ISAICP-6521: Align tables. --- tests/features/glossary/glossary.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/features/glossary/glossary.feature b/tests/features/glossary/glossary.feature index 1af692ac08..528de6f874 100644 --- a/tests/features/glossary/glossary.feature +++ b/tests/features/glossary/glossary.feature @@ -258,9 +258,9 @@ Feature: As a moderator or group facilitator I want to be able to add, edit and | mod | moderator | | fac1 | | And the following collections: - | title | description | state | + | title | description | state | | Collection With Glossary | The Battle of Evermore of the batTle and the BATTLE. Call it everMore or EVERmore. Also, battle again. | validated | - | The Other Collection | desc | validated | + | The Other Collection | desc | validated | And the following collection user membership: | collection | user | roles | | Collection With Glossary | fac | facilitator |