Skip to content

Commit

Permalink
Making changes requested to pull excluded URLs from fixtures and extr…
Browse files Browse the repository at this point in the history
…act a function to utils
  • Loading branch information
antowaddle committed Dec 13, 2024
1 parent c0c9dd4 commit 5ee5499
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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/$
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
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}`);

// Extract URLs from the manifests directory using the registered task
cy.task<string[]>('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) => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/__tests__/cypress/cypress/utils/urlExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

0 comments on commit 5ee5499

Please sign in to comment.