From 8e0bad231daffe8f5be33f8ef8ca7272910fd33f Mon Sep 17 00:00:00 2001
From: kraaij <kraaij@astron.nl>
Date: Tue, 17 Oct 2023 11:56:03 +0200
Subject: [PATCH] wait for Item to be in the document

---
 SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js
index 289339801b5..7e47597f9a4 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js
@@ -1,5 +1,5 @@
 import {act} from "react-dom/test-utils";
-import {fireEvent, render, screen} from "@testing-library/react";
+import {fireEvent, render, screen,waitFor} from "@testing-library/react";
 import {BrowserRouter as Router} from "react-router-dom";
 
 const TIMEOUT = 300
@@ -12,6 +12,7 @@ export async function clickItem(item, timeout = TIMEOUT) {
 }
 
 export async function setMultiSelectValue(pageContent, multiSelectTestId, multiSelectValue, timeout = TIMEOUT) {
+    await waitFor(() => expect(pageContent.queryByTestId(multiSelectTestId)).toBeInTheDocument()); // give rendering the time to have it.
     await clickItem(pageContent.queryByTestId(multiSelectTestId));
 
     let items = []
-- 
GitLab