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 2026/06/26 09:23:03 UTC
(myfaces-tobago) branch main updated: test(ajax-queue): removing toasts
This is an automated email from the ASF dual-hosted git repository.
henningn 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 8d8b951e99 test(ajax-queue): removing toasts
8d8b951e99 is described below
commit 8d8b951e995ce6dc16d3e1027194caa2ca8764b7
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Jun 25 13:17:24 2026 +0200
test(ajax-queue): removing toasts
Add a test for removing toasts.
---
.../src/main/ts/tobago-ajax-queue-static.test.ts | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue-static.test.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue-static.test.ts
index c5597c4b0e..e5e832eb11 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue-static.test.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue-static.test.ts
@@ -738,3 +738,69 @@ test("Ignore and remove unconnected queue item", () => {
expectQueue = [];
expect(queue).toEqual(expectQueue);
});
+
+test("tobago-toast: close all three toasts before the first Ajax request is finished", () => {
+ const queue: QueueItem[] = [];
+
+ document.querySelector("body").replaceChildren(); //fresh body
+ const domWrapperElement = `
+<tobago-toasts id="toastsId">
+ <input id="toastsId::states" name="toastsId" type="hidden"
+ value="{'toast-id-1':{'state':'showed','hideTime':null},'toast-id-2':{'state':'showed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}">
+</tobago-toasts>
+`;
+ document.querySelector("body").insertAdjacentHTML("afterbegin", domWrapperElement);
+
+ const facesAjaxRequestFunction = () => console.log("faces.ajax.request");
+ const toasts = document.querySelector("tobago-toasts");
+ const statesInputField: HTMLInputElement = toasts.querySelector("input[id='toastsId::states']");
+
+ //close toast-1
+ statesInputField.value = "{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'showed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}";
+ AjaxQueueStatic.request(queue, toasts, null, {execute: "toastsId"}, facesAjaxRequestFunction);
+ let expectQueue: QueueItem[] = [];
+ expectQueue.push({
+ element: toasts,
+ event: null,
+ executeValues: ["{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'showed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}"],
+ renderIds: new Set<string>(),
+ func: facesAjaxRequestFunction,
+ inProgress: true
+ });
+ expect(queue).toEqual(expectQueue);
+
+ //close toast-2
+ statesInputField.value = "{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'closed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}";
+ AjaxQueueStatic.request(queue, toasts, null, {execute: "toastsId"}, facesAjaxRequestFunction);
+ expectQueue.push({
+ element: toasts,
+ event: null,
+ executeValues: ["{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'closed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}"],
+ renderIds: new Set<string>(),
+ func: facesAjaxRequestFunction,
+ inProgress: false
+ });
+ expect(queue).toEqual(expectQueue);
+
+ //close toast-3
+ statesInputField.value = "{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'closed','hideTime':null},'toast-id-3':{'state':'closed','hideTime':null}}";
+ AjaxQueueStatic.request(queue, toasts, null, {execute: "toastsId"}, facesAjaxRequestFunction);
+ expectQueue = [];
+ expectQueue.push({
+ element: toasts,
+ event: null,
+ executeValues: ["{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'showed','hideTime':null},'toast-id-3':{'state':'showed','hideTime':null}}"],
+ renderIds: new Set<string>(),
+ func: facesAjaxRequestFunction,
+ inProgress: true
+ });
+ expectQueue.push({
+ element: toasts,
+ event: null,
+ executeValues: ["{'toast-id-1':{'state':'closed','hideTime':null},'toast-id-2':{'state':'closed','hideTime':null},'toast-id-3':{'state':'closed','hideTime':null}}"],
+ renderIds: new Set<string>(),
+ func: facesAjaxRequestFunction,
+ inProgress: false
+ });
+ expect(queue).toEqual(expectQueue);
+});