Skip to content

Commit

Permalink
move some ztl testcases to zats and refine some testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
JamsonChan committed Dec 4, 2024
1 parent 1a6ff5a commit e06919b
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 6 deletions.
11 changes: 5 additions & 6 deletions zktest/src/main/webapp/test2/B65-ZK-1588.zul
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<zk>
<window title="new page title" border="normal">
<div>
<div height="100%">
<div height="90%">
when click the button of bandbox, the popup should be above bandbox.
</div>
<vbox>
<separator height="700px" />
<div height="10%">
<bandbox id="bd" mold="rounded" xmlns:w="client">
<bandpopup>
<vbox>
Expand Down Expand Up @@ -58,6 +57,6 @@
</vbox>
</bandpopup>
</bandbox>
</vbox>
</window>
</div>
</div>
</zk>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* B36_2973306Test.java
Purpose:
Description:
History:
Fri Nov 29 19:19:41 CST 2024, Created by jamson
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

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

import java.util.Collections;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.chrome.ChromeOptions;

import org.zkoss.test.webdriver.ExternalZkXml;
import org.zkoss.test.webdriver.ForkJVMTestOnly;
import org.zkoss.test.webdriver.WebDriverTestCase;
import org.zkoss.test.webdriver.ztl.Widget;

@ForkJVMTestOnly
public class B36_2973306Test extends WebDriverTestCase {

@RegisterExtension
public static final ExternalZkXml CONFIG = new ExternalZkXml("/test2/enable-tablet-ui-zk.xml");

@Override
protected ChromeOptions getWebDriverOptions() {
return super.getWebDriverOptions()
.setExperimentalOption("mobileEmulation", Collections.singletonMap("deviceName", "Nexus 7"));
}

@Test
public void test() {
connect();
Widget detail = jq("$detail").toWidget();
click(detail.$n("icon"));
waitResponse();
assertEquals(1, jq(detail.$n("fake")).find(">td").length());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* B50_ZK_580Test.java
Purpose:
Description:
History:
Fri Nov 29 16:29:59 CST 2024, Created by jamson
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

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

import org.junit.jupiter.api.Test;

import org.zkoss.test.webdriver.FirefoxWebDriverTestCase;
import org.zkoss.test.webdriver.ztl.JQuery;

public class B50_ZK_580Test extends FirefoxWebDriverTestCase {

@Test
public void test() {
connect();
JQuery textbox = jq(".z-textbox");
clickAt(textbox, -40, 5);
waitResponse();
String originCursorPosition = zk(textbox).eval("getSelectionRange()[0]");

mouseOver(jq(".z-label"));
waitResponse();

clickAt(textbox, -10, 5);
waitResponse();
assertNotEquals(originCursorPosition, zk(textbox).eval("getSelectionRange()[0]"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* B60_ZK_765Test.java
Purpose:
Description:
History:
Wed Dec 04 14:55:30 CST 2024, Created by jamson
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

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

import java.util.Collections;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.chrome.ChromeOptions;

import org.zkoss.test.webdriver.ExternalZkXml;
import org.zkoss.test.webdriver.ForkJVMTestOnly;
import org.zkoss.test.webdriver.WebDriverTestCase;
import org.zkoss.test.webdriver.ztl.JQuery;
import org.zkoss.test.webdriver.ztl.Widget;

@ForkJVMTestOnly
public class B60_ZK_765Test extends WebDriverTestCase {

@RegisterExtension
public static final ExternalZkXml CONFIG = new ExternalZkXml("/test2/enable-tablet-ui-zk.xml");

@Override
protected ChromeOptions getWebDriverOptions() {
return super.getWebDriverOptions()
.setExperimentalOption("mobileEmulation", Collections.singletonMap("deviceName", "iPad"));
}

@Test
public void test() {
connect();

Widget btnOne = jq("@button:eq(0)").toWidget(),
btnTwo = jq("@button:eq(1)").toWidget(),
btnThree = jq("@button:eq(2)").toWidget();

clickAndWait(btnTwo);
assertTrue(jq("$msg:contains(selected index is undefined, no selection)").exists()
|| jq("$msg:contains(selected index is -1)").exists(),
"message should be 'selected index is undefined, no selection or ... index is -1 ...'");
clickAndWait(jq(".z-listitem:contains(Item 1)"));
clickAndWait(btnTwo);
assertTrue(jq("$msg:contains(selected index is 1, widget selected is true)").exists(), "message should be 'selected index is 1, widget selected is true'");
clickAndWait(btnOne);
clickAndWait(btnTwo);
assertTrue(jq("$msg:contains(selected index is 1, widget selected is true)").exists(), "message should be 'selected index is 1, widget selected is true'");

waitResponse();
driver.navigate().refresh();
waitResponse();

clickAndWait(btnThree);
assertTrue(jq("$msg:contains(selected no selection)").exists(), "message should be 'selected no selection'");
clickAndWait(jq(".z-listitem:contains(Item 1)"));
clickAndWait(btnThree);
assertTrue(jq("$msg:contains(selected index is 1)").exists(), "message should be 'selected index is 1'");
clickAndWait(btnOne);
clickAndWait(btnThree);
assertTrue(jq("$msg:contains(selected index is 1)").exists(), "message should be 'selected index is 1'");
}

private void clickAndWait(Widget wgt) {
click(wgt);
waitResponse();
}

private void clickAndWait(JQuery jq) {
clickAndWait(jq.toWidget());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* B90_ZK_4407Test.java
Purpose:
Description:
History:
Wed Dec 04 14:27:56 CST 2024, Created by jamson
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

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

import java.util.Collections;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.chrome.ChromeOptions;

import org.zkoss.test.webdriver.ExternalZkXml;
import org.zkoss.test.webdriver.ForkJVMTestOnly;
import org.zkoss.test.webdriver.WebDriverTestCase;

@ForkJVMTestOnly
public class B90_ZK_4407Test extends WebDriverTestCase {

@RegisterExtension
public static final ExternalZkXml CONFIG = new ExternalZkXml("/test2/enable-tablet-ui-zk.xml");

@Override
protected ChromeOptions getWebDriverOptions() {
return super.getWebDriverOptions()
.setExperimentalOption("mobileEmulation", Collections.singletonMap("deviceName", "iPad"));
}

@Test
public void test() {
connect();

eval("window.scroll(0, 0)");
driver.navigate().refresh();
waitResponse();
assertNotEquals(0, jq("html").scrollTop());
sleep(1000);
click(jq("@button"));
waitResponse();
assertEquals("history.scrollRestoration: auto", getZKLog());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* F70_ZK_2410Test.java
Purpose:
Description:
History:
Fri Nov 29 17:06:39 CST 2024, Created by jamson
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

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

import org.junit.jupiter.api.Test;
import org.openqa.selenium.Keys;

import org.zkoss.test.webdriver.FirefoxWebDriverTestCase;
import org.zkoss.test.webdriver.ztl.JQuery;

public class F70_ZK_2410Test extends FirefoxWebDriverTestCase {

@Test
public void test() {
connect();
JQuery input = jq(".z-paging-input");
click(input);
waitResponse();
sendKeys(jq("body"), Keys.TAB, Keys.ENTER);
waitResponse();
assertEquals(jq(".z-paging-input").eval("val()"), "2");
}
}

0 comments on commit e06919b

Please sign in to comment.