From 715da771dfd90995ecf5f8d1dfa9d6b693ec4529 Mon Sep 17 00:00:00 2001 From: David Watkins Date: Mon, 11 Sep 2023 16:46:56 +0100 Subject: [PATCH] Added aliases to app groups - ui editor - search #6738 --- .../overview/app-group-overview.html | 2 + .../client/formly/tags-input-template.html | 2 +- .../test_common/helpers/AppGroupHelper.java | 12 +++ .../playwright/PlaywrightUtilities.java | 10 --- .../test_common/playwright/SearchHelper.java | 50 +++++++++++++ .../playwright/BasePlaywrightTest.java | 1 + .../playwright/app_group/AddAliasesTest.java | 73 +++++++++++++++++++ .../applications/ApplicationSearchTest.java | 24 ++---- .../databases/DatabaseSearchTest.java | 24 ++---- .../MeasurableRatingTests.java | 2 - .../app-group/add-aliases/template.md | 24 ++++++ 11 files changed, 176 insertions(+), 48 deletions(-) create mode 100644 waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/SearchHelper.java create mode 100644 waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/app_group/AddAliasesTest.java create mode 100644 waltz-test-common/src/test/resources/app-group/add-aliases/template.md diff --git a/waltz-ng/client/app-groups/components/overview/app-group-overview.html b/waltz-ng/client/app-groups/components/overview/app-group-overview.html index 0d15aab4f1..4bb5ee40ec 100644 --- a/waltz-ng/client/app-groups/components/overview/app-group-overview.html +++ b/waltz-ng/client/app-groups/components/overview/app-group-overview.html @@ -66,6 +66,7 @@ update @@ -76,6 +77,7 @@ No aliases defined , add one. diff --git a/waltz-ng/client/formly/tags-input-template.html b/waltz-ng/client/formly/tags-input-template.html index 5df5e73e81..d3324d0c7f 100644 --- a/waltz-ng/client/formly/tags-input-template.html +++ b/waltz-ng/client/formly/tags-input-template.html @@ -16,7 +16,7 @@ ~ --> -
+
diff --git a/waltz-test-common/src/main/java/org/finos/waltz/test_common/helpers/AppGroupHelper.java b/waltz-test-common/src/main/java/org/finos/waltz/test_common/helpers/AppGroupHelper.java index ba2333e6c2..4ece7b16a0 100644 --- a/waltz-test-common/src/main/java/org/finos/waltz/test_common/helpers/AppGroupHelper.java +++ b/waltz-test-common/src/main/java/org/finos/waltz/test_common/helpers/AppGroupHelper.java @@ -2,9 +2,11 @@ import org.finos.waltz.common.CollectionUtilities; import org.finos.waltz.common.exception.InsufficientPrivelegeException; +import org.finos.waltz.data.app_group.AppGroupMemberDao; import org.finos.waltz.model.EntityReference; import org.finos.waltz.model.app_group.AppGroup; import org.finos.waltz.model.app_group.AppGroupKind; +import org.finos.waltz.model.app_group.AppGroupMemberRole; import org.finos.waltz.model.app_group.ImmutableAppGroup; import org.finos.waltz.service.app_group.AppGroupService; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +21,9 @@ public class AppGroupHelper { @Autowired private AppGroupService appGroupService; + @Autowired + private AppGroupMemberDao appGroupMemberDao; + public Long createAppGroupWithAppRefs(String groupName, Collection appRefs) throws InsufficientPrivelegeException { Collection appIds = CollectionUtilities.map(appRefs, EntityReference::id); return createAppGroupWithAppIds(groupName, appIds); @@ -43,4 +48,11 @@ public Long createAppGroupWithAppIds(String groupName, Collection appIds) return gId; } + + public void addOwner(Long groupId, String userId) { + appGroupMemberDao.register( + groupId, + userId, + AppGroupMemberRole.OWNER); + } } diff --git a/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/PlaywrightUtilities.java b/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/PlaywrightUtilities.java index 70b2c0c343..6021667957 100644 --- a/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/PlaywrightUtilities.java +++ b/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/PlaywrightUtilities.java @@ -95,14 +95,4 @@ public static void logAppLink(EntityReference appRef) { } - - public static void startSiteSearch(Page page, - String qry) { - page.locator(".navbar-right") - .getByTestId("search-button") - .click(); - - page.locator(".wnso-search-region input[type=search]") - .fill(qry); - } } diff --git a/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/SearchHelper.java b/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/SearchHelper.java new file mode 100644 index 0000000000..5bc66c36eb --- /dev/null +++ b/waltz-test-common/src/main/java/org/finos/waltz/test_common/playwright/SearchHelper.java @@ -0,0 +1,50 @@ +package org.finos.waltz.test_common.playwright; + +import com.microsoft.playwright.Locator; +import com.microsoft.playwright.Page; + +import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; +import static java.lang.String.format; + +public class SearchHelper { + + private final Page page; + + public SearchHelper(Page page) { + this.page = page; + } + + public Locator search(String qry) { + page.locator(".navbar-right") + .getByTestId("search-button") + .click(); + + Locator searchRegion = page.locator(".wnso-search-region"); + searchRegion.locator("input[type=search]") + .fill(qry); + + return searchRegion; + } + + + public Locator waitForResult(String name) { + Locator resultLocator = getSearchResultsPanel() + .getByTestId("entity-name") + .getByText(name); + + resultLocator.waitFor(); + + return resultLocator; + } + + public void click(Locator result) { + result.click(); + + // wait for search panel to be removed + assertThat(page.locator(".wnso-search-results")).isHidden(); + } + + public Locator getSearchResultsPanel() { + return page.locator(".wnso-search-results"); + } +} diff --git a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/BasePlaywrightTest.java b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/BasePlaywrightTest.java index 63f9298c01..34860c8884 100644 --- a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/BasePlaywrightTest.java +++ b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/BasePlaywrightTest.java @@ -15,6 +15,7 @@ public abstract class BasePlaywrightTest { protected static final String BASE = "http://localhost:8000"; + protected static final String HIGHLIGHT_ELEM_SCRIPT = "d => d.style.border = '2px solid red'"; protected static Playwright playwright; protected static Browser browser; diff --git a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/app_group/AddAliasesTest.java b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/app_group/AddAliasesTest.java new file mode 100644 index 0000000000..4150f82742 --- /dev/null +++ b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/app_group/AddAliasesTest.java @@ -0,0 +1,73 @@ +package org.finos.waltz.test_common.playwright.app_group; + +import com.microsoft.playwright.Locator; +import org.finos.waltz.common.SetUtilities; +import org.finos.waltz.common.exception.InsufficientPrivelegeException; +import org.finos.waltz.model.EntityReference; +import org.finos.waltz.test_common.helpers.AppGroupHelper; +import org.finos.waltz.test_common.helpers.AppHelper; +import org.finos.waltz.test_common.playwright.BasePlaywrightIntegrationTest; +import org.finos.waltz.test_common.playwright.DocumentationHelper; +import org.finos.waltz.test_common.playwright.SearchHelper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.IOException; + +import static org.finos.waltz.common.StringUtilities.mkPath; +import static org.finos.waltz.test_common.helpers.NameHelper.mkName; +import static org.finos.waltz.test_common.playwright.PlaywrightUtilities.login; + +public class AddAliasesTest extends BasePlaywrightIntegrationTest { + + @Autowired + private AppGroupHelper appGroupHelper; + + @Autowired + private AppHelper appHelper; + + @BeforeEach + public void setup() throws IOException { + login(page, BASE); + } + + @Test + public void addAliases() throws InsufficientPrivelegeException, IOException, InterruptedException { + String aliasName = mkName("alias"); + String appGroupName = mkName("appGroup_addAlias", "group"); + String appName = mkName("appGroup_addAlias", "application"); + + EntityReference app = appHelper.createNewApp(appName, 10L); + Long groupId = appGroupHelper.createAppGroupWithAppRefs(appGroupName, SetUtilities.asSet(app)); + appGroupHelper.addOwner(groupId, "admin"); + + DocumentationHelper documentationHelper = new DocumentationHelper( + page, + "app-group/add-aliases"); + page.navigate(mkPath(BASE, "app-group", Long.toString(groupId))); + + Locator summary = page.locator(".waltz-page-summary"); + summary.getByTestId("edit-aliases").evaluate(HIGHLIGHT_ELEM_SCRIPT); + documentationHelper.takeElemSnapshot(summary, "initial-group.png"); + + summary.getByTestId("edit-aliases").first().click(); + Locator aliasesInput = summary.locator(".waltz-alias-list input"); + aliasesInput.fill(aliasName); + aliasesInput.press("Enter"); + documentationHelper.takeElemSnapshot(summary, "added-alias.png"); + + Locator closeBtn = summary.locator(".waltz-alias-list .btn").getByText("Close"); + closeBtn.click(); + documentationHelper.takeElemSnapshot(summary, "view-alias.png"); + + SearchHelper searchHelper = new SearchHelper(page); + searchHelper.search(aliasName); + documentationHelper.takePageSnapshot(page, "search.png"); + + searchHelper.waitForResult(appGroupName); + documentationHelper.takePageSnapshot(page, "search-result.png"); + + documentationHelper.prepareDocumentation(); + } +} diff --git a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/applications/ApplicationSearchTest.java b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/applications/ApplicationSearchTest.java index 45925c4861..3745642bed 100644 --- a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/applications/ApplicationSearchTest.java +++ b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/applications/ApplicationSearchTest.java @@ -5,6 +5,7 @@ import org.finos.waltz.test_common.helpers.AppHelper; import org.finos.waltz.test_common.playwright.BasePlaywrightIntegrationTest; import org.finos.waltz.test_common.playwright.DocumentationHelper; +import org.finos.waltz.test_common.playwright.SearchHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +17,6 @@ import static org.finos.waltz.common.StringUtilities.mkPath; import static org.finos.waltz.test_common.helpers.NameHelper.mkName; import static org.finos.waltz.test_common.playwright.PlaywrightUtilities.login; -import static org.finos.waltz.test_common.playwright.PlaywrightUtilities.startSiteSearch; public class ApplicationSearchTest extends BasePlaywrightIntegrationTest { @@ -43,33 +43,23 @@ public void searchForExactMatch() { page, "applications/search"); - startSiteSearch( - page, - appRef.name().orElse("??")); + SearchHelper searchHelper = new SearchHelper(page); + searchHelper.search(appRef.name().orElse("??")); - Locator resultLocator = page - .locator(".wnso-search-results") - .getByTestId("entity-name") - .locator(format( - "text=%s", - appRef.name().orElse("?"))); - resultLocator.waitFor(); + Locator result = searchHelper.waitForResult(appRef.name().orElse("?")); documentationHelper.takePageSnapshot( - resultLocator, + result, "after-typing.png"); - resultLocator - .click(); - - // wait for search panel to be removed - assertThat(page.locator(".wnso-search-results")).isHidden(); + searchHelper.click(result); Locator appPageTitleLocator = page .locator(".waltz-page-header") .getByTestId("header-small") .locator(format("text=%s", appRef.name().orElse("?"))); + assertThat(appPageTitleLocator).isVisible(); documentationHelper.takePageSnapshot(appPageTitleLocator, "clicked-link.png"); diff --git a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/databases/DatabaseSearchTest.java b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/databases/DatabaseSearchTest.java index d1b643de48..4a4bfcb925 100644 --- a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/databases/DatabaseSearchTest.java +++ b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/databases/DatabaseSearchTest.java @@ -5,6 +5,7 @@ import org.finos.waltz.test_common.helpers.DatabaseHelper; import org.finos.waltz.test_common.playwright.BasePlaywrightIntegrationTest; import org.finos.waltz.test_common.playwright.DocumentationHelper; +import org.finos.waltz.test_common.playwright.SearchHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +17,6 @@ import static org.finos.waltz.common.StringUtilities.mkPath; import static org.finos.waltz.test_common.helpers.NameHelper.mkName; import static org.finos.waltz.test_common.playwright.PlaywrightUtilities.login; -import static org.finos.waltz.test_common.playwright.PlaywrightUtilities.startSiteSearch; public class DatabaseSearchTest extends BasePlaywrightIntegrationTest { @@ -44,27 +44,15 @@ public void exactSearch() { page, "databases/search"); - startSiteSearch( - page, - dbRef.name().orElse("??")); - - Locator resultLocator = page - .locator(".wnso-search-results") - .locator(format( - "text=%s", - dbRef.name().orElse("?"))); - - resultLocator.waitFor(); + SearchHelper searchHelper = new SearchHelper(page); + searchHelper.search(dbRef.name().orElse("??")); + Locator result = searchHelper.waitForResult(dbRef.name().orElse("?")); documentationHelper.takePageSnapshot( - resultLocator, + result, "after-typing.png"); - resultLocator - .click(); - - // wait for search panel to be removed - assertThat(page.locator(".wnso-search-results")).isHidden(); + searchHelper.click(result); Locator dbPageTitleLocator = page .locator(".waltz-display-section") diff --git a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/measurable_ratings/MeasurableRatingTests.java b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/measurable_ratings/MeasurableRatingTests.java index 01208bd803..6dc69a7d3d 100644 --- a/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/measurable_ratings/MeasurableRatingTests.java +++ b/waltz-test-common/src/test/java/org/finos/waltz/test_common/playwright/measurable_ratings/MeasurableRatingTests.java @@ -21,8 +21,6 @@ public class MeasurableRatingTests extends BasePlaywrightIntegrationTest { - public static final String HIGHLIGHT_ELEM_SCRIPT = "d => d.style.border = '2px solid red'"; - @Autowired private AppHelper appHelper; diff --git a/waltz-test-common/src/test/resources/app-group/add-aliases/template.md b/waltz-test-common/src/test/resources/app-group/add-aliases/template.md new file mode 100644 index 0000000000..402bf82b66 --- /dev/null +++ b/waltz-test-common/src/test/resources/app-group/add-aliases/template.md @@ -0,0 +1,24 @@ +# App Groups + +## Adding Aliases + +Starting from an app group page, click on the _Aliases: ... add one_ link: + +{{initial-group.png}} + +You can add multiple aliases. +Each time you add an alias it is saved immediately to the database, a confirmation notification will also be displayed. + +{{added-alias.png}} + +When you have finished adding aliases click on the _close_ link to see the saved aliases. + +{{view-alias.png}} + + +## Searching + +Groups can now be searched for by their alias names. +_Note:_ the result shown gives the primary name for the group, not the alias. + +{{search-result.png}} \ No newline at end of file