From 184e53a6f3812d338317746e8cbdf6d6eab6b899 Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Thu, 2 Jan 2025 10:58:11 +0000 Subject: [PATCH 1/4] AAP-36512: FIx Admin portal tests fallout due to PF5 and latest Ansible-UI-framework --- .../src/__tests__/AppHeader.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx b/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx index ac3fd067d..cde9fd4a1 100644 --- a/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx +++ b/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx @@ -2,6 +2,8 @@ import { render, screen } from "@testing-library/react"; import "@testing-library/jest-dom"; import { AppHeader } from "../AppHeader"; import { BrowserRouter } from "react-router-dom"; +import userEvent from "@testing-library/user-event"; +import { act } from "react"; describe("AppHeader", () => { // Store the original 'location' object so that it can be restored for other tests. @@ -33,5 +35,16 @@ describe("AppHeader", () => { // Check "Logout" option is not present expect(screen.queryByText("Logout")).toBeNull(); + + // Emulate click on menu button + await act(() => userEvent.click(accountMenu)); + + // "Logout" menu option should now be present + const logoutMenuButton = await screen.findByText("Logout"); + expect(logoutMenuButton).toBeInTheDocument(); + + // Emulate clicking on the logout button + await act(() => userEvent.click(logoutMenuButton)); + expect(window.location.assign).toBeCalledWith("/logout"); }); }); From fff21167a73952c52d6db71f067c5513415f0ef9 Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Thu, 2 Jan 2025 11:03:22 +0000 Subject: [PATCH 2/4] Fix dependency audit issue --- .../package-lock.json | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ansible_ai_connect_admin_portal/package-lock.json b/ansible_ai_connect_admin_portal/package-lock.json index 0a55d446f..d7f8a17cd 100644 --- a/ansible_ai_connect_admin_portal/package-lock.json +++ b/ansible_ai_connect_admin_portal/package-lock.json @@ -8488,11 +8488,10 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "devOptional": true, - "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -8513,7 +8512,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -8528,6 +8527,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express/node_modules/debug": { @@ -12695,9 +12698,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { @@ -12705,7 +12708,6 @@ "url": "https://github.com/sponsors/ai" } ], - "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -13505,11 +13507,10 @@ "license": "MIT" }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", - "devOptional": true, - "license": "MIT" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "devOptional": true }, "node_modules/path-type": { "version": "4.0.0", From 4f0b46d8ed81d6a1a4535f983aedbf419c4c391b Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Thu, 2 Jan 2025 11:05:45 +0000 Subject: [PATCH 3/4] Fix precommit issue --- requirements.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.in b/requirements.in index 390451154..d4379973d 100644 --- a/requirements.in +++ b/requirements.in @@ -37,7 +37,7 @@ ipython==8.10.0 # remove this once django-oauth-toolkit is updated to properly # pull a version of jwcrypto >= 1.5.6. jwcrypto==1.5.6 -# pin jinja2 on 3.1.5 to address GHSA-h75v-3vvj-5mfj, +# pin jinja2 on 3.1.5 to address GHSA-h75v-3vvj-5mfj, # CVE-2024-56326, CVE-2024-56201 # remove this once ansible-core or torch are updated jinja2==3.1.5 From 802c740fdd9a3018c0a4d62b3b44c9e303a639fd Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Thu, 2 Jan 2025 11:10:41 +0000 Subject: [PATCH 4/4] Fix npm lint issues. --- .../src/__tests__/AppHeader.test.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx b/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx index cde9fd4a1..145f5ca6e 100644 --- a/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx +++ b/ansible_ai_connect_admin_portal/src/__tests__/AppHeader.test.tsx @@ -3,7 +3,6 @@ import "@testing-library/jest-dom"; import { AppHeader } from "../AppHeader"; import { BrowserRouter } from "react-router-dom"; import userEvent from "@testing-library/user-event"; -import { act } from "react"; describe("AppHeader", () => { // Store the original 'location' object so that it can be restored for other tests. @@ -37,14 +36,14 @@ describe("AppHeader", () => { expect(screen.queryByText("Logout")).toBeNull(); // Emulate click on menu button - await act(() => userEvent.click(accountMenu)); + await userEvent.click(accountMenu); // "Logout" menu option should now be present const logoutMenuButton = await screen.findByText("Logout"); expect(logoutMenuButton).toBeInTheDocument(); // Emulate clicking on the logout button - await act(() => userEvent.click(logoutMenuButton)); + await userEvent.click(logoutMenuButton); expect(window.location.assign).toBeCalledWith("/logout"); }); });