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

Port tck/faces40's Spec1567IT to selenium #1781

Merged
merged 1 commit into from
Jan 30, 2023
Merged
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
Expand Up @@ -25,6 +25,7 @@
import org.openqa.selenium.By;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class Spec1567IT extends BaseITNG {

Expand All @@ -33,35 +34,151 @@ public class Spec1567IT extends BaseITNG {
/**
* @see AjaxBehavior#getExecute()
* @see UIComponent#getCompositeComponentParent(UIComponent)
* @see https://github.com/eclipse-ee4j/mojarra/issues/5032
* @see https://github.com/jakartaee/faces/issues/1567
*/
@Test
public void testImplicitThis() throws Exception {
WebPage page = getPage("issue5032IT.xhtml");
public void test() throws Exception {
WebPage page = getPage("spec1567IT.xhtml");

ExtendedTextInput form1input2 = new ExtendedTextInput(getWebDriver(), page.findElement(By.id("form1:inputs:input2")));
form1input2.setValue("1");
form1input2.fireEvent("change");
// fill form1 input1
ExtendedTextInput input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input1")));

input1.setValue("1");
input1.fireEvent("change");
page.waitReqJs();
String form1messages = page.findElement(By.id("form1:messages")).getText();
assertEquals("there are no validation messages coming from required field form1:input1", "", form1messages);
}

/**
* @see AjaxBehavior#getExecute()
* @see UIComponent#getCompositeComponentParent(UIComponent)
* @see https://github.com/eclipse-ee4j/mojarra/issues/5032
*/
@Test
public void testExplicitThis() throws Exception {
WebPage page = getPage("issue5032IT.xhtml");
input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input1")));
ExtendedTextInput input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input2")));
ExtendedTextInput input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input3")));

ExtendedTextInput form2input2 = new ExtendedTextInput(getWebDriver(), page.findElement(By.id("form2:inputs:input2")));
form2input2.setValue("1");
form2input2.fireEvent("change");
String messages = page.findElement(By.id("form1:messages")).getText();
assertEquals("input1 is filled with 1", "1", input1.getValue());
assertEquals("input2 is empty", "", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is empty", "setForm1input1:1\nsetForm1input2:", messages);

// fill form1 input2
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input2")));
input2.setValue("1");
input2.fireEvent("change");
page.waitReqJs();
String form2messages = page.findElement(By.id("form2:messages")).getText();
assertEquals("there are no validation messages coming from required field form2:input1", "", form2messages);

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input3")));
messages = page.findElement(By.id("form1:messages")).getText();
assertEquals("input1 is filled with 1", "1", input1.getValue());
assertEquals("input2 is filled with 1", "1", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is filled", "setForm1input1:1\nsetForm1input2:1", messages);

// fill form1 input3
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input3")));
input3.setValue("1");
input3.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form1:inputs:input3")));
messages = page.findElement(By.id("form1:messages")).getText();
assertEquals("input1 is refreshed to empty string", "", input1.getValue());
assertEquals("input2 is refreshed to empty string", "", input2.getValue());
assertEquals("input3 is filled and refreshed", "1x", input3.getValue());
assertEquals("input3 is filled", "setForm1input3:1", messages);

// fill form2 input1
input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input1")));
input1.setValue("1");
input1.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input3")));

messages = page.findElement(By.id("form2:messages")).getText();
assertEquals("input1 is filled with 1", "1", input1.getValue());
assertEquals("input2 is empty", "", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is empty", "setForm2input1:1\nsetForm2input2:", messages);

// fill form2 input2
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input2")));
input2.setValue("1");
input2.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input3")));
messages = page.findElement(By.id("form2:messages")).getText();
assertEquals("input1 is filled with 1", "1", input1.getValue());
assertEquals("input2 is filled with 1", "1", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is filled", "setForm2input1:1\nsetForm2input2:1", messages);

// fill form2 input3
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input3")));
input3.setValue("1");
input3.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form2:inputs:input3")));
messages = page.findElement(By.id("form2:messages")).getText();
assertEquals("input1 is refreshed to empty string", "", input1.getValue());
assertEquals("input2 is refreshed to empty string", "", input2.getValue());
assertEquals("input3 is filled and refreshed", "1x", input3.getValue());
assertEquals("input3 is filled", "setForm2input3:1", messages);

// fill form3 input1
input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input1")));

input1.setValue("1");
input1.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input3")));

messages = page.findElement(By.id("form3:messages")).getText();
assertEquals("input1 is refreshed to 1x", "1x", input1.getValue());
assertEquals("input2 is refreshed to x", "x", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is empty", "setForm3input1:1\nsetForm3input2:", messages);

// fill form3 input2
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input2")));
input2.setValue("1");
input2.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input3")));
messages = page.findElement(By.id("form3:messages")).getText();
assertEquals("input1 is refreshed to 1xx", "1xx", input1.getValue());
assertEquals("input2 is refreshed to 1x", "1x", input2.getValue());
assertEquals("input3 is empty", "", input3.getValue());
assertEquals("input1 is filled and input2 is filled", "setForm3input1:1x\nsetForm3input2:1", messages);

// fill form3 input3
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input3")));
input3.setValue("1");
input3.fireEvent("change");
page.waitReqJs();

input1 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input1")));
input2 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input2")));
input3 = new ExtendedTextInput( getWebDriver(), page.findElement(By.id("form3:inputs:input3")));
messages = page.findElement(By.id("form3:messages")).getText();
assertEquals("input1 is refreshed to empty string", "", input1.getValue());
assertEquals("input2 is refreshed to empty string", "", input2.getValue());
assertEquals("input3 is filled and refreshed", "1x", input3.getValue());
assertEquals("input3 is filled", "setForm3input3:1", messages);
}

}