You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2022/09/20 11:59:30 UTC
[myfaces-tobago] branch main updated: fix(demo): popup
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/main by this push:
new 1a02653769 fix(demo): popup
1a02653769 is described below
commit 1a02653769ff2080e33132be8deca9f6f464e55f
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue Sep 20 11:46:33 2022 +0200
fix(demo): popup
* fix popup demo
* add integration test
---
.../main/webapp/content/060-popup/Popup.test.js | 72 ++++++++++++++++------
.../src/main/webapp/content/060-popup/Popup.xhtml | 29 ++++-----
2 files changed, 65 insertions(+), 36 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.test.js
index 19b668a54c..7725c3b58e 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.test.js
@@ -32,8 +32,8 @@ it("Open 'Client Popup' and press 'Cancel'.", function (done) {
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", cancelButtonFn);
+ () => hiddenEventCount = 0,
+ "click", cancelButtonFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
@@ -69,8 +69,8 @@ it("Open 'Client Popup', press 'Submit' while field is empty. Press 'Cancel'.",
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", cancelButtonFn);
+ () => hiddenEventCount = 0,
+ "click", cancelButtonFn);
test.setup(() => messagesFn().length === 0, null, "click", messageCloseFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
@@ -111,11 +111,11 @@ it("Open 'Client Popup', press 'Submit' while field has content. Press 'Cancel'.
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", cancelButtonFn);
+ () => hiddenEventCount = 0,
+ "click", cancelButtonFn);
test.setup(() => outputFn().value !== "Tobago",
- () => inputFieldFn().value = "Trinidad",
- "click", submitButtonFn);
+ () => inputFieldFn().value = "Trinidad",
+ "click", submitButtonFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
test.do(() => expect(outputFn().value).not.toBe("Tobago"));
@@ -157,8 +157,8 @@ it("Open 'Client Popup', press 'Submit & Close' while field is empty.", function
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", cancelButtonFn);
+ () => hiddenEventCount = 0,
+ "click", cancelButtonFn);
test.setup(() => messagesFn().length === 0, null, "click", messageCloseFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
@@ -198,11 +198,11 @@ it("Open 'Client Popup', press 'Submit & Close' while field has content.", funct
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", cancelButtonFn);
+ () => hiddenEventCount = 0,
+ "click", cancelButtonFn);
test.setup(() => outputFn().value !== "Little Tobago",
- () => inputFieldFn().value = "Charlotteville",
- "click", submitButtonFn);
+ () => inputFieldFn().value = "Charlotteville",
+ "click", submitButtonFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
test.do(() => expect(outputFn().value).not.toBe("Little Tobago"));
@@ -238,10 +238,10 @@ it("Open 'Large Popup'.", function (done) {
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", closeButtonFn);
+ () => hiddenEventCount = 0,
+ "click", closeButtonFn);
test.setup(() => !dropdownMenuFn().classList.contains("show"),
- null, "click", dropdownButtonFn);
+ null, "click", dropdownButtonFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
test.do(() => expect(dropdownMenuFn().classList).not.toContain("show"));
@@ -278,10 +278,10 @@ it("Open 'Small Popup'.", function (done) {
const test = new JasmineTestTool(done);
test.do(() => hiddenEventCount = 1);
test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
- () => hiddenEventCount = 0,
- "click", closeButtonFn);
+ () => hiddenEventCount = 0,
+ "click", closeButtonFn);
test.setup(() => !dropdownMenuFn().classList.contains("show"),
- null, "click", dropdownButtonFn);
+ null, "click", dropdownButtonFn);
test.do(() => expect(popupFn().classList).not.toContain("show"));
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
test.do(() => expect(dropdownMenuFn().classList).not.toContain("show"));
@@ -301,3 +301,35 @@ it("Open 'Small Popup'.", function (done) {
test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
test.start();
});
+
+it("open 'refresh content popup' and press 'close'", function (done) {
+ const wrapperFn = elementByIdFn("page:mainForm:wrapperForIntegrationTest");
+ const popupFn = elementByIdFn("page:mainForm:refreshPopup");
+ const collapseFn = elementByIdFn("page:mainForm:refreshPopup::collapse");
+ const openButtonFn = elementByIdFn("page:mainForm:openRefreshPopup");
+ const closeButtonFn = elementByIdFn("page:mainForm:refreshPopup:closeRefreshPopup");
+
+ let shownEventCount = 0;
+ let hiddenEventCount = 0;
+ wrapperFn().addEventListener("shown.bs.modal", () => shownEventCount++);
+ wrapperFn().addEventListener("hidden.bs.modal", () => hiddenEventCount++);
+
+ const test = new JasmineTestTool(done);
+ test.do(() => hiddenEventCount = 1);
+ test.setup(() => collapseFn().getAttribute("value") === "true" && hiddenEventCount === 1,
+ () => hiddenEventCount = 0,
+ "click", closeButtonFn);
+ test.do(() => expect(popupFn().classList).not.toContain("show"));
+ test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
+
+ test.do(() => shownEventCount = 0);
+ test.event("click", openButtonFn, () => shownEventCount > 0);
+ test.do(() => expect(popupFn().classList).toContain("show"));
+ test.do(() => expect(collapseFn().getAttribute("value")).toBe("false"));
+
+ test.do(() => hiddenEventCount = 0);
+ test.event("click", closeButtonFn, () => hiddenEventCount > 0);
+ test.do(() => expect(popupFn().classList).not.toContain("show"));
+ test.do(() => expect(collapseFn().getAttribute("value")).toBe("true"));
+ test.start();
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.xhtml
index 03e47ca880..824deac416 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/060-popup/Popup.xhtml
@@ -170,7 +170,7 @@
<tc:section label="Popup opend after AJAX call">
<tc:button label="Open Popup" immediate="true" id="ajaxButton">
<tc:operation name="show" for="ajaxPopup"/>
- <f:ajax render="@this ajaxPopup" execute="@this ajaxPopup"/>
+ <f:ajax render="ajaxPopup" execute="ajaxPopup"/>
</tc:button>
<tc:popup id="ajaxPopup" collapsedMode="absent" markup="small">
@@ -195,23 +195,20 @@
(<tc:link link="https://issues.apache.org/jira/browse/TOBAGO-2083" label="Jira TOBAGO-2083" image="bi-box-arrow-up-right"/>)
</p>
- <tc:button label="Open Popup (to dicuss)" immediate="true">
+ <tc:button id="openRefreshPopup" label="Open Popup" immediate="true">
<tc:operation name="show" for="refreshPopup"/>
- <f:ajax render="refreshPopup:refreshPopupContent" listener="#{popupController.refreshContent}"/>
+ <f:ajax render="@this refreshPopup" execute="refreshPopup" listener="#{popupController.refreshContent}"/>
</tc:button>
- <tc:button label="Open Popup (alternative)" immediate="true">
- <tc:operation name="show" for="refreshPopup"/>
- <f:ajax render="@this refreshPopup" execute="@this refreshPopup" listener="#{popupController.refreshContent}"/>
- </tc:button>
-
- <tc:popup id="refreshPopup" collapsedMode="absent" markup="small">
- <tc:box id="refreshPopupContent" label="Current Time">
- <tc:out label="Current Time" value="#{popupController.time}"/>
- <tc:button label="Close" omit="true">
- <tc:operation name="hide" for="refreshPopup"/>
- </tc:button>
- </tc:box>
- </tc:popup>
+ <tc:panel id="wrapperForIntegrationTest">
+ <tc:popup id="refreshPopup" collapsedMode="absent" markup="small">
+ <tc:box id="refreshPopupContent" label="Current Time">
+ <tc:out label="Current Time" value="#{popupController.time}"/>
+ <tc:button id="closeRefreshPopup" label="Close" omit="true">
+ <tc:operation name="hide" for="refreshPopup"/>
+ </tc:button>
+ </tc:box>
+ </tc:popup>
+ </tc:panel>
</tc:section>
</ui:composition>