Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added playwright test for survey creation and issuance #6700

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class BatchProcessingCollectorTest {

@Test
public void batchingWorksAndReportsNumberOfItemsProcessed() {
ArrayList<String> data = ListUtilities.newArrayList("A", "B", "C", "D");
List<String> batched = new ArrayList<>();

BatchProcessingCollector<String> batchProcessor = new BatchProcessingCollector<>(
3,
xs -> {
batched.add(StringUtilities.join(xs, "!"));
});

Integer rc = data
.stream()
.collect(batchProcessor);

assertEquals(4, rc, "Should have processed all input items");
assertEquals(ListUtilities.asList("A!B!C", "D"), batched);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Columns_toOffsetTest {

@Test
public void toOffset() {
assertEquals(Columns.A, Columns.toOffset("A"));
assertEquals(Columns.BA, Columns.toOffset("BA"));
assertEquals(53, Columns.toOffset("BB"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.List;

import static org.finos.waltz.common.ListUtilities.getOrDefault;
import static org.finos.waltz.common.TestUtilities.assertLength;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ListUtilities_getOrDefaultTest {

@Test
public void getOrDefaultTests(){
List<String> arr = ListUtilities.newArrayList("a", "b");
assertEquals("a", getOrDefault(arr, 0, "z"));
assertEquals("b", getOrDefault(arr, 1, "z"));
assertEquals("z", getOrDefault(arr, 100, "z"));
assertEquals("z", getOrDefault(arr, -1, "z"));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.finos.waltz.common.StreamUtilities.mkSiphon;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class StreamUtilities_siphonTest {

@Test
public void siphon(){
StreamUtilities.Siphon<String> siphon = mkSiphon(x -> x.startsWith("h"));

List<String> result = Stream
.of("hello", "world", "happy", "earth", "hip", "hip", "hooray")
.filter(siphon)
.collect(Collectors.toList());

assertEquals(ListUtilities.asList("world", "earth"), result);
assertTrue(siphon.hasResults());
assertEquals(ListUtilities.asList("hello", "happy", "hip", "hip", "hooray"), siphon.getResults());

}
}
3 changes: 2 additions & 1 deletion waltz-ng/client/survey/survey-run-create.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
</waltz-survey-run-create-recipient>


<div ng-if="ctrl.step === 'COMPLETED'">
<div ng-if="ctrl.step === 'COMPLETED'"
data-testid="issuance-confirmation">
<h4><strong>Issue Survey</strong></h4>
<hr/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

import static org.finos.waltz.schema.tables.Person.PERSON;
Expand All @@ -29,7 +30,7 @@ public Long createPerson(String name) {
p.setEmail(name);
p.setKind(PersonKind.EMPLOYEE.name());
p.setDisplayName(name);
p.setEmployeeId(Long.toString(ctr.incrementAndGet()));
p.setEmployeeId(UUID.randomUUID().toString());
p.insert();

return p.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
import org.finos.waltz.common.StringUtilities;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;

import static java.lang.String.format;
import static org.finos.waltz.common.StringUtilities.mkPath;

public class ScreenshotHelper {

private AtomicInteger counter = new AtomicInteger(0);
private boolean paused = false;

private final Page page;
private final String basePath;

Expand All @@ -19,20 +26,63 @@ public ScreenshotHelper(Page page, String basePath) {


public Locator takeElemSnapshot(Locator locator, String name) {
locator.screenshot(new Locator
.ScreenshotOptions()
.setPath(Paths.get(mkPath(basePath, name))));
if (! paused) {
Locator.ScreenshotOptions options = new Locator.ScreenshotOptions()
.setPath(mkPath(name));

locator.screenshot(options);
}
return locator;
}


public Locator takePageSnapshot(Locator locator, String name) {
public Page takePageSnapshot(Page page, String name) {
if (! paused) {
Page.ScreenshotOptions options = new Page.ScreenshotOptions()
.setPath(mkPath(name));

page.screenshot(options);
}
return page;
}


public Locator takePageSnapshot(Locator locator, String name) {
locator.waitFor();

page.screenshot(new Page
.ScreenshotOptions()
.setPath(Paths.get(mkPath(basePath, name))));
locator.scrollIntoViewIfNeeded();

if (! paused) {
Page.ScreenshotOptions options = new Page
.ScreenshotOptions()
.setPath(mkPath(name));

page.screenshot(options);
}

return locator;
}


public ScreenshotHelper pause() {
this.paused = true;
return this;
}


public ScreenshotHelper resume() {
this.paused = false;
return this;
}


// -- HELPER ---

private Path mkPath(String name) {
return Paths.get(StringUtilities.mkPath(
basePath,
format("%d_%s", counter.incrementAndGet(), name)));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* List of the waltz ui sections and their id's.
*/
public enum Section {
APP_SURVEYS(17),
ASSESSMENTS(200),
BOOKMARKS(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public void add() throws InterruptedException {

screenshotHelper.takePageSnapshot(
listLocator,
"1_show_list.png");
"show_list.png");

listLocator
.getByTestId("create-rule")
.click();

Locator formLocator = screenshotHelper.takePageSnapshot(
page.getByTestId("flow-classification-rule-editor"),
"2_create_rule.png");
"create_rule.png");

formLocator
.locator("#source")
Expand All @@ -73,7 +73,7 @@ public void add() throws InterruptedException {
.locator("#source")
.locator(".autocomplete-list-item")
.locator(format("text=%s", toName(appRef))),
"3_select_app.png");
"select_app.png");

appLocator.click();

Expand All @@ -82,7 +82,7 @@ public void add() throws InterruptedException {
formLocator
.locator("#datatype")
.locator("text=Book Data"),
"4_select_datatype.png")
"select_datatype.png")
.click();

formLocator
Expand All @@ -96,7 +96,7 @@ public void add() throws InterruptedException {
.locator("#scope")
.locator(".autocomplete-list-item")
.locator("text=CEO Office"),
"5_select_scope.png")
"select_scope.png")
.click();

Locator ratingLocator = formLocator
Expand All @@ -107,7 +107,7 @@ public void add() throws InterruptedException {

screenshotHelper.takePageSnapshot(
ratingLocator,
"6_select_rating.png");
"select_rating.png");

formLocator
.locator("button[type=submit]")
Expand All @@ -118,7 +118,7 @@ public void add() throws InterruptedException {

screenshotHelper.takePageSnapshot(
page.locator(".waltz-flow-classification-rules-table"),
"7_result.png");
"result.png");

Thread.sleep(1000);

Expand All @@ -130,7 +130,7 @@ public void add() throws InterruptedException {

screenshotHelper.takePageSnapshot(
page.getByTestId("source"),
"8_view.png");
"view.png");

assertThat(page.getByTestId("source")).containsText(toName(appRef));
assertThat(page.getByTestId("data-type")).containsText("Book Data");
Expand Down
Loading
Loading