Skip to content

Commit

Permalink
Added aliases to app groups
Browse files Browse the repository at this point in the history
- ui editor
- search

finos#6738
  • Loading branch information
davidwatkins73 committed Sep 11, 2023
1 parent cfedbfc commit 715da77
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<last ng-if="$ctrl.editable">
<span class="small">
<a ng-click="$ctrl.showAliasEditor()"
data-testid="edit-aliases"
class="clickable">
update
</a>
Expand All @@ -76,6 +77,7 @@
No aliases defined
<a class="clickable"
ng-if="$ctrl.editable"
data-testid="edit-aliases"
ng-click="$ctrl.showAliasEditor()">
, add one.
</a>
Expand Down
2 changes: 1 addition & 1 deletion waltz-ng/client/formly/tags-input-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
~
-->

<div class="form-group">
<div class="form-group tags-input">
<label>{{options.templateOptions.label}}</label>
<tags-input ng-model="model[options.key]"
placeholder="{{options.templateOptions.placeholder}}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,6 +21,9 @@ public class AppGroupHelper {
@Autowired
private AppGroupService appGroupService;

@Autowired
private AppGroupMemberDao appGroupMemberDao;

public Long createAppGroupWithAppRefs(String groupName, Collection<EntityReference> appRefs) throws InsufficientPrivelegeException {
Collection<Long> appIds = CollectionUtilities.map(appRefs, EntityReference::id);
return createAppGroupWithAppIds(groupName, appIds);
Expand All @@ -43,4 +48,11 @@ public Long createAppGroupWithAppIds(String groupName, Collection<Long> appIds)
return gId;
}


public void addOwner(Long groupId, String userId) {
appGroupMemberDao.register(
groupId,
userId,
AppGroupMemberRole.OWNER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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}}

0 comments on commit 715da77

Please sign in to comment.