diff --git a/dist/api-version.d.ts b/dist/api-version.d.ts
index ffda379..65937d9 100644
--- a/dist/api-version.d.ts
+++ b/dist/api-version.d.ts
@@ -1,5 +1,5 @@
export declare enum APIVersion {
- 'latest' = "latest",
- 'default' = "default",
- 'v14' = "v14"
+ 'latest' = 'latest',
+ 'default' = 'default',
+ 'v14' = 'v14'
}
diff --git a/dist/api-version.js b/dist/api-version.js
index 4741520..72431da 100644
--- a/dist/api-version.js
+++ b/dist/api-version.js
@@ -1,9 +1,9 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.APIVersion = void 0;
-var APIVersion;
-(function (APIVersion) {
- APIVersion["latest"] = "latest";
- APIVersion["default"] = "default";
- APIVersion["v14"] = "v14";
-})(APIVersion || (exports.APIVersion = APIVersion = {}));
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.APIVersion = void 0
+var APIVersion
+;(function (APIVersion) {
+ APIVersion['latest'] = 'latest'
+ APIVersion['default'] = 'default'
+ APIVersion['v14'] = 'v14'
+})(APIVersion || (exports.APIVersion = APIVersion = {}))
diff --git a/dist/commands.d.ts b/dist/commands.d.ts
index cb0ff5c..336ce12 100644
--- a/dist/commands.d.ts
+++ b/dist/commands.d.ts
@@ -1 +1 @@
-export {};
+export {}
diff --git a/dist/commands.js b/dist/commands.js
index bb7ac12..e9460c8 100644
--- a/dist/commands.js
+++ b/dist/commands.js
@@ -1,44 +1,80 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
///
// @ts-nocheck - Cypress commands registration bypasses TypeScript checking
-const tt_accessibility_1 = require("./commands/tt-accessibility");
-const tt_click_if_element_exist_1 = require("./commands/tt-click-if-element-exist");
-const tt_cookie_all_accept_1 = require("./commands/tt-cookie-all-accept");
-const tt_detect_http_1 = require("./commands/tt-detect-http");
-const tt_element_exists_1 = require("./commands/tt-element-exists");
-const tt_every_internal_link_is_loading_1 = require("./commands/tt-every-internal-link-is-loading");
-const tt_every_internal_link_status_ok_1 = require("./commands/tt-every-internal-link-status-ok");
-const tt_get_internal_links_1 = require("./commands/tt-get-internal-links");
-const tt_invalid_path_404_1 = require("./commands/tt-invalid-path-404");
-const tt_only_one_h1_1 = require("./commands/tt-only-one-h1");
-const tt_page_loaded_1 = require("./commands/tt-page-loaded");
-const tt_setup_console_error_listener_1 = require("./commands/tt-setup-console-error-listener");
-const tt_threshold_1 = require("./commands/tt-threshold");
-const tt_validate_all_images_response_status_ok_1 = require("./commands/tt-validate-all-images-response-status-ok");
-const tt_validate_imprint_clickable_1 = require("./commands/tt-validate-imprint-clickable");
-const tt_validate_language_tag_1 = require("./commands/tt-validate-language-tag");
-const tt_validate_no_google_services_1 = require("./commands/tt-validate-no-google-services");
-const tt_validate_page_content_1 = require("./commands/tt-validate-page-content");
-const tt_validate_subpages_and_images_1 = require("./commands/tt-validate-subpages-and-images");
-const tt_el_1 = require("./commands/tt-el");
-Cypress.Commands.add('ttEl', tt_el_1.ttEl);
-Cypress.Commands.add('ttAccessibility', tt_accessibility_1.ttAccessibility);
-Cypress.Commands.add('ttClickIfElementExist', tt_click_if_element_exist_1.ttClickIfElementExist);
-Cypress.Commands.add('ttCookieAllAcceptClick', tt_cookie_all_accept_1.ttCookieAllAcceptClick);
-Cypress.Commands.add('ttDetectHttp', tt_detect_http_1.ttDetectHttp);
-Cypress.Commands.add('ttElementExists', tt_element_exists_1.ttElementExists);
-Cypress.Commands.add('ttEveryInternalLinkIsLoading', tt_every_internal_link_is_loading_1.ttEveryInternalLinkIsLoading);
-Cypress.Commands.add('ttEveryInternalLinkStatusOk', tt_every_internal_link_status_ok_1.ttEveryInternalLinkStatusOk);
-Cypress.Commands.add('ttGetInternalLinks', tt_get_internal_links_1.ttGetInternalLinks);
-Cypress.Commands.add('ttInvalidPath404', tt_invalid_path_404_1.ttInvalidPath404);
-Cypress.Commands.add('ttOnlyOneH1', tt_only_one_h1_1.ttOnlyOneH1);
-Cypress.Commands.add('ttPageLoaded', tt_page_loaded_1.ttPageLoaded);
-Cypress.Commands.add('ttSetupConsoleErrorListener', tt_setup_console_error_listener_1.ttSetupConsoleErrorListener);
-Cypress.Commands.add('ttThreshold', tt_threshold_1.ttThreshold);
-Cypress.Commands.add('ttValidateAllImagesResponseStatusOk', tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk);
-Cypress.Commands.add('ttValidateImprintClickable', tt_validate_imprint_clickable_1.ttValidateImprintClickable);
-Cypress.Commands.add('ttValidateLanguageTag', tt_validate_language_tag_1.ttValidateLanguageTag);
-Cypress.Commands.add('ttValidateNoGoogleServices', tt_validate_no_google_services_1.ttValidateNoGoogleServices);
-Cypress.Commands.add('ttValidatePageContent', tt_validate_page_content_1.ttValidatePageContent);
-Cypress.Commands.add('ttValidateSubpagesAndImages', tt_validate_subpages_and_images_1.ttValidateSubpagesAndImages);
+const tt_accessibility_1 = require('./commands/tt-accessibility')
+const tt_click_if_element_exist_1 = require('./commands/tt-click-if-element-exist')
+const tt_cookie_all_accept_1 = require('./commands/tt-cookie-all-accept')
+const tt_detect_http_1 = require('./commands/tt-detect-http')
+const tt_element_exists_1 = require('./commands/tt-element-exists')
+const tt_every_internal_link_is_loading_1 = require('./commands/tt-every-internal-link-is-loading')
+const tt_every_internal_link_status_ok_1 = require('./commands/tt-every-internal-link-status-ok')
+const tt_get_internal_links_1 = require('./commands/tt-get-internal-links')
+const tt_invalid_path_404_1 = require('./commands/tt-invalid-path-404')
+const tt_only_one_h1_1 = require('./commands/tt-only-one-h1')
+const tt_page_loaded_1 = require('./commands/tt-page-loaded')
+const tt_setup_console_error_listener_1 = require('./commands/tt-setup-console-error-listener')
+const tt_threshold_1 = require('./commands/tt-threshold')
+const tt_validate_all_images_response_status_ok_1 = require('./commands/tt-validate-all-images-response-status-ok')
+const tt_validate_imprint_clickable_1 = require('./commands/tt-validate-imprint-clickable')
+const tt_validate_language_tag_1 = require('./commands/tt-validate-language-tag')
+const tt_validate_no_google_services_1 = require('./commands/tt-validate-no-google-services')
+const tt_validate_page_content_1 = require('./commands/tt-validate-page-content')
+const tt_validate_subpages_and_images_1 = require('./commands/tt-validate-subpages-and-images')
+const tt_el_1 = require('./commands/tt-el')
+Cypress.Commands.add('ttEl', tt_el_1.ttEl)
+Cypress.Commands.add('ttAccessibility', tt_accessibility_1.ttAccessibility)
+Cypress.Commands.add(
+ 'ttClickIfElementExist',
+ tt_click_if_element_exist_1.ttClickIfElementExist
+)
+Cypress.Commands.add(
+ 'ttCookieAllAcceptClick',
+ tt_cookie_all_accept_1.ttCookieAllAcceptClick
+)
+Cypress.Commands.add('ttDetectHttp', tt_detect_http_1.ttDetectHttp)
+Cypress.Commands.add('ttElementExists', tt_element_exists_1.ttElementExists)
+Cypress.Commands.add(
+ 'ttEveryInternalLinkIsLoading',
+ tt_every_internal_link_is_loading_1.ttEveryInternalLinkIsLoading
+)
+Cypress.Commands.add(
+ 'ttEveryInternalLinkStatusOk',
+ tt_every_internal_link_status_ok_1.ttEveryInternalLinkStatusOk
+)
+Cypress.Commands.add(
+ 'ttGetInternalLinks',
+ tt_get_internal_links_1.ttGetInternalLinks
+)
+Cypress.Commands.add('ttInvalidPath404', tt_invalid_path_404_1.ttInvalidPath404)
+Cypress.Commands.add('ttOnlyOneH1', tt_only_one_h1_1.ttOnlyOneH1)
+Cypress.Commands.add('ttPageLoaded', tt_page_loaded_1.ttPageLoaded)
+Cypress.Commands.add(
+ 'ttSetupConsoleErrorListener',
+ tt_setup_console_error_listener_1.ttSetupConsoleErrorListener
+)
+Cypress.Commands.add('ttThreshold', tt_threshold_1.ttThreshold)
+Cypress.Commands.add(
+ 'ttValidateAllImagesResponseStatusOk',
+ tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk
+)
+Cypress.Commands.add(
+ 'ttValidateImprintClickable',
+ tt_validate_imprint_clickable_1.ttValidateImprintClickable
+)
+Cypress.Commands.add(
+ 'ttValidateLanguageTag',
+ tt_validate_language_tag_1.ttValidateLanguageTag
+)
+Cypress.Commands.add(
+ 'ttValidateNoGoogleServices',
+ tt_validate_no_google_services_1.ttValidateNoGoogleServices
+)
+Cypress.Commands.add(
+ 'ttValidatePageContent',
+ tt_validate_page_content_1.ttValidatePageContent
+)
+Cypress.Commands.add(
+ 'ttValidateSubpagesAndImages',
+ tt_validate_subpages_and_images_1.ttValidateSubpagesAndImages
+)
diff --git a/dist/commands/tt-accessibility.d.ts b/dist/commands/tt-accessibility.d.ts
index 6c69423..ca9aa3a 100644
--- a/dist/commands/tt-accessibility.d.ts
+++ b/dist/commands/tt-accessibility.d.ts
@@ -1 +1 @@
-export declare const ttAccessibility: () => void;
+export declare const ttAccessibility: () => void
diff --git a/dist/commands/tt-accessibility.js b/dist/commands/tt-accessibility.js
index af69e50..2299db7 100644
--- a/dist/commands/tt-accessibility.js
+++ b/dist/commands/tt-accessibility.js
@@ -1,11 +1,11 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttAccessibility = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttAccessibility = void 0
const ttAccessibility = () => {
- cy.log('ttAccessibility - NCA TESTIFY');
- // @ts-ignore - cypress-axe types
- cy.injectAxe();
- // @ts-ignore - cypress-axe types
- cy.checkA11y();
-};
-exports.ttAccessibility = ttAccessibility;
+ cy.log('ttAccessibility - NCA TESTIFY')
+ // @ts-ignore - cypress-axe types
+ cy.injectAxe()
+ // @ts-ignore - cypress-axe types
+ cy.checkA11y()
+}
+exports.ttAccessibility = ttAccessibility
diff --git a/dist/commands/tt-click-if-element-exist.d.ts b/dist/commands/tt-click-if-element-exist.d.ts
index a1ce976..b305874 100644
--- a/dist/commands/tt-click-if-element-exist.d.ts
+++ b/dist/commands/tt-click-if-element-exist.d.ts
@@ -1 +1,3 @@
-export declare const ttClickIfElementExist: (selector: string) => Cypress.Chainable;
+export declare const ttClickIfElementExist: (
+ selector: string
+) => Cypress.Chainable
diff --git a/dist/commands/tt-click-if-element-exist.js b/dist/commands/tt-click-if-element-exist.js
index 1b07da2..61bf7c2 100644
--- a/dist/commands/tt-click-if-element-exist.js
+++ b/dist/commands/tt-click-if-element-exist.js
@@ -1,18 +1,17 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttClickIfElementExist = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttClickIfElementExist = void 0
// src/commands/tt-click-if-element-exist.ts
const ttClickIfElementExist = (selector) => {
- cy.log(`ttClickIfElementExist - Checking if element exists: ${selector}`);
- return cy.get('body').then(($body) => {
- if ($body.find(selector).length > 0) {
- cy.log(`Element found: ${selector}. Clicking...`);
- return cy.get(selector).click();
- }
- else {
- cy.log(`Element not found: ${selector}. Skipping click.`);
- return null;
- }
- });
-};
-exports.ttClickIfElementExist = ttClickIfElementExist;
+ cy.log(`ttClickIfElementExist - Checking if element exists: ${selector}`)
+ return cy.get('body').then(($body) => {
+ if ($body.find(selector).length > 0) {
+ cy.log(`Element found: ${selector}. Clicking...`)
+ return cy.get(selector).click()
+ } else {
+ cy.log(`Element not found: ${selector}. Skipping click.`)
+ return null
+ }
+ })
+}
+exports.ttClickIfElementExist = ttClickIfElementExist
diff --git a/dist/commands/tt-cookie-all-accept.d.ts b/dist/commands/tt-cookie-all-accept.d.ts
index 3aee45f..8406367 100644
--- a/dist/commands/tt-cookie-all-accept.d.ts
+++ b/dist/commands/tt-cookie-all-accept.d.ts
@@ -1 +1,3 @@
-export declare const ttCookieAllAcceptClick: (cookieButtonStrings?: string[]) => Cypress.Chainable;
+export declare const ttCookieAllAcceptClick: (
+ cookieButtonStrings?: string[]
+) => Cypress.Chainable
diff --git a/dist/commands/tt-cookie-all-accept.js b/dist/commands/tt-cookie-all-accept.js
index 8ce0699..b74971d 100644
--- a/dist/commands/tt-cookie-all-accept.js
+++ b/dist/commands/tt-cookie-all-accept.js
@@ -1,41 +1,49 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttCookieAllAcceptClick = void 0;
-const ttCookieAllAcceptClick = (cookieButtonStrings = ['alle akzeptieren', 'alles akzeptieren']) => {
- cy.log('ttCookieAllAcceptClick - NCA TESTIFY');
- return cy.get('body').then(($body) => {
- let found = false;
- for (const buttonString of cookieButtonStrings) {
- if ($body.text().toLowerCase().includes(buttonString)) {
- cy.log(`Found matching string: ${buttonString}`);
- cy.contains(buttonString, { matchCase: false }).click({ force: true });
- found = true;
- break;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttCookieAllAcceptClick = void 0
+const ttCookieAllAcceptClick = (
+ cookieButtonStrings = ['alle akzeptieren', 'alles akzeptieren']
+) => {
+ cy.log('ttCookieAllAcceptClick - NCA TESTIFY')
+ return cy.get('body').then(($body) => {
+ let found = false
+ for (const buttonString of cookieButtonStrings) {
+ if ($body.text().toLowerCase().includes(buttonString)) {
+ cy.log(`Found matching string: ${buttonString}`)
+ cy.contains(buttonString, { matchCase: false }).click({ force: true })
+ found = true
+ break
+ }
+ }
+ if (!found) {
+ // Usercentrics special case
+ return cy.window().then((win) => {
+ const shadowHost = win.document.querySelector('#usercentrics-root')
+ if (shadowHost !== null) {
+ const shadowRoot = shadowHost.shadowRoot
+ if (shadowRoot !== null) {
+ const acceptButton = shadowRoot.querySelector(
+ '[data-testid="uc-accept-all-button"]'
+ )
+ if (acceptButton !== null) {
+ cy.log('Found accept button in shadow DOM, clicking...')
+ acceptButton.click()
+ found = true
}
+ }
}
if (!found) {
- // Usercentrics special case
- return cy.window().then((win) => {
- const shadowHost = win.document.querySelector('#usercentrics-root');
- if (shadowHost !== null) {
- const shadowRoot = shadowHost.shadowRoot;
- if (shadowRoot !== null) {
- const acceptButton = shadowRoot.querySelector('[data-testid="uc-accept-all-button"]');
- if (acceptButton !== null) {
- cy.log('Found accept button in shadow DOM, clicking...');
- acceptButton.click();
- found = true;
- }
- }
- }
- if (!found) {
- cy.log('No matching string found. Please open an issue at https://github.com/ncatestify/cypress-base-plugin/issues');
- throw new Error('No matching string found. Please open an issue at https://github.com/ncatestify/cypress-base-plugin/issues');
- }
- return null;
- });
+ cy.log(
+ 'No matching string found. Please open an issue at https://github.com/ncatestify/cypress-base-plugin/issues'
+ )
+ throw new Error(
+ 'No matching string found. Please open an issue at https://github.com/ncatestify/cypress-base-plugin/issues'
+ )
}
- return null;
- });
-};
-exports.ttCookieAllAcceptClick = ttCookieAllAcceptClick;
+ return null
+ })
+ }
+ return null
+ })
+}
+exports.ttCookieAllAcceptClick = ttCookieAllAcceptClick
diff --git a/dist/commands/tt-detect-http.d.ts b/dist/commands/tt-detect-http.d.ts
index 395b746..c6d23fc 100644
--- a/dist/commands/tt-detect-http.d.ts
+++ b/dist/commands/tt-detect-http.d.ts
@@ -1 +1 @@
-export declare const ttDetectHttp: () => void;
+export declare const ttDetectHttp: () => void
diff --git a/dist/commands/tt-detect-http.js b/dist/commands/tt-detect-http.js
index 3b601b5..5374569 100644
--- a/dist/commands/tt-detect-http.js
+++ b/dist/commands/tt-detect-http.js
@@ -1,22 +1,23 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttDetectHttp = void 0;
-const chai_1 = require("chai");
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttDetectHttp = void 0
+const chai_1 = require('chai')
const ttDetectHttp = () => {
- cy.log('ttDetectHttp - NCA TESTIFY');
- cy.get('a').each((resultItem) => {
- cy.wrap(resultItem)
- .invoke('attr', 'href')
- .then((href) => {
- if (typeof href !== 'undefined' &&
- !href.includes('mailto') &&
- !href.includes('tel')) {
- chai_1.assert.notInclude(href, 'http:');
- }
- else {
- cy.log(`Filtered URL: ${href}`);
- }
- });
- });
-};
-exports.ttDetectHttp = ttDetectHttp;
+ cy.log('ttDetectHttp - NCA TESTIFY')
+ cy.get('a').each((resultItem) => {
+ cy.wrap(resultItem)
+ .invoke('attr', 'href')
+ .then((href) => {
+ if (
+ typeof href !== 'undefined' &&
+ !href.includes('mailto') &&
+ !href.includes('tel')
+ ) {
+ chai_1.assert.notInclude(href, 'http:')
+ } else {
+ cy.log(`Filtered URL: ${href}`)
+ }
+ })
+ })
+}
+exports.ttDetectHttp = ttDetectHttp
diff --git a/dist/commands/tt-el.d.ts b/dist/commands/tt-el.d.ts
index 2f6b439..7902201 100644
--- a/dist/commands/tt-el.d.ts
+++ b/dist/commands/tt-el.d.ts
@@ -1 +1,4 @@
-export declare const ttEl: (selector: string, name?: string) => Cypress.Chainable>;
+export declare const ttEl: (
+ selector: string,
+ name?: string
+) => Cypress.Chainable>
diff --git a/dist/commands/tt-el.js b/dist/commands/tt-el.js
index 5d43dd9..d6e61f8 100644
--- a/dist/commands/tt-el.js
+++ b/dist/commands/tt-el.js
@@ -1,8 +1,19 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttEl = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttEl = void 0
+const extractCallerName = () => {
+ const stack = new Error().stack
+ if (!stack) return null
+ const lines = stack.split('\n')
+ for (const line of lines) {
+ const match = line.match(/get (\w+)/)
+ if (match) return match[1]
+ }
+ return null
+}
const ttEl = (selector, name) => {
- cy.log(name || selector);
- return cy.get(selector);
-};
-exports.ttEl = ttEl;
+ const logName = name || extractCallerName() || selector
+ cy.log(logName)
+ return cy.get(selector)
+}
+exports.ttEl = ttEl
diff --git a/dist/commands/tt-element-exists.d.ts b/dist/commands/tt-element-exists.d.ts
index 1cb542f..563a8fd 100644
--- a/dist/commands/tt-element-exists.d.ts
+++ b/dist/commands/tt-element-exists.d.ts
@@ -1 +1,3 @@
-export declare const ttElementExists: (selector: string) => Cypress.Chainable;
+export declare const ttElementExists: (
+ selector: string
+) => Cypress.Chainable
diff --git a/dist/commands/tt-element-exists.js b/dist/commands/tt-element-exists.js
index bf23236..2253ace 100644
--- a/dist/commands/tt-element-exists.js
+++ b/dist/commands/tt-element-exists.js
@@ -1,10 +1,10 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttElementExists = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttElementExists = void 0
const ttElementExists = (selector) => {
- cy.log('ttElementExists - NCA TESTIFY');
- return cy.window().then(($window) => {
- return $window.document.querySelector(selector) !== null;
- });
-};
-exports.ttElementExists = ttElementExists;
+ cy.log('ttElementExists - NCA TESTIFY')
+ return cy.window().then(($window) => {
+ return $window.document.querySelector(selector) !== null
+ })
+}
+exports.ttElementExists = ttElementExists
diff --git a/dist/commands/tt-every-internal-link-is-loading.d.ts b/dist/commands/tt-every-internal-link-is-loading.d.ts
index 305ab8f..4e8cf3f 100644
--- a/dist/commands/tt-every-internal-link-is-loading.d.ts
+++ b/dist/commands/tt-every-internal-link-is-loading.d.ts
@@ -1 +1 @@
-export declare const ttEveryInternalLinkIsLoading: (limit?: number) => void;
+export declare const ttEveryInternalLinkIsLoading: (limit?: number) => void
diff --git a/dist/commands/tt-every-internal-link-is-loading.js b/dist/commands/tt-every-internal-link-is-loading.js
index cd6ec9e..3b9c4a6 100644
--- a/dist/commands/tt-every-internal-link-is-loading.js
+++ b/dist/commands/tt-every-internal-link-is-loading.js
@@ -1,32 +1,33 @@
-"use strict";
+'use strict'
///
///
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttEveryInternalLinkIsLoading = void 0;
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttEveryInternalLinkIsLoading = void 0
const ttEveryInternalLinkIsLoading = (limit = 10) => {
- cy.log('everyInternalLinkIsLoading - NCA TESTIFY');
- //@ts-ignore - Custom command type not available in build context
- cy.ttGetInternalLinks().then((internalLinks) => {
- const linksToValidate = internalLinks.slice(0, limit);
- cy.log(`Found ${internalLinks.length} unique internal links, validating ${linksToValidate.length}`);
- linksToValidate.forEach((href) => {
- if (href.includes('.pdf')) {
- cy.log(`Validating PDF: ${href}`);
- cy.request({
- url: href,
- failOnStatusCode: false
- }).then((response) => {
- expect(response.status).to.be.oneOf([200, 301, 302, 307, 308]);
- });
- }
- else {
- cy.visit(href);
- cy.get('a').should('be.visible');
- //@ts-ignore - Custom command type not available in build context
- cy.ttValidateAllImagesResponseStatusOk();
- }
- cy.clearAllLocalStorage();
- });
- });
-};
-exports.ttEveryInternalLinkIsLoading = ttEveryInternalLinkIsLoading;
+ cy.log('everyInternalLinkIsLoading - NCA TESTIFY')
+ //@ts-ignore - Custom command type not available in build context
+ cy.ttGetInternalLinks().then((internalLinks) => {
+ const linksToValidate = internalLinks.slice(0, limit)
+ cy.log(
+ `Found ${internalLinks.length} unique internal links, validating ${linksToValidate.length}`
+ )
+ linksToValidate.forEach((href) => {
+ if (href.includes('.pdf')) {
+ cy.log(`Validating PDF: ${href}`)
+ cy.request({
+ url: href,
+ failOnStatusCode: false
+ }).then((response) => {
+ expect(response.status).to.be.oneOf([200, 301, 302, 307, 308])
+ })
+ } else {
+ cy.visit(href)
+ cy.get('a').should('be.visible')
+ //@ts-ignore - Custom command type not available in build context
+ cy.ttValidateAllImagesResponseStatusOk()
+ }
+ cy.clearAllLocalStorage()
+ })
+ })
+}
+exports.ttEveryInternalLinkIsLoading = ttEveryInternalLinkIsLoading
diff --git a/dist/commands/tt-every-internal-link-status-ok.d.ts b/dist/commands/tt-every-internal-link-status-ok.d.ts
index 0cb537b..0a6c43f 100644
--- a/dist/commands/tt-every-internal-link-status-ok.d.ts
+++ b/dist/commands/tt-every-internal-link-status-ok.d.ts
@@ -1 +1,3 @@
-export declare const ttEveryInternalLinkStatusOk: (minLinksRequired?: number) => Cypress.Chainable;
+export declare const ttEveryInternalLinkStatusOk: (
+ minLinksRequired?: number
+) => Cypress.Chainable
diff --git a/dist/commands/tt-every-internal-link-status-ok.js b/dist/commands/tt-every-internal-link-status-ok.js
index 19d6a51..12e7b8d 100644
--- a/dist/commands/tt-every-internal-link-status-ok.js
+++ b/dist/commands/tt-every-internal-link-status-ok.js
@@ -1,34 +1,39 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttEveryInternalLinkStatusOk = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttEveryInternalLinkStatusOk = void 0
const ttEveryInternalLinkStatusOk = (minLinksRequired = 1) => {
- //@ts-ignore - Custom command type not available in build context
- return cy.ttGetInternalLinks().then((urls) => {
- cy.log('everyInternalLinkStatusOk - NCA TESTIFY');
- cy.wrap(urls).its('length').should('be.gte', minLinksRequired);
- let allLinksOk = true;
- urls.forEach((url) => {
- const requestOptions = {
- url: url,
- failOnStatusCode: false
- };
- cy.request(requestOptions).then((resp) => {
- var _a;
- if ((_a = resp.headers['content-type']) === null || _a === void 0 ? void 0 : _a.includes('text/html')) {
- const validStatuses = [200, 301, 302];
- const success = validStatuses.includes(resp.status);
- allLinksOk = allLinksOk && success;
- cy.log(`${success ? '✅' : '❌'} Testing ${url}: ${resp.status}`);
- if (!success) {
- cy.log(`⚠️ Link validation failed: ${url} returned ${resp.status}`);
- }
- }
- else {
- cy.log(`⏭️ Testing ${url}: Skipped (content-type: ${resp.headers['content-type']})`);
- }
- });
- });
- return cy.wrap(allLinksOk);
- });
-};
-exports.ttEveryInternalLinkStatusOk = ttEveryInternalLinkStatusOk;
+ //@ts-ignore - Custom command type not available in build context
+ return cy.ttGetInternalLinks().then((urls) => {
+ cy.log('everyInternalLinkStatusOk - NCA TESTIFY')
+ cy.wrap(urls).its('length').should('be.gte', minLinksRequired)
+ let allLinksOk = true
+ urls.forEach((url) => {
+ const requestOptions = {
+ url: url,
+ failOnStatusCode: false
+ }
+ cy.request(requestOptions).then((resp) => {
+ var _a
+ if (
+ (_a = resp.headers['content-type']) === null || _a === void 0
+ ? void 0
+ : _a.includes('text/html')
+ ) {
+ const validStatuses = [200, 301, 302]
+ const success = validStatuses.includes(resp.status)
+ allLinksOk = allLinksOk && success
+ cy.log(`${success ? '✅' : '❌'} Testing ${url}: ${resp.status}`)
+ if (!success) {
+ cy.log(`⚠️ Link validation failed: ${url} returned ${resp.status}`)
+ }
+ } else {
+ cy.log(
+ `⏭️ Testing ${url}: Skipped (content-type: ${resp.headers['content-type']})`
+ )
+ }
+ })
+ })
+ return cy.wrap(allLinksOk)
+ })
+}
+exports.ttEveryInternalLinkStatusOk = ttEveryInternalLinkStatusOk
diff --git a/dist/commands/tt-get-internal-links.d.ts b/dist/commands/tt-get-internal-links.d.ts
index b70ad50..28d4518 100644
--- a/dist/commands/tt-get-internal-links.d.ts
+++ b/dist/commands/tt-get-internal-links.d.ts
@@ -1 +1,3 @@
-export declare const ttGetInternalLinks: (linkSelector?: string) => Cypress.Chainable;
+export declare const ttGetInternalLinks: (
+ linkSelector?: string
+) => Cypress.Chainable
diff --git a/dist/commands/tt-get-internal-links.js b/dist/commands/tt-get-internal-links.js
index f9a0ecd..2b75db5 100644
--- a/dist/commands/tt-get-internal-links.js
+++ b/dist/commands/tt-get-internal-links.js
@@ -1,57 +1,59 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttGetInternalLinks = void 0;
-const isInternal_1 = require("./../utils/isInternal");
-const extractAuth_1 = require("./../utils/extractAuth");
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttGetInternalLinks = void 0
+const isInternal_1 = require('./../utils/isInternal')
+const extractAuth_1 = require('./../utils/extractAuth')
const isNonRequestableLink = (href) => {
- const nonRequestablePatterns = [
- '#',
- 'javascript:',
- 'mailto:',
- 'tel:',
- 'data:'
- ];
- return nonRequestablePatterns.some((pattern) => href === pattern || href.startsWith(pattern));
-};
+ const nonRequestablePatterns = [
+ '#',
+ 'javascript:',
+ 'mailto:',
+ 'tel:',
+ 'data:'
+ ]
+ return nonRequestablePatterns.some(
+ (pattern) => href === pattern || href.startsWith(pattern)
+ )
+}
const normalizeUrl = (href, baseUrl, currentUrl) => {
- if (href.startsWith('https://') || href.startsWith('http://')) {
- return href;
- }
- if (href.startsWith('/')) {
- return new URL(href, baseUrl).toString();
- }
- return new URL(href, currentUrl).toString();
-};
+ if (href.startsWith('https://') || href.startsWith('http://')) {
+ return href
+ }
+ if (href.startsWith('/')) {
+ return new URL(href, baseUrl).toString()
+ }
+ return new URL(href, currentUrl).toString()
+}
const ttGetInternalLinks = (linkSelector = '') => {
- cy.log('ttGetInternalLinks - NCA TESTIFY');
- const baseUrl = Cypress.config('baseUrl');
- return cy.url().then((currentUrl) => {
- const selector = linkSelector ? `${linkSelector} a[href]` : 'a[href]';
- return cy.get(selector).then(($links) => {
- const uniqueLinks = new Set();
- $links.each((_, element) => {
- const href = element.getAttribute('href');
- if (!href || !href.trim()) {
- return;
- }
- if (isNonRequestableLink(href)) {
- return;
- }
- try {
- const normalizedUrl = normalizeUrl(href, baseUrl, currentUrl);
- const urlWithoutFragment = normalizedUrl.split('#')[0];
- if ((0, isInternal_1.isInternal)(urlWithoutFragment)) {
- uniqueLinks.add(urlWithoutFragment);
- }
- }
- catch {
- cy.log(`Error processing URL: ${href}`);
- }
- });
- const internalLinks = Array.from(uniqueLinks);
- const linksWithCredentials = (0, extractAuth_1.addCredentialsToInternalLinks)(internalLinks, baseUrl);
- return cy.wrap(linksWithCredentials);
- });
- });
-};
-exports.ttGetInternalLinks = ttGetInternalLinks;
+ cy.log('ttGetInternalLinks - NCA TESTIFY')
+ const baseUrl = Cypress.config('baseUrl')
+ return cy.url().then((currentUrl) => {
+ const selector = linkSelector ? `${linkSelector} a[href]` : 'a[href]'
+ return cy.get(selector).then(($links) => {
+ const uniqueLinks = new Set()
+ $links.each((_, element) => {
+ const href = element.getAttribute('href')
+ if (!href || !href.trim()) {
+ return
+ }
+ if (isNonRequestableLink(href)) {
+ return
+ }
+ try {
+ const normalizedUrl = normalizeUrl(href, baseUrl, currentUrl)
+ const urlWithoutFragment = normalizedUrl.split('#')[0]
+ if ((0, isInternal_1.isInternal)(urlWithoutFragment)) {
+ uniqueLinks.add(urlWithoutFragment)
+ }
+ } catch {
+ cy.log(`Error processing URL: ${href}`)
+ }
+ })
+ const internalLinks = Array.from(uniqueLinks)
+ const linksWithCredentials = (0,
+ extractAuth_1.addCredentialsToInternalLinks)(internalLinks, baseUrl)
+ return cy.wrap(linksWithCredentials)
+ })
+ })
+}
+exports.ttGetInternalLinks = ttGetInternalLinks
diff --git a/dist/commands/tt-invalid-path-404.d.ts b/dist/commands/tt-invalid-path-404.d.ts
index 3601474..84c6e4e 100644
--- a/dist/commands/tt-invalid-path-404.d.ts
+++ b/dist/commands/tt-invalid-path-404.d.ts
@@ -1 +1 @@
-export declare const ttInvalidPath404: () => void;
+export declare const ttInvalidPath404: () => void
diff --git a/dist/commands/tt-invalid-path-404.js b/dist/commands/tt-invalid-path-404.js
index 1358ddd..949c008 100644
--- a/dist/commands/tt-invalid-path-404.js
+++ b/dist/commands/tt-invalid-path-404.js
@@ -1,23 +1,23 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttInvalidPath404 = void 0;
-const extractAuth_1 = require("./../utils/extractAuth");
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttInvalidPath404 = void 0
+const extractAuth_1 = require('./../utils/extractAuth')
const ttInvalidPath404 = () => {
- cy.log('ttInvalidPath404 - NCA TESTIFY');
- const baseUrl = Cypress.config('baseUrl');
- const auth = (0, extractAuth_1.extractAuth)(baseUrl);
- const requestOptions = {
- url: '/TESTIFY.invalidUrl',
- failOnStatusCode: false
- };
- if (auth) {
- requestOptions.auth = {
- username: auth.username,
- password: auth.password
- };
+ cy.log('ttInvalidPath404 - NCA TESTIFY')
+ const baseUrl = Cypress.config('baseUrl')
+ const auth = (0, extractAuth_1.extractAuth)(baseUrl)
+ const requestOptions = {
+ url: '/TESTIFY.invalidUrl',
+ failOnStatusCode: false
+ }
+ if (auth) {
+ requestOptions.auth = {
+ username: auth.username,
+ password: auth.password
}
- cy.request(requestOptions).then((resp) => {
- assert.equal(resp.status, 404);
- });
-};
-exports.ttInvalidPath404 = ttInvalidPath404;
+ }
+ cy.request(requestOptions).then((resp) => {
+ assert.equal(resp.status, 404)
+ })
+}
+exports.ttInvalidPath404 = ttInvalidPath404
diff --git a/dist/commands/tt-only-one-h1.d.ts b/dist/commands/tt-only-one-h1.d.ts
index 7644647..cff3a23 100644
--- a/dist/commands/tt-only-one-h1.d.ts
+++ b/dist/commands/tt-only-one-h1.d.ts
@@ -1 +1 @@
-export declare const ttOnlyOneH1: () => void;
+export declare const ttOnlyOneH1: () => void
diff --git a/dist/commands/tt-only-one-h1.js b/dist/commands/tt-only-one-h1.js
index cac141c..8293784 100644
--- a/dist/commands/tt-only-one-h1.js
+++ b/dist/commands/tt-only-one-h1.js
@@ -1,9 +1,9 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttOnlyOneH1 = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttOnlyOneH1 = void 0
const ttOnlyOneH1 = () => {
- cy.log('ttOnlyOneH1 - NCA TESTIFY');
- // @ts-ignore - Custom command registered at runtime
- cy.ttEl('h1', 'h1Heading').its('length').should('eq', 1);
-};
-exports.ttOnlyOneH1 = ttOnlyOneH1;
+ cy.log('ttOnlyOneH1 - NCA TESTIFY')
+ // @ts-ignore - Custom command registered at runtime
+ cy.ttEl('h1', 'h1Heading').its('length').should('eq', 1)
+}
+exports.ttOnlyOneH1 = ttOnlyOneH1
diff --git a/dist/commands/tt-page-loaded.d.ts b/dist/commands/tt-page-loaded.d.ts
index 0e549e6..07c54ed 100644
--- a/dist/commands/tt-page-loaded.d.ts
+++ b/dist/commands/tt-page-loaded.d.ts
@@ -1 +1 @@
-export declare const ttPageLoaded: () => void;
+export declare const ttPageLoaded: () => void
diff --git a/dist/commands/tt-page-loaded.js b/dist/commands/tt-page-loaded.js
index 366b338..9bc7ed4 100644
--- a/dist/commands/tt-page-loaded.js
+++ b/dist/commands/tt-page-loaded.js
@@ -1,22 +1,21 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttPageLoaded = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttPageLoaded = void 0
const ttPageLoaded = () => {
- let pendingRequests = 0;
- cy.intercept('*', (req) => {
- pendingRequests++;
- req.on('response', () => {
- pendingRequests--;
- });
- }).as('anyRequest');
- function waitForRequestsToFinish() {
- if (pendingRequests > 0) {
- cy.wait(1000).then(waitForRequestsToFinish);
- }
- else {
- cy.log('No new network requests, page considered loaded');
- }
+ let pendingRequests = 0
+ cy.intercept('*', (req) => {
+ pendingRequests++
+ req.on('response', () => {
+ pendingRequests--
+ })
+ }).as('anyRequest')
+ function waitForRequestsToFinish() {
+ if (pendingRequests > 0) {
+ cy.wait(1000).then(waitForRequestsToFinish)
+ } else {
+ cy.log('No new network requests, page considered loaded')
}
- waitForRequestsToFinish();
-};
-exports.ttPageLoaded = ttPageLoaded;
+ }
+ waitForRequestsToFinish()
+}
+exports.ttPageLoaded = ttPageLoaded
diff --git a/dist/commands/tt-setup-console-error-listener.d.ts b/dist/commands/tt-setup-console-error-listener.d.ts
index dfc0008..5a53efa 100644
--- a/dist/commands/tt-setup-console-error-listener.d.ts
+++ b/dist/commands/tt-setup-console-error-listener.d.ts
@@ -1 +1 @@
-export declare const ttSetupConsoleErrorListener: () => void;
+export declare const ttSetupConsoleErrorListener: () => void
diff --git a/dist/commands/tt-setup-console-error-listener.js b/dist/commands/tt-setup-console-error-listener.js
index b233457..01151cb 100644
--- a/dist/commands/tt-setup-console-error-listener.js
+++ b/dist/commands/tt-setup-console-error-listener.js
@@ -1,35 +1,35 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttSetupConsoleErrorListener = void 0;
-let errors = [];
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttSetupConsoleErrorListener = void 0
+let errors = []
const ttSetupConsoleErrorListener = () => {
- cy.log('ttSetupConsoleErrorListener - Setting up error listener');
- // Clear previous errors
- errors = [];
- // Attach error event listener to the window object
- cy.window().then((win) => {
- win.addEventListener('error', (event) => {
- errors.push(`Console error: ${event.message}`);
- });
- });
- // Intercept network requests
- cy.intercept('*', (req) => {
- req.continue((res) => {
- // Check for network errors
- if (res.statusCode >= 400) {
- errors.push(`Network error: ${res.statusCode} - ${req.url}`);
- }
- });
- }).as('networkRequests');
- // Reload the page
- cy.reload();
- // Wait for the page to load and stabilize
- cy.window().should('exist');
- // Check for errors after the page load
- cy.then(() => {
- if (errors.length) {
- throw new Error(`Errors detected:\n${errors.join('\n')}`);
- }
- });
-};
-exports.ttSetupConsoleErrorListener = ttSetupConsoleErrorListener;
+ cy.log('ttSetupConsoleErrorListener - Setting up error listener')
+ // Clear previous errors
+ errors = []
+ // Attach error event listener to the window object
+ cy.window().then((win) => {
+ win.addEventListener('error', (event) => {
+ errors.push(`Console error: ${event.message}`)
+ })
+ })
+ // Intercept network requests
+ cy.intercept('*', (req) => {
+ req.continue((res) => {
+ // Check for network errors
+ if (res.statusCode >= 400) {
+ errors.push(`Network error: ${res.statusCode} - ${req.url}`)
+ }
+ })
+ }).as('networkRequests')
+ // Reload the page
+ cy.reload()
+ // Wait for the page to load and stabilize
+ cy.window().should('exist')
+ // Check for errors after the page load
+ cy.then(() => {
+ if (errors.length) {
+ throw new Error(`Errors detected:\n${errors.join('\n')}`)
+ }
+ })
+}
+exports.ttSetupConsoleErrorListener = ttSetupConsoleErrorListener
diff --git a/dist/commands/tt-threshold.d.ts b/dist/commands/tt-threshold.d.ts
index 89a4377..6958a0f 100644
--- a/dist/commands/tt-threshold.d.ts
+++ b/dist/commands/tt-threshold.d.ts
@@ -1 +1 @@
-export declare const ttThreshold: (thresholdMB?: number) => void;
+export declare const ttThreshold: (thresholdMB?: number) => void
diff --git a/dist/commands/tt-threshold.js b/dist/commands/tt-threshold.js
index f8d601a..4e726f5 100644
--- a/dist/commands/tt-threshold.js
+++ b/dist/commands/tt-threshold.js
@@ -1,67 +1,70 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttThreshold = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttThreshold = void 0
const ttThreshold = (thresholdMB = 3) => {
- cy.window().then((win) => {
- win.performance.clearResourceTimings();
- cy.reload().then(() => {
- cy.window().then((reloadedWin) => {
- const resources = reloadedWin.performance.getEntriesByType('resource');
- const categorizedResources = {
- JavaScript: [],
- CSS: [],
- Images: [],
- Other: []
- };
- // Categorize resources by type
- resources.forEach((resource) => {
- const url = resource.name.toLowerCase();
- if (url.endsWith('.js')) {
- categorizedResources.JavaScript.push(resource);
- }
- else if (url.endsWith('.css')) {
- categorizedResources.CSS.push(resource);
- }
- else if (url.match(/\.(png|jpg|jpeg|gif|svg|webp)$/)) {
- categorizedResources.Images.push(resource);
- }
- else {
- categorizedResources.Other.push(resource);
- }
- });
- let pageWeight = 0;
- // Log the summary for each category first
- Object.keys(categorizedResources).forEach((type) => {
- let categoryWeight = 0;
- categorizedResources[type].forEach((resource) => {
- categoryWeight += resource.transferSize || resource.decodedBodySize;
- });
- const categoryWeightMB = categoryWeight / (1024 * 1024);
- pageWeight += categoryWeight;
- cy.log(`${type}: ${categoryWeightMB.toFixed(2)} MB`);
- });
- // Log details for each file within the categories
- Object.keys(categorizedResources).forEach((type) => {
- categorizedResources[type].forEach((resource) => {
- const sizeKB = (resource.transferSize || resource.decodedBodySize) / 1024;
- cy.log(` ${resource.name}: ${sizeKB.toFixed(2)} KB`);
- });
- });
- const thresholdBytes = thresholdMB * 1024 * 1024;
- const pageWeightMB = pageWeight / (1024 * 1024);
- const pageWeightKB = pageWeight / 1024;
- cy.log(`Total page weight: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`);
- // Delay assertion to ensure logs are displayed
- cy.then(() => {
- if (pageWeight > thresholdBytes) {
- assert.fail(`Page weight exceeds threshold: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`);
- }
- else {
- cy.log(`Page weight is within the threshold: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`);
- }
- });
- });
- });
- });
-};
-exports.ttThreshold = ttThreshold;
+ cy.window().then((win) => {
+ win.performance.clearResourceTimings()
+ cy.reload().then(() => {
+ cy.window().then((reloadedWin) => {
+ const resources = reloadedWin.performance.getEntriesByType('resource')
+ const categorizedResources = {
+ JavaScript: [],
+ CSS: [],
+ Images: [],
+ Other: []
+ }
+ // Categorize resources by type
+ resources.forEach((resource) => {
+ const url = resource.name.toLowerCase()
+ if (url.endsWith('.js')) {
+ categorizedResources.JavaScript.push(resource)
+ } else if (url.endsWith('.css')) {
+ categorizedResources.CSS.push(resource)
+ } else if (url.match(/\.(png|jpg|jpeg|gif|svg|webp)$/)) {
+ categorizedResources.Images.push(resource)
+ } else {
+ categorizedResources.Other.push(resource)
+ }
+ })
+ let pageWeight = 0
+ // Log the summary for each category first
+ Object.keys(categorizedResources).forEach((type) => {
+ let categoryWeight = 0
+ categorizedResources[type].forEach((resource) => {
+ categoryWeight += resource.transferSize || resource.decodedBodySize
+ })
+ const categoryWeightMB = categoryWeight / (1024 * 1024)
+ pageWeight += categoryWeight
+ cy.log(`${type}: ${categoryWeightMB.toFixed(2)} MB`)
+ })
+ // Log details for each file within the categories
+ Object.keys(categorizedResources).forEach((type) => {
+ categorizedResources[type].forEach((resource) => {
+ const sizeKB =
+ (resource.transferSize || resource.decodedBodySize) / 1024
+ cy.log(` ${resource.name}: ${sizeKB.toFixed(2)} KB`)
+ })
+ })
+ const thresholdBytes = thresholdMB * 1024 * 1024
+ const pageWeightMB = pageWeight / (1024 * 1024)
+ const pageWeightKB = pageWeight / 1024
+ cy.log(
+ `Total page weight: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`
+ )
+ // Delay assertion to ensure logs are displayed
+ cy.then(() => {
+ if (pageWeight > thresholdBytes) {
+ assert.fail(
+ `Page weight exceeds threshold: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`
+ )
+ } else {
+ cy.log(
+ `Page weight is within the threshold: ${pageWeightMB.toFixed(2)} MB (${pageWeightKB.toFixed(2)} KB)`
+ )
+ }
+ })
+ })
+ })
+ })
+}
+exports.ttThreshold = ttThreshold
diff --git a/dist/commands/tt-validate-all-images-response-status-ok.d.ts b/dist/commands/tt-validate-all-images-response-status-ok.d.ts
index 0c6ac1b..b3437cf 100644
--- a/dist/commands/tt-validate-all-images-response-status-ok.d.ts
+++ b/dist/commands/tt-validate-all-images-response-status-ok.d.ts
@@ -1 +1 @@
-export declare const ttValidateAllImagesResponseStatusOk: () => void;
+export declare const ttValidateAllImagesResponseStatusOk: () => void
diff --git a/dist/commands/tt-validate-all-images-response-status-ok.js b/dist/commands/tt-validate-all-images-response-status-ok.js
index 95f93d2..5dace62 100644
--- a/dist/commands/tt-validate-all-images-response-status-ok.js
+++ b/dist/commands/tt-validate-all-images-response-status-ok.js
@@ -1,190 +1,202 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidateAllImagesResponseStatusOk = void 0;
-const extractAuth_1 = require("./../utils/extractAuth");
-const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:'];
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidateAllImagesResponseStatusOk = void 0
+const extractAuth_1 = require('./../utils/extractAuth')
+const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:']
const isExcludedUrl = (url) => {
- return excludedUrlPrefixes.some((prefix) => url.startsWith(prefix));
-};
+ return excludedUrlPrefixes.some((prefix) => url.startsWith(prefix))
+}
const normalizeUrl = (url) => {
- return url.startsWith('//') ? `https:${url}` : url;
-};
+ return url.startsWith('//') ? `https:${url}` : url
+}
const buildImageSourceInfo = (img, index, type, pageUrl) => {
- var _a;
- const alt = (_a = img.getAttribute('alt')) !== null && _a !== void 0 ? _a : 'no alt';
- const id = img.getAttribute('id') ? `#${img.getAttribute('id')}` : '';
- const classes = img.className ? `.${Array.from(img.classList).join('.')}` : '';
- const parent = img.parentElement;
- const parentInfo = parent
- ? ` in ${parent.tagName.toLowerCase()}${parent.id ? '#' + parent.id : ''}${parent.className ? '.' + Array.from(parent.classList).join('.') : ''}`
- : '';
- const suffix = type === 'srcset' ? ' srcset' : '';
- return `IMG${id}${classes}${suffix} (alt: "${alt}", element ${index + 1}${parentInfo} on page ${pageUrl})`;
-};
+ var _a
+ const alt =
+ (_a = img.getAttribute('alt')) !== null && _a !== void 0 ? _a : 'no alt'
+ const id = img.getAttribute('id') ? `#${img.getAttribute('id')}` : ''
+ const classes = img.className ? `.${Array.from(img.classList).join('.')}` : ''
+ const parent = img.parentElement
+ const parentInfo = parent
+ ? ` in ${parent.tagName.toLowerCase()}${parent.id ? '#' + parent.id : ''}${parent.className ? '.' + Array.from(parent.classList).join('.') : ''}`
+ : ''
+ const suffix = type === 'srcset' ? ' srcset' : ''
+ return `IMG${id}${classes}${suffix} (alt: "${alt}", element ${index + 1}${parentInfo} on page ${pageUrl})`
+}
const extractCssImageUrls = () => {
- const cssImageUrls = [];
- const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:'];
- const isExcludedUrl = (url) => {
- return excludedUrlPrefixes.some((prefix) => url.startsWith(prefix));
- };
- // Get all CSS files loaded on the page
- const cssFiles = [];
- Array.from(document.styleSheets).forEach((sheet) => {
- if (sheet.href) {
- cssFiles.push(sheet.href);
- }
- });
- const cssFilesList = cssFiles.length > 0
- ? ` (CSS files: ${cssFiles.join(', ')})`
- : ' (inline styles)';
- const allElements = document.querySelectorAll('*');
- Array.from(allElements).forEach((element, index) => {
- const computedStyle = window.getComputedStyle(element);
- const backgroundImage = computedStyle.backgroundImage;
- if (backgroundImage && backgroundImage !== 'none') {
- // Extract URLs from url("...") or url('...') or url(...)
- const urlMatches = backgroundImage.match(/url\(['"]?([^'")]+)['"]?\)/g);
- if (urlMatches) {
- urlMatches.forEach((match) => {
- const url = match.replace(/url\(['"]?([^'")]+)['"]?\)/, '$1');
- if (url && !isExcludedUrl(url)) {
- const elementInfo = element.tagName.toLowerCase() +
- (element.id ? `#${element.id}` : '') +
- (element.className
- ? `.${Array.from(element.classList).join('.')}`
- : '') +
- ` (element ${index + 1})`;
- // Try to find which CSS rule applies
- let cssRuleInfo = '';
- try {
- for (let i = 0; i < document.styleSheets.length; i++) {
- const sheet = document.styleSheets[i];
- if (sheet.href && sheet.cssRules) {
- for (let j = 0; j < sheet.cssRules.length; j++) {
- const rule = sheet.cssRules[j];
- if (rule.selectorText &&
- element.matches &&
- element.matches(rule.selectorText)) {
- if (rule.style.backgroundImage &&
- rule.style.backgroundImage.includes(url)) {
- cssRuleInfo = ` from rule "${rule.selectorText}" in ${sheet.href}`;
- break;
- }
- }
- }
- if (cssRuleInfo)
- break;
- }
- }
- }
- catch {
- // Cross-origin or other CSS access issues
- cssRuleInfo = ' (CSS rule details unavailable due to CORS)';
- }
- cssImageUrls.push({
- url,
- source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList}`
- });
+ const cssImageUrls = []
+ const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:']
+ const isExcludedUrl = (url) => {
+ return excludedUrlPrefixes.some((prefix) => url.startsWith(prefix))
+ }
+ // Get all CSS files loaded on the page
+ const cssFiles = []
+ Array.from(document.styleSheets).forEach((sheet) => {
+ if (sheet.href) {
+ cssFiles.push(sheet.href)
+ }
+ })
+ const cssFilesList =
+ cssFiles.length > 0
+ ? ` (CSS files: ${cssFiles.join(', ')})`
+ : ' (inline styles)'
+ const allElements = document.querySelectorAll('*')
+ Array.from(allElements).forEach((element, index) => {
+ const computedStyle = window.getComputedStyle(element)
+ const backgroundImage = computedStyle.backgroundImage
+ if (backgroundImage && backgroundImage !== 'none') {
+ // Extract URLs from url("...") or url('...') or url(...)
+ const urlMatches = backgroundImage.match(/url\(['"]?([^'")]+)['"]?\)/g)
+ if (urlMatches) {
+ urlMatches.forEach((match) => {
+ const url = match.replace(/url\(['"]?([^'")]+)['"]?\)/, '$1')
+ if (url && !isExcludedUrl(url)) {
+ const elementInfo =
+ element.tagName.toLowerCase() +
+ (element.id ? `#${element.id}` : '') +
+ (element.className
+ ? `.${Array.from(element.classList).join('.')}`
+ : '') +
+ ` (element ${index + 1})`
+ // Try to find which CSS rule applies
+ let cssRuleInfo = ''
+ try {
+ for (let i = 0; i < document.styleSheets.length; i++) {
+ const sheet = document.styleSheets[i]
+ if (sheet.href && sheet.cssRules) {
+ for (let j = 0; j < sheet.cssRules.length; j++) {
+ const rule = sheet.cssRules[j]
+ if (
+ rule.selectorText &&
+ element.matches &&
+ element.matches(rule.selectorText)
+ ) {
+ if (
+ rule.style.backgroundImage &&
+ rule.style.backgroundImage.includes(url)
+ ) {
+ cssRuleInfo = ` from rule "${rule.selectorText}" in ${sheet.href}`
+ break
+ }
}
- });
+ }
+ if (cssRuleInfo) break
+ }
+ }
+ } catch {
+ // Cross-origin or other CSS access issues
+ cssRuleInfo = ' (CSS rule details unavailable due to CORS)'
}
- }
- });
- return cssImageUrls;
-};
+ cssImageUrls.push({
+ url,
+ source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList}`
+ })
+ }
+ })
+ }
+ }
+ })
+ return cssImageUrls
+}
const ttValidateAllImagesResponseStatusOk = () => {
- const imageMap = new Map(); // URL -> source description
- cy.log('Collecting images from DOM and CSS...');
- // First, collect CSS background images
- cy.window().then((win) => {
- const cssImages = win.eval(`(${extractCssImageUrls.toString()})()`);
- cssImages.forEach((item) => {
- const normalizedUrl = normalizeUrl(item.url);
- if (!isExcludedUrl(normalizedUrl)) {
- imageMap.set(normalizedUrl, item.source);
- cy.log(`📍 ${item.source}: ${item.url}`);
+ const imageMap = new Map() // URL -> source description
+ cy.log('Collecting images from DOM and CSS...')
+ // First, collect CSS background images
+ cy.window().then((win) => {
+ const cssImages = win.eval(`(${extractCssImageUrls.toString()})()`)
+ cssImages.forEach((item) => {
+ const normalizedUrl = normalizeUrl(item.url)
+ if (!isExcludedUrl(normalizedUrl)) {
+ imageMap.set(normalizedUrl, item.source)
+ cy.log(`📍 ${item.source}: ${item.url}`)
+ }
+ })
+ if (cssImages.length > 0) {
+ cy.log(`Found ${cssImages.length} CSS background images`)
+ }
+ })
+ // Then collect IMG tag images (make it optional)
+ cy.get('body')
+ .then(($body) => {
+ const imgElements = $body.find('img')
+ if (imgElements.length > 0) {
+ cy.log(`Found ${imgElements.length}
elements`)
+ const pageUrl = window.location.href
+ cy.get('img').each(($img, index) => {
+ var _a
+ const img = $img[0]
+ const src = img.getAttribute('src')
+ const srcset = img.getAttribute('srcset')
+ if (src !== null) {
+ const normalizedSrc = normalizeUrl(src)
+ if (!isExcludedUrl(normalizedSrc)) {
+ const imgSource = buildImageSourceInfo(img, index, 'src', pageUrl)
+ imageMap.set(normalizedSrc, imgSource)
+ cy.log(`📍 ${imgSource}: ${src}`)
}
- });
- if (cssImages.length > 0) {
- cy.log(`Found ${cssImages.length} CSS background images`);
- }
- });
- // Then collect IMG tag images (make it optional)
- cy.get('body')
- .then(($body) => {
- const imgElements = $body.find('img');
- if (imgElements.length > 0) {
- cy.log(`Found ${imgElements.length}
elements`);
- const pageUrl = window.location.href;
- cy.get('img').each(($img, index) => {
- var _a;
- const img = $img[0];
- const src = img.getAttribute('src');
- const srcset = img.getAttribute('srcset');
- if (src !== null) {
- const normalizedSrc = normalizeUrl(src);
- if (!isExcludedUrl(normalizedSrc)) {
- const imgSource = buildImageSourceInfo(img, index, 'src', pageUrl);
- imageMap.set(normalizedSrc, imgSource);
- cy.log(`📍 ${imgSource}: ${src}`);
- }
- }
- if (srcset !== null) {
- const srcsetUrls = srcset
- .split(',')
- .map((srcsetItem) => srcsetItem.trim().split(' ')[0])
- .map(normalizeUrl);
- srcsetUrls.forEach((url) => {
- if (!isExcludedUrl(url)) {
- const srcsetSource = buildImageSourceInfo(img, index, 'srcset', pageUrl);
- imageMap.set(url, srcsetSource);
- cy.log(`📍 ${srcsetSource}: ${url}`);
- }
- });
- }
- if (src === null && srcset === null) {
- const alt = (_a = img.getAttribute('alt')) !== null && _a !== void 0 ? _a : '';
- cy.log(`⚠️ Image ${alt} has neither src nor srcset attribute`);
- }
- });
+ }
+ if (srcset !== null) {
+ const srcsetUrls = srcset
+ .split(',')
+ .map((srcsetItem) => srcsetItem.trim().split(' ')[0])
+ .map(normalizeUrl)
+ srcsetUrls.forEach((url) => {
+ if (!isExcludedUrl(url)) {
+ const srcsetSource = buildImageSourceInfo(
+ img,
+ index,
+ 'srcset',
+ pageUrl
+ )
+ imageMap.set(url, srcsetSource)
+ cy.log(`📍 ${srcsetSource}: ${url}`)
+ }
+ })
+ }
+ if (src === null && srcset === null) {
+ const alt =
+ (_a = img.getAttribute('alt')) !== null && _a !== void 0 ? _a : ''
+ cy.log(`⚠️ Image ${alt} has neither src nor srcset attribute`)
+ }
+ })
+ } else {
+ cy.log('No
elements found')
+ }
+ return null
+ })
+ .then(() => {
+ // Validate all collected images
+ const totalImages = imageMap.size
+ if (totalImages === 0) {
+ cy.log('✅ No images found to validate')
+ return
+ }
+ cy.log(`🔍 Validating ${totalImages} total images (IMG + CSS)`)
+ const baseUrl = Cypress.config('baseUrl')
+ const auth = (0, extractAuth_1.extractAuth)(baseUrl)
+ Array.from(imageMap.entries()).forEach(([url, source]) => {
+ const requestOptions = {
+ method: 'HEAD',
+ url: url,
+ failOnStatusCode: false
}
- else {
- cy.log('No
elements found');
+ if (auth) {
+ requestOptions.auth = {
+ username: auth.username,
+ password: auth.password
+ }
}
- return null;
+ cy.request(requestOptions).then((response) => {
+ if (response.status === 200) {
+ cy.log(`✅ ${url}`)
+ } else {
+ cy.log(`❌ ${url} - Status: ${response.status}`)
+ throw new Error(
+ `Image validation failed: ${url} returned ${response.status}. Source: ${source}`
+ )
+ }
+ })
+ })
})
- .then(() => {
- // Validate all collected images
- const totalImages = imageMap.size;
- if (totalImages === 0) {
- cy.log('✅ No images found to validate');
- return;
- }
- cy.log(`🔍 Validating ${totalImages} total images (IMG + CSS)`);
- const baseUrl = Cypress.config('baseUrl');
- const auth = (0, extractAuth_1.extractAuth)(baseUrl);
- Array.from(imageMap.entries()).forEach(([url, source]) => {
- const requestOptions = {
- method: 'HEAD',
- url: url,
- failOnStatusCode: false
- };
- if (auth) {
- requestOptions.auth = {
- username: auth.username,
- password: auth.password
- };
- }
- cy.request(requestOptions).then((response) => {
- if (response.status === 200) {
- cy.log(`✅ ${url}`);
- }
- else {
- cy.log(`❌ ${url} - Status: ${response.status}`);
- throw new Error(`Image validation failed: ${url} returned ${response.status}. Source: ${source}`);
- }
- });
- });
- });
-};
-exports.ttValidateAllImagesResponseStatusOk = ttValidateAllImagesResponseStatusOk;
+}
+exports.ttValidateAllImagesResponseStatusOk =
+ ttValidateAllImagesResponseStatusOk
diff --git a/dist/commands/tt-validate-imprint-clickable.d.ts b/dist/commands/tt-validate-imprint-clickable.d.ts
index d0702f0..ba84965 100644
--- a/dist/commands/tt-validate-imprint-clickable.d.ts
+++ b/dist/commands/tt-validate-imprint-clickable.d.ts
@@ -1 +1 @@
-export declare const ttValidateImprintClickable: () => void;
+export declare const ttValidateImprintClickable: () => void
diff --git a/dist/commands/tt-validate-imprint-clickable.js b/dist/commands/tt-validate-imprint-clickable.js
index d02244b..6ae8717 100644
--- a/dist/commands/tt-validate-imprint-clickable.js
+++ b/dist/commands/tt-validate-imprint-clickable.js
@@ -1,29 +1,32 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidateImprintClickable = void 0;
-const chai_1 = require("chai");
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidateImprintClickable = void 0
+const chai_1 = require('chai')
const ttValidateImprintClickable = () => {
- cy.get('a')
- .each(($el, _index, _$list) => {
- if ($el.text().toLowerCase().includes('impressum')) {
- const element = $el.get(0);
- const rect = element.getBoundingClientRect();
- const elAtPoint = document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2);
- const clickable = elAtPoint === element || element.contains(elAtPoint);
- if (clickable) {
- cy.wrap($el).click();
- cy.window().then((win) => {
- const isImpressum = win.location.href.includes('/impressum');
- (0, chai_1.expect)(isImpressum).to.be.true;
- return false; // to break out of the each loop
- });
- }
+ cy.get('a')
+ .each(($el, _index, _$list) => {
+ if ($el.text().toLowerCase().includes('impressum')) {
+ const element = $el.get(0)
+ const rect = element.getBoundingClientRect()
+ const elAtPoint = document.elementFromPoint(
+ rect.left + rect.width / 2,
+ rect.top + rect.height / 2
+ )
+ const clickable = elAtPoint === element || element.contains(elAtPoint)
+ if (clickable) {
+ cy.wrap($el).click()
+ cy.window().then((win) => {
+ const isImpressum = win.location.href.includes('/impressum')
+ ;(0, chai_1.expect)(isImpressum).to.be.true
+ return false // to break out of the each loop
+ })
}
+ }
})
- .then(($list) => {
- if ($list.length === 0) {
- (0, chai_1.expect)(false).to.be.true; // Fails the test if no clickable link is found
- }
- });
-};
-exports.ttValidateImprintClickable = ttValidateImprintClickable;
+ .then(($list) => {
+ if ($list.length === 0) {
+ ;(0, chai_1.expect)(false).to.be.true // Fails the test if no clickable link is found
+ }
+ })
+}
+exports.ttValidateImprintClickable = ttValidateImprintClickable
diff --git a/dist/commands/tt-validate-language-tag.d.ts b/dist/commands/tt-validate-language-tag.d.ts
index 768ce3c..e6cda39 100644
--- a/dist/commands/tt-validate-language-tag.d.ts
+++ b/dist/commands/tt-validate-language-tag.d.ts
@@ -1 +1 @@
-export declare const ttValidateLanguageTag: (language?: string) => void;
+export declare const ttValidateLanguageTag: (language?: string) => void
diff --git a/dist/commands/tt-validate-language-tag.js b/dist/commands/tt-validate-language-tag.js
index 9d0b2b6..ee8b04b 100644
--- a/dist/commands/tt-validate-language-tag.js
+++ b/dist/commands/tt-validate-language-tag.js
@@ -1,15 +1,15 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidateLanguageTag = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidateLanguageTag = void 0
const ttValidateLanguageTag = (language = 'de') => {
- cy.log('ttValidateLanguageTag - NCA TESTIFY');
- // @ts-ignore - Custom command registered at runtime
- cy.ttEl('html', 'htmlElement').should('have.attr', 'lang');
- // @ts-ignore - Custom command registered at runtime
- cy.ttEl('html', 'htmlElement')
- .invoke('attr', 'lang')
- .then((langTag) => {
- expect(langTag.toLowerCase()).to.contain(language);
- });
-};
-exports.ttValidateLanguageTag = ttValidateLanguageTag;
+ cy.log('ttValidateLanguageTag - NCA TESTIFY')
+ // @ts-ignore - Custom command registered at runtime
+ cy.ttEl('html', 'htmlElement').should('have.attr', 'lang')
+ // @ts-ignore - Custom command registered at runtime
+ cy.ttEl('html', 'htmlElement')
+ .invoke('attr', 'lang')
+ .then((langTag) => {
+ expect(langTag.toLowerCase()).to.contain(language)
+ })
+}
+exports.ttValidateLanguageTag = ttValidateLanguageTag
diff --git a/dist/commands/tt-validate-no-google-services.d.ts b/dist/commands/tt-validate-no-google-services.d.ts
index 1d3597f..e110711 100644
--- a/dist/commands/tt-validate-no-google-services.d.ts
+++ b/dist/commands/tt-validate-no-google-services.d.ts
@@ -1 +1 @@
-export declare const ttValidateNoGoogleServices: () => void;
+export declare const ttValidateNoGoogleServices: () => void
diff --git a/dist/commands/tt-validate-no-google-services.js b/dist/commands/tt-validate-no-google-services.js
index f423da1..d93c6dd 100644
--- a/dist/commands/tt-validate-no-google-services.js
+++ b/dist/commands/tt-validate-no-google-services.js
@@ -1,17 +1,21 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidateNoGoogleServices = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidateNoGoogleServices = void 0
const ttValidateNoGoogleServices = () => {
- cy.on('request', (req) => {
- var _a;
- if (!req.url.startsWith(`${(_a = Cypress.config('baseUrl')) !== null && _a !== void 0 ? _a : ''}`)) {
- cy.log('External url: ' + String(req.url));
- expect(req.url).not.to.contain('/fonts.gstatic.com/');
- expect(req.url).not.to.contain('/fonts.googleapis.com/');
- expect(req.url).not.to.contain('/maps.google');
- expect(req.url).not.to.contain('/google.com/maps');
- }
- });
- cy.reload();
-};
-exports.ttValidateNoGoogleServices = ttValidateNoGoogleServices;
+ cy.on('request', (req) => {
+ var _a
+ if (
+ !req.url.startsWith(
+ `${(_a = Cypress.config('baseUrl')) !== null && _a !== void 0 ? _a : ''}`
+ )
+ ) {
+ cy.log('External url: ' + String(req.url))
+ expect(req.url).not.to.contain('/fonts.gstatic.com/')
+ expect(req.url).not.to.contain('/fonts.googleapis.com/')
+ expect(req.url).not.to.contain('/maps.google')
+ expect(req.url).not.to.contain('/google.com/maps')
+ }
+ })
+ cy.reload()
+}
+exports.ttValidateNoGoogleServices = ttValidateNoGoogleServices
diff --git a/dist/commands/tt-validate-page-content.d.ts b/dist/commands/tt-validate-page-content.d.ts
index bc0a440..294aa08 100644
--- a/dist/commands/tt-validate-page-content.d.ts
+++ b/dist/commands/tt-validate-page-content.d.ts
@@ -1 +1 @@
-export declare const ttValidatePageContent: () => void;
+export declare const ttValidatePageContent: () => void
diff --git a/dist/commands/tt-validate-page-content.js b/dist/commands/tt-validate-page-content.js
index 2f0e62b..0788fc9 100644
--- a/dist/commands/tt-validate-page-content.js
+++ b/dist/commands/tt-validate-page-content.js
@@ -1,15 +1,15 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidatePageContent = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidatePageContent = void 0
// @ts-nocheck - Cypress custom commands are dynamically registered
const ttValidatePageContent = () => {
- cy.ttAccessibility();
- cy.ttValidateNoGoogleServices();
- cy.ttValidateAllImagesResponseStatusOk();
- cy.ttEveryInternalLinkStatusOk();
- cy.ttEveryInternalLinkIsLoading();
- cy.ttValidateImprintClickable();
- cy.ttOnlyOneH1();
- cy.ttDetectHttp();
-};
-exports.ttValidatePageContent = ttValidatePageContent;
+ cy.ttAccessibility()
+ cy.ttValidateNoGoogleServices()
+ cy.ttValidateAllImagesResponseStatusOk()
+ cy.ttEveryInternalLinkStatusOk()
+ cy.ttEveryInternalLinkIsLoading()
+ cy.ttValidateImprintClickable()
+ cy.ttOnlyOneH1()
+ cy.ttDetectHttp()
+}
+exports.ttValidatePageContent = ttValidatePageContent
diff --git a/dist/commands/tt-validate-subpages-and-images.d.ts b/dist/commands/tt-validate-subpages-and-images.d.ts
index 689c643..7b0368c 100644
--- a/dist/commands/tt-validate-subpages-and-images.d.ts
+++ b/dist/commands/tt-validate-subpages-and-images.d.ts
@@ -1 +1,4 @@
-export declare const ttValidateSubpagesAndImages: (limit?: number, linkSelector?: string) => Cypress.Chainable;
+export declare const ttValidateSubpagesAndImages: (
+ limit?: number,
+ linkSelector?: string
+) => Cypress.Chainable
diff --git a/dist/commands/tt-validate-subpages-and-images.js b/dist/commands/tt-validate-subpages-and-images.js
index 0d091f2..e638c4e 100644
--- a/dist/commands/tt-validate-subpages-and-images.js
+++ b/dist/commands/tt-validate-subpages-and-images.js
@@ -1,22 +1,24 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ttValidateSubpagesAndImages = void 0;
-const tt_get_internal_links_1 = require("./tt-get-internal-links");
-const tt_validate_all_images_response_status_ok_1 = require("./tt-validate-all-images-response-status-ok");
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.ttValidateSubpagesAndImages = void 0
+const tt_get_internal_links_1 = require('./tt-get-internal-links')
+const tt_validate_all_images_response_status_ok_1 = require('./tt-validate-all-images-response-status-ok')
const ttValidateSubpagesAndImages = (limit = 20, linkSelector) => {
- cy.log('ttValidateSubpagesAndImages - NCA TESTIFY');
- return (0, tt_get_internal_links_1.ttGetInternalLinks)(linkSelector).then((urls) => {
- urls.slice(0, limit).forEach((url) => {
- if (!url.includes('.pdf')) {
- cy.visit(url);
- (0, tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk)();
- }
- else {
- cy.log('PDF detected' + url);
- }
- cy.clearAllLocalStorage();
- });
- return null;
- });
-};
-exports.ttValidateSubpagesAndImages = ttValidateSubpagesAndImages;
+ cy.log('ttValidateSubpagesAndImages - NCA TESTIFY')
+ return (0, tt_get_internal_links_1.ttGetInternalLinks)(linkSelector).then(
+ (urls) => {
+ urls.slice(0, limit).forEach((url) => {
+ if (!url.includes('.pdf')) {
+ cy.visit(url)
+ ;(0,
+ tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk)()
+ } else {
+ cy.log('PDF detected' + url)
+ }
+ cy.clearAllLocalStorage()
+ })
+ return null
+ }
+ )
+}
+exports.ttValidateSubpagesAndImages = ttValidateSubpagesAndImages
diff --git a/dist/e2e.d.ts b/dist/e2e.d.ts
index 9951b51..b43e8c4 100644
--- a/dist/e2e.d.ts
+++ b/dist/e2e.d.ts
@@ -1,2 +1,2 @@
-import 'cypress-axe';
-import './commands';
+import 'cypress-axe'
+import './commands'
diff --git a/dist/e2e.js b/dist/e2e.js
index 49e92d8..0da3e4e 100644
--- a/dist/e2e.js
+++ b/dist/e2e.js
@@ -1,5 +1,5 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
@@ -14,8 +14,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
-require("cypress-axe");
+require('cypress-axe')
// Import commands.js using ES2015 syntax:
-require("./commands");
+require('./commands')
// Alternatively you can use CommonJS syntax:
// require('./commands')
diff --git a/dist/index.js b/dist/index.js
index 26ce575..13135ef 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,6 +1,11 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.BasePage = void 0;
-require("./commands");
-var BasePage_1 = require("./pages/BasePage");
-Object.defineProperty(exports, "BasePage", { enumerable: true, get: function () { return BasePage_1.BasePage; } });
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.BasePage = void 0
+require('./commands')
+var BasePage_1 = require('./pages/BasePage')
+Object.defineProperty(exports, 'BasePage', {
+ enumerable: true,
+ get: function () {
+ return BasePage_1.BasePage
+ }
+})
diff --git a/dist/pages/BasePage.d.ts b/dist/pages/BasePage.d.ts
index e40d4b4..2370f59 100644
--- a/dist/pages/BasePage.d.ts
+++ b/dist/pages/BasePage.d.ts
@@ -1,4 +1,7 @@
export declare abstract class BasePage {
- protected el(selector: string, name?: string): Cypress.Chainable>;
- private extractGetterName;
+ protected el(
+ selector: string,
+ name?: string
+ ): Cypress.Chainable>
+ private extractGetterName
}
diff --git a/dist/pages/BasePage.js b/dist/pages/BasePage.js
index 913e2e9..e5377ed 100644
--- a/dist/pages/BasePage.js
+++ b/dist/pages/BasePage.js
@@ -1,19 +1,25 @@
-"use strict";
+'use strict'
///
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.BasePage = void 0;
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.BasePage = void 0
class BasePage {
- el(selector, name) {
- const logName = name || this.extractGetterName() || selector;
- cy.log(logName);
- return cy.get(selector);
- }
- extractGetterName() {
- var _a, _b;
- const stack = new Error().stack;
- if (!stack)
- return null;
- return ((_b = (_a = stack.split('\n')[3]) === null || _a === void 0 ? void 0 : _a.match(/get (\w+)/)) === null || _b === void 0 ? void 0 : _b[1]) || null;
- }
+ el(selector, name) {
+ const logName = name || this.extractGetterName() || selector
+ cy.log(logName)
+ return cy.get(selector)
+ }
+ extractGetterName() {
+ var _a, _b
+ const stack = new Error().stack
+ if (!stack) return null
+ return (
+ ((_b =
+ (_a = stack.split('\n')[3]) === null || _a === void 0
+ ? void 0
+ : _a.match(/get (\w+)/)) === null || _b === void 0
+ ? void 0
+ : _b[1]) || null
+ )
+ }
}
-exports.BasePage = BasePage;
+exports.BasePage = BasePage
diff --git a/dist/utils/domainMapping.d.ts b/dist/utils/domainMapping.d.ts
index d051684..f35d260 100644
--- a/dist/utils/domainMapping.d.ts
+++ b/dist/utils/domainMapping.d.ts
@@ -2,28 +2,36 @@
* Domain mapping configuration for staging/testing environments
*/
export interface DomainMappingConfig {
- /** Manual domain mappings: production domain -> staging domain */
- mappings?: {
- [prodDomain: string]: string;
- };
- /** Auto-detect staging patterns from baseUrl (default: true) */
- autoDetectFromBaseUrl?: boolean;
- /** Additional domains to include in link discovery */
- includedDomains?: string[];
- /** Minimum links required for validation (default: 1) */
- minLinksRequired?: number;
+ /** Manual domain mappings: production domain -> staging domain */
+ mappings?: {
+ [prodDomain: string]: string
+ }
+ /** Auto-detect staging patterns from baseUrl (default: true) */
+ autoDetectFromBaseUrl?: boolean
+ /** Additional domains to include in link discovery */
+ includedDomains?: string[]
+ /** Minimum links required for validation (default: 1) */
+ minLinksRequired?: number
}
/**
* Auto-detect domain mappings based on common staging patterns
*/
export declare const autoDetectDomainMapping: (baseUrl: string) => {
- [key: string]: string;
-};
+ [key: string]: string
+}
/**
* Apply domain mapping to a URL
*/
-export declare const applyDomainMapping: (url: string, config: DomainMappingConfig, baseUrl: string) => string;
+export declare const applyDomainMapping: (
+ url: string,
+ config: DomainMappingConfig,
+ baseUrl: string
+) => string
/**
* Check if URL should be included based on domain mapping config
*/
-export declare const shouldIncludeUrl: (href: string, config: DomainMappingConfig, baseUrl: string) => boolean;
+export declare const shouldIncludeUrl: (
+ href: string,
+ config: DomainMappingConfig,
+ baseUrl: string
+) => boolean
diff --git a/dist/utils/domainMapping.js b/dist/utils/domainMapping.js
index e8c4e3c..69af8c1 100644
--- a/dist/utils/domainMapping.js
+++ b/dist/utils/domainMapping.js
@@ -1,103 +1,115 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.shouldIncludeUrl = exports.applyDomainMapping = exports.autoDetectDomainMapping = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.shouldIncludeUrl =
+ exports.applyDomainMapping =
+ exports.autoDetectDomainMapping =
+ void 0
/**
* Auto-detect domain mappings based on common staging patterns
*/
const autoDetectDomainMapping = (baseUrl) => {
- const mapping = {};
- try {
- const baseUrlObj = new URL(baseUrl);
- const hostname = baseUrlObj.hostname;
- // Common staging patterns
- const stagingPatterns = [
- 'staging',
- 'test',
- 'testing',
- 'dev',
- 'development',
- 'demo',
- 'qa',
- 'uat',
- 'preview',
- 'beta',
- 'testingcrud'
- ];
- // Check if this looks like a staging domain
- const looksLikeStaging = stagingPatterns.some((pattern) => hostname.toLowerCase().includes(pattern.toLowerCase()));
- if (looksLikeStaging) {
- // Special handling for complex patterns like "testingcrud.testify.projects.nevercodealone.de"
- if (hostname.includes('testingcrud.testify.projects.nevercodealone.de')) {
- mapping['nevercodealone.de'] = hostname;
- }
- // Handle other common patterns
- else {
- let prodDomain = hostname;
- // Remove common staging prefixes/subdomains
- stagingPatterns.forEach((pattern) => {
- prodDomain = prodDomain
- .replace(new RegExp(`^${pattern}\\.`, 'i'), '')
- .replace(new RegExp(`\\.${pattern}\\.`, 'i'), '.')
- .replace(new RegExp(`${pattern}-`, 'i'), '')
- .replace(new RegExp(`-${pattern}`, 'i'), '')
- .replace(new RegExp(`${pattern}`, 'gi'), '');
- });
- // Clean up domain to get production equivalent
- const parts = prodDomain.split('.');
- if (parts.length > 2) {
- prodDomain = parts.slice(-2).join('.');
- }
- prodDomain = prodDomain.replace(/^\.+|\.+$/g, '').replace(/\.+/g, '.');
- if (prodDomain && prodDomain !== hostname && prodDomain.includes('.')) {
- mapping[prodDomain] = hostname;
- }
- }
+ const mapping = {}
+ try {
+ const baseUrlObj = new URL(baseUrl)
+ const hostname = baseUrlObj.hostname
+ // Common staging patterns
+ const stagingPatterns = [
+ 'staging',
+ 'test',
+ 'testing',
+ 'dev',
+ 'development',
+ 'demo',
+ 'qa',
+ 'uat',
+ 'preview',
+ 'beta',
+ 'testingcrud'
+ ]
+ // Check if this looks like a staging domain
+ const looksLikeStaging = stagingPatterns.some((pattern) =>
+ hostname.toLowerCase().includes(pattern.toLowerCase())
+ )
+ if (looksLikeStaging) {
+ // Special handling for complex patterns like "testingcrud.testify.projects.nevercodealone.de"
+ if (hostname.includes('testingcrud.testify.projects.nevercodealone.de')) {
+ mapping['nevercodealone.de'] = hostname
+ }
+ // Handle other common patterns
+ else {
+ let prodDomain = hostname
+ // Remove common staging prefixes/subdomains
+ stagingPatterns.forEach((pattern) => {
+ prodDomain = prodDomain
+ .replace(new RegExp(`^${pattern}\\.`, 'i'), '')
+ .replace(new RegExp(`\\.${pattern}\\.`, 'i'), '.')
+ .replace(new RegExp(`${pattern}-`, 'i'), '')
+ .replace(new RegExp(`-${pattern}`, 'i'), '')
+ .replace(new RegExp(`${pattern}`, 'gi'), '')
+ })
+ // Clean up domain to get production equivalent
+ const parts = prodDomain.split('.')
+ if (parts.length > 2) {
+ prodDomain = parts.slice(-2).join('.')
}
+ prodDomain = prodDomain.replace(/^\.+|\.+$/g, '').replace(/\.+/g, '.')
+ if (prodDomain && prodDomain !== hostname && prodDomain.includes('.')) {
+ mapping[prodDomain] = hostname
+ }
+ }
}
- catch (error) {
- console.warn('Could not auto-detect domain mapping:', error);
- }
- return mapping;
-};
-exports.autoDetectDomainMapping = autoDetectDomainMapping;
+ } catch (error) {
+ console.warn('Could not auto-detect domain mapping:', error)
+ }
+ return mapping
+}
+exports.autoDetectDomainMapping = autoDetectDomainMapping
/**
* Apply domain mapping to a URL
*/
const applyDomainMapping = (url, config, baseUrl) => {
- let mappedUrl = url;
- // Get all mappings (manual + auto-detected)
- const autoMappings = config.autoDetectFromBaseUrl !== false
- ? (0, exports.autoDetectDomainMapping)(baseUrl)
- : {};
- const allMappings = { ...autoMappings, ...config.mappings };
- // Apply domain mappings
- Object.keys(allMappings).forEach((prodDomain) => {
- const stagingDomain = allMappings[prodDomain];
- if (url.includes(prodDomain) && !url.includes(stagingDomain)) {
- mappedUrl = url.replace(prodDomain, stagingDomain);
- }
- });
- return mappedUrl;
-};
-exports.applyDomainMapping = applyDomainMapping;
+ let mappedUrl = url
+ // Get all mappings (manual + auto-detected)
+ const autoMappings =
+ config.autoDetectFromBaseUrl !== false
+ ? (0, exports.autoDetectDomainMapping)(baseUrl)
+ : {}
+ const allMappings = { ...autoMappings, ...config.mappings }
+ // Apply domain mappings
+ Object.keys(allMappings).forEach((prodDomain) => {
+ const stagingDomain = allMappings[prodDomain]
+ if (url.includes(prodDomain) && !url.includes(stagingDomain)) {
+ mappedUrl = url.replace(prodDomain, stagingDomain)
+ }
+ })
+ return mappedUrl
+}
+exports.applyDomainMapping = applyDomainMapping
/**
* Check if URL should be included based on domain mapping config
*/
const shouldIncludeUrl = (href, config, baseUrl) => {
- var _a;
- // Include internal links (same domain as baseUrl)
- if (href.startsWith('/') || href.includes(baseUrl)) {
- return true;
- }
- // Include specifically configured domains
- if ((_a = config.includedDomains) === null || _a === void 0 ? void 0 : _a.some((domain) => href.includes(domain))) {
- return true;
- }
- // Include domains from mappings (both manual and auto-detected)
- const autoMappings = config.autoDetectFromBaseUrl !== false
- ? (0, exports.autoDetectDomainMapping)(baseUrl)
- : {};
- const allMappings = { ...autoMappings, ...config.mappings };
- return Object.keys(allMappings).some((prodDomain) => href.includes(prodDomain));
-};
-exports.shouldIncludeUrl = shouldIncludeUrl;
+ var _a
+ // Include internal links (same domain as baseUrl)
+ if (href.startsWith('/') || href.includes(baseUrl)) {
+ return true
+ }
+ // Include specifically configured domains
+ if (
+ (_a = config.includedDomains) === null || _a === void 0
+ ? void 0
+ : _a.some((domain) => href.includes(domain))
+ ) {
+ return true
+ }
+ // Include domains from mappings (both manual and auto-detected)
+ const autoMappings =
+ config.autoDetectFromBaseUrl !== false
+ ? (0, exports.autoDetectDomainMapping)(baseUrl)
+ : {}
+ const allMappings = { ...autoMappings, ...config.mappings }
+ return Object.keys(allMappings).some((prodDomain) =>
+ href.includes(prodDomain)
+ )
+}
+exports.shouldIncludeUrl = shouldIncludeUrl
diff --git a/dist/utils/extractAuth.d.ts b/dist/utils/extractAuth.d.ts
index 580d27e..feb22b7 100644
--- a/dist/utils/extractAuth.d.ts
+++ b/dist/utils/extractAuth.d.ts
@@ -4,23 +4,29 @@
* @returns Object with auth credentials or null
*/
export declare const extractAuth: (url: string) => {
- username: string;
- password: string;
-} | null;
+ username: string
+ password: string
+} | null
/**
* Apply Basic Auth credentials to a URL
* @param url - Target URL
* @param auth - Auth credentials
* @returns URL with auth credentials
*/
-export declare const applyAuth: (url: string, auth: {
- username: string;
- password: string;
-} | null) => string;
+export declare const applyAuth: (
+ url: string,
+ auth: {
+ username: string
+ password: string
+ } | null
+) => string
/**
* Add baseUrl credentials to internal links using simple @ split approach
* @param links - Array of internal link URLs
* @param baseUrl - Base URL that may contain credentials (e.g., https://user:pass@domain.com)
* @returns Array of links with credentials applied
*/
-export declare const addCredentialsToInternalLinks: (links: string[], baseUrl?: string) => string[];
+export declare const addCredentialsToInternalLinks: (
+ links: string[],
+ baseUrl?: string
+) => string[]
diff --git a/dist/utils/extractAuth.js b/dist/utils/extractAuth.js
index a29e970..a27a82e 100644
--- a/dist/utils/extractAuth.js
+++ b/dist/utils/extractAuth.js
@@ -1,27 +1,29 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.addCredentialsToInternalLinks = exports.applyAuth = exports.extractAuth = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.addCredentialsToInternalLinks =
+ exports.applyAuth =
+ exports.extractAuth =
+ void 0
/**
* Extract Basic Auth credentials from a URL
* @param url - URL string that may contain Basic Auth credentials
* @returns Object with auth credentials or null
*/
const extractAuth = (url) => {
- try {
- const urlObj = new URL(url);
- if (urlObj.username && urlObj.password) {
- return {
- username: urlObj.username,
- password: urlObj.password
- };
- }
- return null;
+ try {
+ const urlObj = new URL(url)
+ if (urlObj.username && urlObj.password) {
+ return {
+ username: urlObj.username,
+ password: urlObj.password
+ }
}
- catch {
- return null;
- }
-};
-exports.extractAuth = extractAuth;
+ return null
+ } catch {
+ return null
+ }
+}
+exports.extractAuth = extractAuth
/**
* Apply Basic Auth credentials to a URL
* @param url - Target URL
@@ -29,19 +31,17 @@ exports.extractAuth = extractAuth;
* @returns URL with auth credentials
*/
const applyAuth = (url, auth) => {
- if (!auth)
- return url;
- try {
- const urlObj = new URL(url);
- urlObj.username = auth.username;
- urlObj.password = auth.password;
- return urlObj.toString();
- }
- catch {
- return url;
- }
-};
-exports.applyAuth = applyAuth;
+ if (!auth) return url
+ try {
+ const urlObj = new URL(url)
+ urlObj.username = auth.username
+ urlObj.password = auth.password
+ return urlObj.toString()
+ } catch {
+ return url
+ }
+}
+exports.applyAuth = applyAuth
/**
* Add baseUrl credentials to internal links using simple @ split approach
* @param links - Array of internal link URLs
@@ -49,30 +49,28 @@ exports.applyAuth = applyAuth;
* @returns Array of links with credentials applied
*/
const addCredentialsToInternalLinks = (links, baseUrl) => {
- if (!baseUrl) {
- baseUrl =
- typeof Cypress !== 'undefined' ? Cypress.config('baseUrl') : undefined;
+ if (!baseUrl) {
+ baseUrl =
+ typeof Cypress !== 'undefined' ? Cypress.config('baseUrl') : undefined
+ }
+ // Return original links if no baseUrl or no credentials
+ if (!baseUrl || !baseUrl.includes('@')) return links
+ // Extract credential part (everything before @)
+ const credentialPart = baseUrl.split('@')[0] // e.g., "https://nca:nca"
+ return links.map((link) => {
+ // Skip if link already has credentials
+ if (link.includes('@')) return link
+ // For absolute URLs, replace protocol with credential part
+ if (link.includes('://')) {
+ const protocolEnd = link.indexOf('://') + 3
+ return credentialPart + '@' + link.substring(protocolEnd)
+ }
+ // For relative URLs, convert to absolute with credentials
+ if (link.startsWith('/')) {
+ const domainPart = baseUrl.split('@')[1] // e.g., "testify.projects.nevercodealone.de"
+ return credentialPart + '@' + domainPart + link
}
- // Return original links if no baseUrl or no credentials
- if (!baseUrl || !baseUrl.includes('@'))
- return links;
- // Extract credential part (everything before @)
- const credentialPart = baseUrl.split('@')[0]; // e.g., "https://nca:nca"
- return links.map((link) => {
- // Skip if link already has credentials
- if (link.includes('@'))
- return link;
- // For absolute URLs, replace protocol with credential part
- if (link.includes('://')) {
- const protocolEnd = link.indexOf('://') + 3;
- return credentialPart + '@' + link.substring(protocolEnd);
- }
- // For relative URLs, convert to absolute with credentials
- if (link.startsWith('/')) {
- const domainPart = baseUrl.split('@')[1]; // e.g., "testify.projects.nevercodealone.de"
- return credentialPart + '@' + domainPart + link;
- }
- return link;
- });
-};
-exports.addCredentialsToInternalLinks = addCredentialsToInternalLinks;
+ return link
+ })
+}
+exports.addCredentialsToInternalLinks = addCredentialsToInternalLinks
diff --git a/dist/utils/isInternal.d.ts b/dist/utils/isInternal.d.ts
index 5734837..e89122d 100644
--- a/dist/utils/isInternal.d.ts
+++ b/dist/utils/isInternal.d.ts
@@ -1,7 +1,7 @@
/**
* Type definitions for URL validation
*/
-type URLString = string;
+type URLString = string
/**
* Validates if URL is internal relative to base URL
*
@@ -14,5 +14,5 @@ type URLString = string;
* isInternal('https://same-domain.com/path') // true if baseUrl matches
* isInternal('https://other-domain.com') // false
*/
-export declare const isInternal: (url: URLString) => boolean;
-export {};
+export declare const isInternal: (url: URLString) => boolean
+export {}
diff --git a/dist/utils/isInternal.js b/dist/utils/isInternal.js
index 3a559b1..5814fff 100644
--- a/dist/utils/isInternal.js
+++ b/dist/utils/isInternal.js
@@ -1,78 +1,76 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.isInternal = void 0;
+'use strict'
+Object.defineProperty(exports, '__esModule', { value: true })
+exports.isInternal = void 0
/**
* Never Code Alone configuration
*/
const NCA_CONFIG = {
- ip: '213.203.219.157',
- domains: [
- 'nevercodealone.de',
- 'dsv98.de',
- 'projects.nevercodealone.de'
- ]
-};
+ ip: '213.203.219.157',
+ domains: ['nevercodealone.de', 'dsv98.de', 'projects.nevercodealone.de']
+}
/**
* Default base URL fallback
*/
-const DEFAULT_BASE_URL = 'https://localhost:3000';
+const DEFAULT_BASE_URL = 'https://localhost:3000'
/**
* Extracts domain from URL, removing protocol and path
*/
const extractDomain = (url) => {
- return url.replace(/https?:\/\//, '').split('/')[0];
-};
+ return url.replace(/https?:\/\//, '').split('/')[0]
+}
/**
* Checks if URL is a relative path
*/
const isRelativePath = (url) => {
- return url.startsWith('/') || !url.includes('://');
-};
+ return url.startsWith('/') || !url.includes('://')
+}
/**
* Gets base URL from Cypress config or environment
*/
const getBaseUrl = () => {
- if (typeof Cypress !== 'undefined') {
- return Cypress.config('baseUrl');
- }
- return process.env.BASE_URL || DEFAULT_BASE_URL;
-};
+ if (typeof Cypress !== 'undefined') {
+ return Cypress.config('baseUrl')
+ }
+ return process.env.BASE_URL || DEFAULT_BASE_URL
+}
/**
* Parses URL into validation result
*/
const parseUrl = (url) => {
- const isRelative = isRelativePath(url);
- if (isRelative) {
- return {
- domain: '',
- protocol: null,
- isRelative: true
- };
- }
- const protocol = url.startsWith('https://')
- ? 'https'
- : url.startsWith('http://')
- ? 'http'
- : null;
+ const isRelative = isRelativePath(url)
+ if (isRelative) {
return {
- domain: extractDomain(url),
- protocol,
- isRelative: false
- };
-};
+ domain: '',
+ protocol: null,
+ isRelative: true
+ }
+ }
+ const protocol = url.startsWith('https://')
+ ? 'https'
+ : url.startsWith('http://')
+ ? 'http'
+ : null
+ return {
+ domain: extractDomain(url),
+ protocol,
+ isRelative: false
+ }
+}
/**
* Checks if URL belongs to special NCA domain
*/
const isSpecialDomain = (url, config) => {
- return (url.includes(config.ip) ||
- config.domains.some((domain) => url.includes(domain)));
-};
+ return (
+ url.includes(config.ip) ||
+ config.domains.some((domain) => url.includes(domain))
+ )
+}
/**
* Checks if domains match
*/
const doDomainsMatch = (urlDomain, baseUrlDomain) => {
- return urlDomain === baseUrlDomain;
-};
+ return urlDomain === baseUrlDomain
+}
/**
* Validates if URL is internal relative to base URL
*
@@ -86,24 +84,24 @@ const doDomainsMatch = (urlDomain, baseUrlDomain) => {
* isInternal('https://other-domain.com') // false
*/
const isInternal = (url) => {
- const parsed = parseUrl(url);
- // Relative paths are always internal
- if (parsed.isRelative) {
- return true;
- }
- const baseUrl = getBaseUrl();
- const baseUrlParsed = parseUrl(baseUrl);
- // Same domain check (protocol-aware by default)
- if (parsed.domain === baseUrlParsed.domain) {
- return true;
- }
- // Special handling for NCA domains with protocol mismatch
- const isNCABaseUrl = isSpecialDomain(baseUrl, NCA_CONFIG);
- const isNCAUrl = isSpecialDomain(url, NCA_CONFIG);
- if (isNCABaseUrl && isNCAUrl) {
- return doDomainsMatch(parsed.domain, baseUrlParsed.domain);
- }
- // Standard check: URL must start with base URL
- return url.startsWith(baseUrl);
-};
-exports.isInternal = isInternal;
+ const parsed = parseUrl(url)
+ // Relative paths are always internal
+ if (parsed.isRelative) {
+ return true
+ }
+ const baseUrl = getBaseUrl()
+ const baseUrlParsed = parseUrl(baseUrl)
+ // Same domain check (protocol-aware by default)
+ if (parsed.domain === baseUrlParsed.domain) {
+ return true
+ }
+ // Special handling for NCA domains with protocol mismatch
+ const isNCABaseUrl = isSpecialDomain(baseUrl, NCA_CONFIG)
+ const isNCAUrl = isSpecialDomain(url, NCA_CONFIG)
+ if (isNCABaseUrl && isNCAUrl) {
+ return doDomainsMatch(parsed.domain, baseUrlParsed.domain)
+ }
+ // Standard check: URL must start with base URL
+ return url.startsWith(baseUrl)
+}
+exports.isInternal = isInternal
diff --git a/package.json b/package.json
index 273fa5b..37a562e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cypress-ncatestify-plugin",
- "version": "2.1.71",
+ "version": "2.1.72",
"description": "NCA TESTIFY commands and tests",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/src/commands/tt-el.ts b/src/commands/tt-el.ts
index 92ed544..6681087 100644
--- a/src/commands/tt-el.ts
+++ b/src/commands/tt-el.ts
@@ -1,7 +1,19 @@
+const extractCallerName = (): string | null => {
+ const stack = new Error().stack
+ if (!stack) return null
+ const lines = stack.split('\n')
+ for (const line of lines) {
+ const match = line.match(/get (\w+)/)
+ if (match) return match[1]
+ }
+ return null
+}
+
export const ttEl = (
selector: string,
name?: string
): Cypress.Chainable> => {
- cy.log(name || selector)
+ const logName = name || extractCallerName() || selector
+ cy.log(logName)
return cy.get(selector)
}
diff --git a/update.md b/update.md
index cfce18e..9df8a88 100644
--- a/update.md
+++ b/update.md
@@ -1,5 +1,10 @@
# Update md file
+2.1.72
+
+- Add auto-getter name extraction to cy.ttEl command via stack trace parsing
+- cy.ttEl now automatically logs getter names when used in page objects
+
2.1.71
- Add cy.ttEl(selector, name) command for semantic element logging