Skip to content

Instantly share code, notes, and snippets.

@Watcher24
Created October 9, 2019 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Watcher24/24a57798641897470b5ff4e489415a0e to your computer and use it in GitHub Desktop.
Save Watcher24/24a57798641897470b5ff4e489415a0e to your computer and use it in GitHub Desktop.
package info.magnolia.functionaltests;
import static org.junit.jupiter.api.Assertions.assertTrue;
import info.magnolia.integrationtests.rules.Cleanup;
import info.magnolia.testframework.ContentApp;
import info.magnolia.testframework.PageObjects;
import info.magnolia.testframework.Personas;
import info.magnolia.testframework.Selenium;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* This class tests different mgnl page objects calls in a more or less fluent way
* to figure out whether we have an issue with "wait" periods on the selenium side.
*/
@ExtendWith(Selenium.class)
public class FailOrWaitTest {
private ContentApp contentApp;
@BeforeEach
void setUp(PageObjects expect) {
expect.loginPage()
.login(Personas.ARMIN);
expect.findBar().openApp("Configuration");
contentApp = expect.contentApp("Configuration");
}
/**
* Creating the node config:/modules/foobar using the page objects API with some "delaying" steps.
*/
@Test
@Cleanup("config:/modules/untitled")
@Cleanup("config:/modules/foobar")
public void createContent_withArtificalStops(PageObjects expect) {
// WHEN
contentApp.selectRowByPath("/modules/");
contentApp.hitAction("Add folder");
assertTrue(contentApp.hasRow("untitled"));
if (!contentApp.rowIsSelected("untitled")) {
contentApp.clickRow("untitled");
}
contentApp.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "foobar")
.save();
// THEN
assertTrue(contentApp.hasRow("foobar"));
}
/**
* Creating the node config:/modules/foobar using the page objects API the most fluent way.
*/
@Test
@Cleanup("config:/modules/untitled")
@Cleanup("config:/modules/foobar")
public void createContent_fullyFluent(PageObjects expect) {
// WHEN
contentApp.selectRowByPath("/modules/");
contentApp.hitAction("Add folder");
contentApp.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "foobar")
.save();
// THEN
assertTrue(contentApp.hasRow("foobar"));
}
/**
* Creating JCR content config:/modules/foobar/goodies/@beer using the page objects API with some "delaying" steps.
*/
@Test
@Cleanup("config:/modules/untitled")
@Cleanup("config:/modules/foobar")
public void createMoreContent_withArtificalStops(PageObjects expect) {
// WHEN
// add folder "foobar" to config:/modules
contentApp.selectRowByPath("/modules/");
contentApp.hitAction("Add folder");
assertTrue(contentApp.hasRow("untitled"));
if (!contentApp.rowIsSelected("untitled")) {
contentApp.clickRow("untitled");
}
contentApp.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "foobar")
.save();
// add node "goodies" to config:/modules/foobar
if (!contentApp.rowIsSelected("foobar")) {
contentApp.clickRow("foobar");
}
contentApp.hitAction("Add content node");
assertTrue(contentApp.hasRow("untitled"));
contentApp.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "goodies")
.save();
// add the property "beer" (with a value) to /modules/foobar/goodies
if (!contentApp.rowIsSelected("goodies")) {
contentApp.clickRow("goodies");
}
contentApp.hitAction("Add property");
assertTrue(contentApp.hasRow("untitled"));
if (!contentApp.rowIsSelected("untitled")) {
contentApp.clickRow("untitled");
}
contentApp.hitAction("Edit property");
expect.form("Edit property")
.setTextField("Name", "beer")
.setTextField("Value", "Saigon Export")
.save();
assertTrue(contentApp.hasRow("beer"));
}
/**
* Creating JCR content config:/modules/foobar/goodies/@beer using the page objects API in the most fluent way.
*/
@Test
@Cleanup("config:/modules/untitled")
@Cleanup("config:/modules/foobar")
public void createMoreContent_fullyFluent(PageObjects expect) {
// WHEN
// /modules/foobar
contentApp.selectRowByPath("/modules/")
.hitAction("Add folder")
.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "foobar")
.save();
// /modules/foobar/goodies
contentApp.hitAction("Add content node")
.hitAction("Rename item");
expect.form("Rename Item")
.setTextField("Name", "goodies")
.save();
// /modules/foobar/goodies@beer
contentApp.hitAction("Add property")
.hitAction("Edit property");
expect.form("Edit property")
.setTextField("Name", "beer")
.setTextField("Value", "Saigon Export")
.save();
// THEN
assertTrue(contentApp.hasRow("beer"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment