diff --git a/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dashboardNavigation/testManifestLinks.yaml b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dashboardNavigation/testManifestLinks.yaml new file mode 100644 index 0000000000..19a2d56cfb --- /dev/null +++ b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dashboardNavigation/testManifestLinks.yaml @@ -0,0 +1,13 @@ +# testManifestLinks.cy.ts Test Data # +excludedSubstrings: + - my-project-s2i-python-service + - clusterip/ + - ClusterIP + - s2i-python-service + - user-dev-rhoam-quarkus + - project-simple + - example.apps + - localhost + - console-openshift-console.apps.test-cluster.example.com/ + - console-openshift-console.apps.test-cluster.example.com + - repo.anaconda.cloud/repo/t/$ \ No newline at end of file diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dashboardNavigation/testManifestLinks.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dashboardNavigation/testManifestLinks.cy.ts index 8744fa374a..9730df196b 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dashboardNavigation/testManifestLinks.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dashboardNavigation/testManifestLinks.cy.ts @@ -1,4 +1,17 @@ +import * as yaml from 'js-yaml'; +import { isUrlExcluded } from '~/__tests__/cypress/cypress/utils/urlExtractor'; + describe('Verify that all the URLs referenced in the Manifest directory are operational', () => { + let excludedSubstrings: string[]; + + // Setup: Load test data + before(() => { + cy.fixture('e2e/dashboardNavigation/testManifestLinks.yaml', 'utf8').then((yamlString) => { + const yamlData = yaml.load(yamlString) as { excludedSubstrings: string[] }; + excludedSubstrings = yamlData.excludedSubstrings; + }); + }); + it('Reads the manifest directory, filters out test/sample URLs and validates the remaining URLs', () => { const manifestsDir = '../../../../manifests'; cy.log(`Resolved manifests directory: ${manifestsDir}`); @@ -6,20 +19,7 @@ describe('Verify that all the URLs referenced in the Manifest directory are oper // Extract URLs from the manifests directory using the registered task cy.task('extractHttpsUrls', manifestsDir).then((urls) => { // Filter out Sample/Test URLs - const filteredUrls = urls.filter( - (url) => - !url.includes('my-project-s2i-python-service') && - !url.includes('clusterip/') && - !url.includes('ClusterIP') && - !url.includes('s2i-python-service') && - !url.includes('user-dev-rhoam-quarkus') && - !url.includes('project-simple') && - !url.includes('example.apps') && - !url.includes('localhost') && - !url.includes('console-openshift-console.apps.test-cluster.example.com/') && - !url.includes('console-openshift-console.apps.test-cluster.example.com') && - !url.includes('repo.anaconda.cloud/repo/t/$'), - ); + const filteredUrls = urls.filter((url) => !isUrlExcluded(url, excludedSubstrings)); // Log filtered URLs for debugging filteredUrls.forEach((url) => { diff --git a/frontend/src/__tests__/cypress/cypress/utils/urlExtractor.ts b/frontend/src/__tests__/cypress/cypress/utils/urlExtractor.ts index 2f9deda95a..d0425d7c69 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/urlExtractor.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/urlExtractor.ts @@ -108,3 +108,6 @@ export function extractHttpsUrls(directory: string): string[] { walkDir(directory); // Start walking the directory return Array.from(httpsUrlSet); // Return the unique set of URLs as an array } +export const isUrlExcluded = (url: string, excludedSubstrings: string[]): boolean => { + return excludedSubstrings.some((substring) => url.includes(substring)); +};