From 71a3e53b55085070e86c8a18972a332f3e747165 Mon Sep 17 00:00:00 2001 From: achmelo <37397715+achmelo@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:14:24 +0200 Subject: [PATCH] chore: remove redundant npm registry config (#3855) * remove redundant npm registry config Signed-off-by: ac892247 * return undici to make tests more stable Signed-off-by: ac892247 * remove undici, replace flaky test Signed-off-by: ac892247 --------- Signed-off-by: ac892247 --- api-catalog-ui/frontend/package-lock.json | 7 +++-- .../src/components/GraphQL/GraphQLUI.test.jsx | 27 +++++++------------ .../src/components/GraphQL/GraphQLUIApiml.jsx | 2 +- zowe-cli-id-federation-plugin/.npmrc | 2 -- 4 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 zowe-cli-id-federation-plugin/.npmrc diff --git a/api-catalog-ui/frontend/package-lock.json b/api-catalog-ui/frontend/package-lock.json index ce1a85f76a..e997dc725a 100644 --- a/api-catalog-ui/frontend/package-lock.json +++ b/api-catalog-ui/frontend/package-lock.json @@ -29531,11 +29531,10 @@ "dev": true }, "node_modules/undici": { - "version": "6.20.0", - "resolved": "https://zowe.jfrog.io/artifactory/api/npm/npm-org/undici/-/undici-6.20.0.tgz", - "integrity": "sha512-AITZfPuxubm31Sx0vr8bteSalEbs9wQb/BOBi9FPlD9Qpd6HxZ4Q0+hI742jBhkPb4RT2v5MQzaW5VhRVyj+9A==", + "version": "6.20.1", + "resolved": "https://zowe.jfrog.io/artifactory/api/npm/npm-org/undici/-/undici-6.20.1.tgz", + "integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==", "dev": true, - "license": "MIT", "engines": { "node": ">=18.17" } diff --git a/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUI.test.jsx b/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUI.test.jsx index 7767da5fd6..b62c7428e1 100644 --- a/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUI.test.jsx +++ b/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUI.test.jsx @@ -11,7 +11,7 @@ import { getIntrospectionQuery } from 'graphql/utilities'; import { render, screen, waitFor, act } from '@testing-library/react'; import '@testing-library/jest-dom'; import GraphQLUI from './GraphQLUIApiml'; - +import { getUrl } from './GraphQLUIApiml'; const host = 'localhost:3000'; const protocol = 'https:'; const graphqlUrl = 'https://localhost:4000/discoverableclient/api/v3/graphql'; @@ -91,22 +91,15 @@ describe('>>> GraphQL component tests', () => { }, 10000); it('getUrl constructs the correct URL', async () => { - mockFetcher(); - render(); - await waitFor(() => expect(fetch).toHaveBeenCalled()); - - expect(fetch).toHaveBeenCalledWith( - `${protocol}//${host}/discoverableclient/api/v3/graphql`, - expect.objectContaining({ - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: expect.any(String), - credentials: 'same-origin', - }) - ); + const originalLocation = window.location; + window.location = { + protocol: 'https:', + host: 'example.com', + }; + const graphqlUrl = 'https://some-api.com/graphql'; + const result = getUrl(graphqlUrl); + expect(result).toBe('https://example.com/graphql'); + window.location = originalLocation; }); it('Fetches and sets schema on mount', async () => { diff --git a/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUIApiml.jsx b/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUIApiml.jsx index b8f72951c2..2863effb0c 100644 --- a/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUIApiml.jsx +++ b/api-catalog-ui/frontend/src/components/GraphQL/GraphQLUIApiml.jsx @@ -19,7 +19,7 @@ import { buildClientSchema, getIntrospectionQuery } from 'graphql/utilities'; * @param {string} graphqlUrl - The GraphQL endpoint URL. * @returns {string} The full URL for the GraphQL endpoint. */ -function getUrl(graphqlUrl) { +export function getUrl(graphqlUrl) { const location = `${window.location.protocol}//${window.location.host}`; const urlForPathName = new URL(graphqlUrl); const pathName = urlForPathName.pathname; diff --git a/zowe-cli-id-federation-plugin/.npmrc b/zowe-cli-id-federation-plugin/.npmrc deleted file mode 100644 index 2cc0fe24df..0000000000 --- a/zowe-cli-id-federation-plugin/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -registry=https://registry.npmjs.org/ -@zowe:registry=https://zowe.jfrog.io/zowe/api/npm/npm-release/