From 781155f66f7a12a1233d18264fe23a54bf6f3ee9 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Mon, 5 Jan 2026 17:33:00 +0100 Subject: [PATCH 01/17] Add ttEl type definition with JSDoc to cypress/index.d.ts --- cypress/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cypress/index.d.ts b/cypress/index.d.ts index f3fe1af..074abe1 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -1,5 +1,17 @@ +/// +/// + declare namespace Cypress { interface Chainable { + /** + * Select element with semantic logging (auto-extracts getter name from stack trace) + * @param selector - CSS selector + * @param name - Optional custom name for logging (overrides auto-detection) + * @example cy.ttEl('#myId') // logs getter name or selector + * @example cy.ttEl('#myId', 'Login Button') // logs "Login Button" + */ + ttEl(selector: string, name?: string): Chainable> + ttAccessibility(context?: any, options?: any): Chainable ttClickIfElementExist(element: string): Chainable ttCookieAllAcceptClick(): Chainable From 27fa1f20877e6914cc7ce4587c104a9e189a56b2 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Mon, 5 Jan 2026 17:34:47 +0100 Subject: [PATCH 02/17] Add changelog entry for version 2.1.73 --- update.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/update.md b/update.md index 9df8a88..f9e8cb8 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,9 @@ # Update md file +2.1.73 + +- Add ttEl type definition with JSDoc to cypress/index.d.ts + 2.1.72 - Add auto-getter name extraction to cy.ttEl command via stack trace parsing From b11042928fd942b9ab7d03b293128b7c82e003ba Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Mon, 5 Jan 2026 17:34:47 +0100 Subject: [PATCH 03/17] Bump version to 2.1.73 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37a562e..be2c2ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cypress-ncatestify-plugin", - "version": "2.1.72", + "version": "2.1.73", "description": "NCA TESTIFY commands and tests", "main": "dist/index.js", "types": "dist/index.d.ts", From 1801b19ada5a1cdb5b2cffd1620c4efa5524222e Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:48:45 +0100 Subject: [PATCH 04/17] Fix async boolean bug in ttEveryInternalLinkStatusOk Replace stale boolean tracking with failedLinks array and cy.then() assertion that properly fails tests when links return error statuses. --- .../tt-every-internal-link-status-ok.d.ts | 4 +- .../tt-every-internal-link-status-ok.js | 73 +++++++++---------- .../tt-every-internal-link-status-ok.ts | 25 ++++--- 3 files changed, 52 insertions(+), 50 deletions(-) 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 0a6c43f..0cb537b 100644 --- a/dist/commands/tt-every-internal-link-status-ok.d.ts +++ b/dist/commands/tt-every-internal-link-status-ok.d.ts @@ -1,3 +1 @@ -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 12e7b8d..6a819b6 100644 --- a/dist/commands/tt-every-internal-link-status-ok.js +++ b/dist/commands/tt-every-internal-link-status-ok.js @@ -1,39 +1,36 @@ -'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 + return cy.ttGetInternalLinks().then((urls) => { + cy.log('everyInternalLinkStatusOk - NCA TESTIFY'); + cy.wrap(urls).its('length').should('be.gte', minLinksRequired); + const failedLinks = []; + urls.forEach((url) => { + cy.request({ + url, + failOnStatusCode: false + }).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); + cy.log(`${success ? '✅' : '❌'} Testing ${url}: ${resp.status}`); + if (!success) { + failedLinks.push({ url, status: resp.status }); + cy.log(`⚠️ Link validation failed: ${url} returned ${resp.status}`); + } + } + else { + cy.log(`⏭️ Testing ${url}: Skipped (content-type: ${resp.headers['content-type']})`); + } + }); + }); + return cy.then(() => { + expect(failedLinks).to.have.length(0, `Links with invalid status: ${failedLinks.map((l) => `${l.url} (${l.status})`).join(', ')}`); + return null; + }); + }); +}; +exports.ttEveryInternalLinkStatusOk = ttEveryInternalLinkStatusOk; diff --git a/src/commands/tt-every-internal-link-status-ok.ts b/src/commands/tt-every-internal-link-status-ok.ts index 4f3e62c..7a9ea9a 100644 --- a/src/commands/tt-every-internal-link-status-ok.ts +++ b/src/commands/tt-every-internal-link-status-ok.ts @@ -1,26 +1,26 @@ +/// + export const ttEveryInternalLinkStatusOk = ( minLinksRequired: number = 1 ): Cypress.Chainable => { - //@ts-ignore - Custom command type not available in build context return cy.ttGetInternalLinks().then((urls: string[]) => { cy.log('everyInternalLinkStatusOk - NCA TESTIFY') cy.wrap(urls).its('length').should('be.gte', minLinksRequired) - let allLinksOk = true + const failedLinks: { url: string; status: number }[] = [] + urls.forEach((url) => { - const requestOptions: any = { - url: url, + cy.request({ + url, failOnStatusCode: false - } - - cy.request(requestOptions).then((resp) => { + }).then((resp) => { if (resp.headers['content-type']?.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) { + failedLinks.push({ url, status: resp.status }) cy.log(`⚠️ Link validation failed: ${url} returned ${resp.status}`) } } else { @@ -30,6 +30,13 @@ export const ttEveryInternalLinkStatusOk = ( } }) }) - return cy.wrap(allLinksOk) + + return cy.then(() => { + expect(failedLinks).to.have.length( + 0, + `Links with invalid status: ${failedLinks.map((l) => `${l.url} (${l.status})`).join(', ')}` + ) + return null + }) }) } From 1c3764325bde950d0a31c178d946126ecc65abae Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:48:51 +0100 Subject: [PATCH 05/17] Remove dead NCA special-case logic from isInternal Simplify from 152 lines to 56 by removing unused types, interfaces, and NCA_CONFIG that could never change the outcome of the check. --- dist/utils/isInternal.d.ts | 7 +-- dist/utils/isInternal.js | 102 ++++++++-------------------------- src/utils/isInternal.ts | 111 +++---------------------------------- 3 files changed, 33 insertions(+), 187 deletions(-) diff --git a/dist/utils/isInternal.d.ts b/dist/utils/isInternal.d.ts index e89122d..be5fa1e 100644 --- a/dist/utils/isInternal.d.ts +++ b/dist/utils/isInternal.d.ts @@ -1,7 +1,3 @@ -/** - * Type definitions for URL validation - */ -type URLString = string /** * Validates if URL is internal relative to base URL * @@ -14,5 +10,4 @@ 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: string) => boolean; diff --git a/dist/utils/isInternal.js b/dist/utils/isInternal.js index 5814fff..b216ceb 100644 --- a/dist/utils/isInternal.js +++ b/dist/utils/isInternal.js @@ -1,76 +1,31 @@ -'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'] -} +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isInternal = void 0; /** * 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 -} -/** - * Parses URL into validation result - */ -const parseUrl = (url) => { - const isRelative = isRelativePath(url) - if (isRelative) { - return { - domain: '', - protocol: null, - isRelative: true + if (typeof Cypress !== 'undefined') { + return Cypress.config('baseUrl'); } - } - 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)) - ) -} -/** - * Checks if domains match - */ -const doDomainsMatch = (urlDomain, baseUrlDomain) => { - return urlDomain === baseUrlDomain -} + return process.env.BASE_URL || DEFAULT_BASE_URL; +}; /** * Validates if URL is internal relative to base URL * @@ -84,24 +39,15 @@ 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 + if (isRelativePath(url)) { + return true; + } + const baseUrl = getBaseUrl(); + const urlDomain = extractDomain(url); + const baseUrlDomain = extractDomain(baseUrl); + if (urlDomain === baseUrlDomain) { + return true; + } + return url.startsWith(baseUrl); +}; +exports.isInternal = isInternal; diff --git a/src/utils/isInternal.ts b/src/utils/isInternal.ts index 1dcc3d8..5c49515 100644 --- a/src/utils/isInternal.ts +++ b/src/utils/isInternal.ts @@ -1,39 +1,3 @@ -/** - * Type definitions for URL validation - */ -type URLString = string -type Domain = string -type Protocol = 'http' | 'https' - -/** - * Configuration for special case domains - */ -interface SpecialDomainConfig { - readonly ip: string - readonly domains: readonly string[] -} - -/** - * URL validation result with metadata - */ -interface URLValidationResult { - readonly domain: Domain - readonly protocol: Protocol | null - readonly isRelative: boolean -} - -/** - * Never Code Alone configuration - */ -const NCA_CONFIG: SpecialDomainConfig = { - ip: '213.203.219.157', - domains: [ - 'nevercodealone.de', - 'dsv98.de', - 'projects.nevercodealone.de' - ] as const -} as const - /** * Default base URL fallback */ @@ -42,74 +6,27 @@ const DEFAULT_BASE_URL = 'https://localhost:3000' as const /** * Extracts domain from URL, removing protocol and path */ -const extractDomain = (url: URLString): Domain => { +const extractDomain = (url: string): string => { return url.replace(/https?:\/\//, '').split('/')[0] } /** * Checks if URL is a relative path */ -const isRelativePath = (url: URLString): boolean => { +const isRelativePath = (url: string): boolean => { return url.startsWith('/') || !url.includes('://') } /** * Gets base URL from Cypress config or environment */ -const getBaseUrl = (): URLString => { +const getBaseUrl = (): string => { if (typeof Cypress !== 'undefined') { return Cypress.config('baseUrl') } return process.env.BASE_URL || DEFAULT_BASE_URL } -/** - * Parses URL into validation result - */ -const parseUrl = (url: URLString): URLValidationResult => { - const isRelative = isRelativePath(url) - - if (isRelative) { - return { - 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: URLString, - config: SpecialDomainConfig -): boolean => { - return ( - url.includes(config.ip) || - config.domains.some((domain) => url.includes(domain)) - ) -} - -/** - * Checks if domains match - */ -const doDomainsMatch = (urlDomain: Domain, baseUrlDomain: Domain): boolean => { - return urlDomain === baseUrlDomain -} - /** * Validates if URL is internal relative to base URL * @@ -122,30 +39,18 @@ const doDomainsMatch = (urlDomain: Domain, baseUrlDomain: Domain): boolean => { * isInternal('https://same-domain.com/path') // true if baseUrl matches * isInternal('https://other-domain.com') // false */ -export const isInternal = (url: URLString): boolean => { - const parsed = parseUrl(url) - - // Relative paths are always internal - if (parsed.isRelative) { +export const isInternal = (url: string): boolean => { + if (isRelativePath(url)) { return true } const baseUrl = getBaseUrl() - const baseUrlParsed = parseUrl(baseUrl) + const urlDomain = extractDomain(url) + const baseUrlDomain = extractDomain(baseUrl) - // Same domain check (protocol-aware by default) - if (parsed.domain === baseUrlParsed.domain) { + if (urlDomain === baseUrlDomain) { 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) } From 6f9c36efc3ad83dd81163220035eff566aa8738b Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:48:55 +0100 Subject: [PATCH 06/17] Remove unused domainMapping module and its tests domainMapping.ts was never imported by any command. Delete the source, dist artifacts, and test file. --- __test__/domainMapping.test.ts | 146 --------------------------------- dist/utils/domainMapping.d.ts | 37 --------- dist/utils/domainMapping.js | 115 -------------------------- src/utils/domainMapping.ts | 142 -------------------------------- 4 files changed, 440 deletions(-) delete mode 100644 __test__/domainMapping.test.ts delete mode 100644 dist/utils/domainMapping.d.ts delete mode 100644 dist/utils/domainMapping.js delete mode 100644 src/utils/domainMapping.ts diff --git a/__test__/domainMapping.test.ts b/__test__/domainMapping.test.ts deleted file mode 100644 index 1572e19..0000000 --- a/__test__/domainMapping.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { describe, it, expect } from 'vitest' -import { - autoDetectDomainMapping, - applyDomainMapping, - shouldIncludeUrl -} from '../src/utils/domainMapping' - -describe('domainMapping', () => { - describe('autoDetectDomainMapping', () => { - const testCases = [ - { - name: 'should detect nevercodealone staging pattern', - input: 'https://testingcrud.testify.projects.nevercodealone.de', - expected: { - 'nevercodealone.de': 'testingcrud.testify.projects.nevercodealone.de' - } - }, - { - name: 'should detect common staging patterns', - input: 'https://staging.example.com', - expected: { 'example.com': 'staging.example.com' } - }, - { - name: 'should detect test subdomain patterns', - input: 'https://test.mysite.org', - expected: { 'mysite.org': 'test.mysite.org' } - }, - { - name: 'should return empty for production URLs', - input: 'https://example.com', - expected: {} - } - ] - - testCases.forEach(({ name, input, expected }) => { - it(name, () => { - const result = autoDetectDomainMapping(input) - expect(result).toEqual(expected) - }) - }) - }) - - describe('applyDomainMapping', () => { - const testCases = [ - { - name: 'should apply manual domain mapping', - url: 'https://example.com/page', - config: { - mappings: { 'example.com': 'staging.example.com' }, - autoDetectFromBaseUrl: false - }, - baseUrl: 'https://staging.example.com', - expected: 'https://staging.example.com/page' - }, - { - name: 'should apply auto-detected mapping', - url: 'https://nevercodealone.de/page', - config: { autoDetectFromBaseUrl: true }, - baseUrl: 'https://testingcrud.testify.projects.nevercodealone.de', - expected: 'https://testingcrud.testify.projects.nevercodealone.de/page' - }, - { - name: 'should not modify URLs that do not match mappings', - url: 'https://other.com/page', - config: { mappings: { 'example.com': 'staging.example.com' } }, - baseUrl: 'https://staging.example.com', - expected: 'https://other.com/page' - }, - { - name: 'should prioritize manual mappings over auto-detection', - url: 'https://example.com/page', - config: { - mappings: { 'example.com': 'custom.example.com' }, - autoDetectFromBaseUrl: true - }, - baseUrl: 'https://staging.example.com', - expected: 'https://custom.example.com/page' - } - ] - - testCases.forEach(({ name, url, config, baseUrl, expected }) => { - it(name, () => { - const result = applyDomainMapping(url, config, baseUrl) - expect(result).toBe(expected) - }) - }) - }) - - describe('shouldIncludeUrl', () => { - it('should include internal URLs', () => { - const config = {} - const result = shouldIncludeUrl( - '/internal-page', - config, - 'https://example.com' - ) - expect(result).toBe(true) - }) - - it('should include URLs from includedDomains', () => { - const config = { - includedDomains: ['api.example.com'] - } - const result = shouldIncludeUrl( - 'https://api.example.com/endpoint', - config, - 'https://example.com' - ) - expect(result).toBe(true) - }) - - it('should include URLs from manual mappings', () => { - const config = { - mappings: { 'production.com': 'staging.production.com' } - } - const result = shouldIncludeUrl( - 'https://production.com/page', - config, - 'https://staging.production.com' - ) - expect(result).toBe(true) - }) - - it('should include URLs from auto-detected mappings', () => { - const config = { - autoDetectFromBaseUrl: true - } - const result = shouldIncludeUrl( - 'https://nevercodealone.de/page', - config, - 'https://testingcrud.testify.projects.nevercodealone.de' - ) - expect(result).toBe(true) - }) - - it('should exclude unrelated external URLs', () => { - const config = {} - const result = shouldIncludeUrl( - 'https://external.com/page', - config, - 'https://example.com' - ) - expect(result).toBe(false) - }) - }) -}) diff --git a/dist/utils/domainMapping.d.ts b/dist/utils/domainMapping.d.ts deleted file mode 100644 index f35d260..0000000 --- a/dist/utils/domainMapping.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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 -} -/** - * Auto-detect domain mappings based on common staging patterns - */ -export declare const autoDetectDomainMapping: (baseUrl: string) => { - [key: string]: string -} -/** - * Apply domain mapping to a URL - */ -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 diff --git a/dist/utils/domainMapping.js b/dist/utils/domainMapping.js deleted file mode 100644 index 69af8c1..0000000 --- a/dist/utils/domainMapping.js +++ /dev/null @@ -1,115 +0,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 - } - } - } - } 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 -/** - * 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 diff --git a/src/utils/domainMapping.ts b/src/utils/domainMapping.ts deleted file mode 100644 index 52de4a7..0000000 --- a/src/utils/domainMapping.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 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 -} - -/** - * Auto-detect domain mappings based on common staging patterns - */ -export const autoDetectDomainMapping = ( - baseUrl: string -): { [key: string]: string } => { - const mapping: { [key: string]: string } = {} - - 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 -} - -/** - * Apply domain mapping to a URL - */ -export const applyDomainMapping = ( - url: string, - config: DomainMappingConfig, - baseUrl: string -): string => { - let mappedUrl = url - - // Get all mappings (manual + auto-detected) - const autoMappings = - config.autoDetectFromBaseUrl !== false - ? 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 -} - -/** - * Check if URL should be included based on domain mapping config - */ -export const shouldIncludeUrl = ( - href: string, - config: DomainMappingConfig, - baseUrl: string -): boolean => { - // Include internal links (same domain as baseUrl) - if (href.startsWith('/') || href.includes(baseUrl)) { - return true - } - - // Include specifically configured domains - if (config.includedDomains?.some((domain) => href.includes(domain))) { - return true - } - - // Include domains from mappings (both manual and auto-detected) - const autoMappings = - config.autoDetectFromBaseUrl !== false - ? autoDetectDomainMapping(baseUrl) - : {} - const allMappings = { ...autoMappings, ...config.mappings } - - return Object.keys(allMappings).some((prodDomain) => - href.includes(prodDomain) - ) -} From a1e0e6ca86b17a81f0195e6392d7a610e51134fb Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:00 +0100 Subject: [PATCH 07/17] Fix type declarations with declare global and align signatures Use declare global { namespace Cypress } so augmentation works in module context. Remove unused DomainMappingConfig interface. Align all command signatures with actual implementations. --- dist/index.d.ts | 69 +++++++++++++++++++++---------------------------- src/index.d.ts | 69 +++++++++++++++++++++---------------------------- 2 files changed, 58 insertions(+), 80 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index ec7fda0..c2dc469 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,45 +1,34 @@ /// -interface DomainMappingConfig { - mappings?: { [prodDomain: string]: string } - autoDetectFromBaseUrl?: boolean - includedDomains?: string[] - minLinksRequired?: number -} - -declare namespace Cypress { - interface Chainable { - ttEl(selector: string, name?: string): Chainable> - ttAccessibility(context?: any, options?: any): Chainable - ttClickIfElementExist(element: string): Chainable - ttCookieAllAcceptClick(): Chainable - ttDetectHttp(): Chainable - ttElementExists(element: string): Chainable - ttEveryInternalLinkIsLoading( - limitOrConfig?: number | DomainMappingConfig, - legacyConfig?: DomainMappingConfig - ): Chainable - ttEveryInternalLinkStatusOk( - config?: DomainMappingConfig - ): Chainable - ttGetInternalLinks( - linkSelectorOrConfig?: string | DomainMappingConfig, - legacyConfig?: DomainMappingConfig - ): Chainable - ttInvalidPath404(): Chainable - ttOnlyOneH1(): Chainable - ttPageLoaded(): Chainable - ttSetupConsoleErrorListener(): Chainable - ttThreshold(threshold?: number): Chainable - ttValidateAllImagesResponseStatusOk(): Chainable - ttValidateImprintClickable(): Chainable - ttValidateLanguageTag(language: string): Chainable - ttValidateNoGoogleServices(): Chainable - ttValidatePageContent(): Chainable - ttValidateSubpagesAndImages( - limit?: number, - linkSelector?: string - ): Chainable +declare global { + namespace Cypress { + interface Chainable { + ttEl(selector: string, name?: string): Chainable> + ttAccessibility(context?: any, options?: any): Chainable + ttClickIfElementExist(element: string): Chainable + ttCookieAllAcceptClick(): Chainable + ttDetectHttp(): Chainable + ttElementExists(element: string): Chainable + ttEveryInternalLinkIsLoading(limit?: number): Chainable + ttEveryInternalLinkStatusOk( + minLinksRequired?: number + ): Chainable + ttGetInternalLinks(linkSelector?: string): Chainable + ttInvalidPath404(): Chainable + ttOnlyOneH1(): Chainable + ttPageLoaded(): Chainable + ttSetupConsoleErrorListener(): Chainable + ttThreshold(threshold?: number): Chainable + ttValidateAllImagesResponseStatusOk(): Chainable + ttValidateImprintClickable(): Chainable + ttValidateLanguageTag(language: string): Chainable + ttValidateNoGoogleServices(): Chainable + ttValidatePageContent(): Chainable + ttValidateSubpagesAndImages( + limit?: number, + linkSelector?: string + ): Chainable + } } } diff --git a/src/index.d.ts b/src/index.d.ts index ec7fda0..c2dc469 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,45 +1,34 @@ /// -interface DomainMappingConfig { - mappings?: { [prodDomain: string]: string } - autoDetectFromBaseUrl?: boolean - includedDomains?: string[] - minLinksRequired?: number -} - -declare namespace Cypress { - interface Chainable { - ttEl(selector: string, name?: string): Chainable> - ttAccessibility(context?: any, options?: any): Chainable - ttClickIfElementExist(element: string): Chainable - ttCookieAllAcceptClick(): Chainable - ttDetectHttp(): Chainable - ttElementExists(element: string): Chainable - ttEveryInternalLinkIsLoading( - limitOrConfig?: number | DomainMappingConfig, - legacyConfig?: DomainMappingConfig - ): Chainable - ttEveryInternalLinkStatusOk( - config?: DomainMappingConfig - ): Chainable - ttGetInternalLinks( - linkSelectorOrConfig?: string | DomainMappingConfig, - legacyConfig?: DomainMappingConfig - ): Chainable - ttInvalidPath404(): Chainable - ttOnlyOneH1(): Chainable - ttPageLoaded(): Chainable - ttSetupConsoleErrorListener(): Chainable - ttThreshold(threshold?: number): Chainable - ttValidateAllImagesResponseStatusOk(): Chainable - ttValidateImprintClickable(): Chainable - ttValidateLanguageTag(language: string): Chainable - ttValidateNoGoogleServices(): Chainable - ttValidatePageContent(): Chainable - ttValidateSubpagesAndImages( - limit?: number, - linkSelector?: string - ): Chainable +declare global { + namespace Cypress { + interface Chainable { + ttEl(selector: string, name?: string): Chainable> + ttAccessibility(context?: any, options?: any): Chainable + ttClickIfElementExist(element: string): Chainable + ttCookieAllAcceptClick(): Chainable + ttDetectHttp(): Chainable + ttElementExists(element: string): Chainable + ttEveryInternalLinkIsLoading(limit?: number): Chainable + ttEveryInternalLinkStatusOk( + minLinksRequired?: number + ): Chainable + ttGetInternalLinks(linkSelector?: string): Chainable + ttInvalidPath404(): Chainable + ttOnlyOneH1(): Chainable + ttPageLoaded(): Chainable + ttSetupConsoleErrorListener(): Chainable + ttThreshold(threshold?: number): Chainable + ttValidateAllImagesResponseStatusOk(): Chainable + ttValidateImprintClickable(): Chainable + ttValidateLanguageTag(language: string): Chainable + ttValidateNoGoogleServices(): Chainable + ttValidatePageContent(): Chainable + ttValidateSubpagesAndImages( + limit?: number, + linkSelector?: string + ): Chainable + } } } From 078df315edae0f304c492260021b855957445bf0 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:04 +0100 Subject: [PATCH 08/17] Add minLinksRequired param to ttEveryInternalLinkStatusOk type --- cypress/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/index.d.ts b/cypress/index.d.ts index 074abe1..caa767d 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -18,7 +18,7 @@ declare namespace Cypress { ttDetectHttp(): Chainable ttElementExists(element: string): Chainable ttEveryInternalLinkIsLoading(limit?: number): Chainable - ttEveryInternalLinkStatusOk(): Chainable + ttEveryInternalLinkStatusOk(minLinksRequired?: number): Chainable ttGetInternalLinks(linkSelector?: string): Chainable ttInvalidPath404(): Chainable ttOnlyOneH1(): Chainable From a8827d6dfe0ac6ad22cc0694f02ac71cd31de081 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:07 +0100 Subject: [PATCH 09/17] Replace @ts-nocheck with proper type reference in commands.ts --- dist/commands.d.ts | 2 +- dist/commands.js | 122 ++++++++++++++++----------------------------- src/commands.ts | 2 +- 3 files changed, 45 insertions(+), 81 deletions(-) diff --git a/dist/commands.d.ts b/dist/commands.d.ts index 336ce12..cb0ff5c 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 e9460c8..94afb9a 100644 --- a/dist/commands.js +++ b/dist/commands.js @@ -1,80 +1,44 @@ -'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/src/commands.ts b/src/commands.ts index 6cc93b2..3fabf8b 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,5 +1,5 @@ /// -// @ts-nocheck - Cypress commands registration bypasses TypeScript checking +/// import { ttAccessibility } from './commands/tt-accessibility' import { ttClickIfElementExist } from './commands/tt-click-if-element-exist' import { ttCookieAllAcceptClick } from './commands/tt-cookie-all-accept' From 7b5bd0d903aa4ef1a055a0fc2ffb5b87f958b5f6 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:11 +0100 Subject: [PATCH 10/17] Remove @ts-ignore directives from ttEveryInternalLinkIsLoading --- .../tt-every-internal-link-is-loading.d.ts | 2 +- .../tt-every-internal-link-is-loading.js | 57 +++++++++---------- .../tt-every-internal-link-is-loading.ts | 4 +- 3 files changed, 29 insertions(+), 34 deletions(-) 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 4e8cf3f..305ab8f 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 3b9c4a6..efbaa6f 100644 --- a/dist/commands/tt-every-internal-link-is-loading.js +++ b/dist/commands/tt-every-internal-link-is-loading.js @@ -1,33 +1,30 @@ -'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'); + 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('body').should('not.be.empty'); + cy.ttValidateAllImagesResponseStatusOk(); + } + cy.clearAllLocalStorage(); + }); + }); +}; +exports.ttEveryInternalLinkIsLoading = ttEveryInternalLinkIsLoading; diff --git a/src/commands/tt-every-internal-link-is-loading.ts b/src/commands/tt-every-internal-link-is-loading.ts index 02edbaa..5feb7fa 100644 --- a/src/commands/tt-every-internal-link-is-loading.ts +++ b/src/commands/tt-every-internal-link-is-loading.ts @@ -4,7 +4,6 @@ export const ttEveryInternalLinkIsLoading = (limit: number = 10): void => { cy.log('everyInternalLinkIsLoading - NCA TESTIFY') - //@ts-ignore - Custom command type not available in build context cy.ttGetInternalLinks().then((internalLinks: string[]) => { const linksToValidate = internalLinks.slice(0, limit) @@ -23,8 +22,7 @@ export const ttEveryInternalLinkIsLoading = (limit: number = 10): void => { }) } else { cy.visit(href) - cy.get('a').should('be.visible') - //@ts-ignore - Custom command type not available in build context + cy.get('body').should('not.be.empty') cy.ttValidateAllImagesResponseStatusOk() } From df965b8414cae84f8347842b180f2856d621d932 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:15 +0100 Subject: [PATCH 11/17] Replace @ts-nocheck with proper type reference in ttValidatePageContent --- dist/commands/tt-validate-page-content.d.ts | 2 +- dist/commands/tt-validate-page-content.js | 29 +++++++++++---------- src/commands/tt-validate-page-content.ts | 4 ++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/dist/commands/tt-validate-page-content.d.ts b/dist/commands/tt-validate-page-content.d.ts index 294aa08..bc0a440 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 0788fc9..42e1897 100644 --- a/dist/commands/tt-validate-page-content.js +++ b/dist/commands/tt-validate-page-content.js @@ -1,15 +1,16 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { value: true }) -exports.ttValidatePageContent = void 0 -// @ts-nocheck - Cypress custom commands are dynamically registered +"use strict"; +/// +/// +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ttValidatePageContent = void 0; 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/src/commands/tt-validate-page-content.ts b/src/commands/tt-validate-page-content.ts index 3c2fc49..20ee379 100644 --- a/src/commands/tt-validate-page-content.ts +++ b/src/commands/tt-validate-page-content.ts @@ -1,4 +1,6 @@ -// @ts-nocheck - Cypress custom commands are dynamically registered +/// +/// + export const ttValidatePageContent = (): void => { cy.ttAccessibility() cy.ttValidateNoGoogleServices() From 1cf9329d386e69462aaa20733301837db6b74a1e Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:18 +0100 Subject: [PATCH 12/17] Handle protocol-relative URLs in ttGetInternalLinks normalizeUrl --- dist/commands/tt-get-internal-links.d.ts | 4 +- dist/commands/tt-get-internal-links.js | 114 ++++++++++++----------- src/commands/tt-get-internal-links.ts | 5 + 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/dist/commands/tt-get-internal-links.d.ts b/dist/commands/tt-get-internal-links.d.ts index 28d4518..b70ad50 100644 --- a/dist/commands/tt-get-internal-links.d.ts +++ b/dist/commands/tt-get-internal-links.d.ts @@ -1,3 +1 @@ -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 2b75db5..2a8626a 100644 --- a/dist/commands/tt-get-internal-links.js +++ b/dist/commands/tt-get-internal-links.js @@ -1,59 +1,61 @@ -'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('//')) { + const protocol = baseUrl.startsWith('https://') ? 'https:' : 'http:'; + return protocol + 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/src/commands/tt-get-internal-links.ts b/src/commands/tt-get-internal-links.ts index 80d61d8..99dce91 100644 --- a/src/commands/tt-get-internal-links.ts +++ b/src/commands/tt-get-internal-links.ts @@ -24,6 +24,11 @@ const normalizeUrl = ( return href } + if (href.startsWith('//')) { + const protocol = baseUrl.startsWith('https://') ? 'https:' : 'http:' + return protocol + href + } + if (href.startsWith('/')) { return new URL(href, baseUrl).toString() } From e4166404666f811855425fadc8a3ded7de7ff7ce Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:23 +0100 Subject: [PATCH 13/17] Use URL API for credential injection instead of string splitting Replace fragile split('@') approach with existing extractAuth/applyAuth functions that properly handle edge cases via the URL constructor. --- dist/utils/extractAuth.d.ts | 24 ++++----- dist/utils/extractAuth.js | 101 ++++++++++++++++-------------------- src/utils/extractAuth.ts | 25 ++------- 3 files changed, 60 insertions(+), 90 deletions(-) diff --git a/dist/utils/extractAuth.d.ts b/dist/utils/extractAuth.d.ts index feb22b7..ff8e94f 100644 --- a/dist/utils/extractAuth.d.ts +++ b/dist/utils/extractAuth.d.ts @@ -4,29 +4,23 @@ * @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 + * Add baseUrl credentials to internal links * @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 a27a82e..57de2f4 100644 --- a/dist/utils/extractAuth.js +++ b/dist/utils/extractAuth.js @@ -1,29 +1,27 @@ -'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 - } + try { + const urlObj = new URL(url); + if (urlObj.username && urlObj.password) { + return { + username: urlObj.username, + password: urlObj.password + }; + } + return null; } - return null - } catch { - return null - } -} -exports.extractAuth = extractAuth + catch { + return null; + } +}; +exports.extractAuth = extractAuth; /** * Apply Basic Auth credentials to a URL * @param url - Target URL @@ -31,46 +29,39 @@ 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 + * Add baseUrl credentials to internal links * @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 */ const addCredentialsToInternalLinks = (links, baseUrl) => { - 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 + if (!baseUrl) { + baseUrl = + typeof Cypress !== 'undefined' ? Cypress.config('baseUrl') : undefined; } - return link - }) -} -exports.addCredentialsToInternalLinks = addCredentialsToInternalLinks + if (!baseUrl) + return links; + const auth = (0, exports.extractAuth)(baseUrl); + if (!auth) + return links; + return links.map((link) => { + if (link.includes('@')) + return link; + return (0, exports.applyAuth)(link, auth); + }); +}; +exports.addCredentialsToInternalLinks = addCredentialsToInternalLinks; diff --git a/src/utils/extractAuth.ts b/src/utils/extractAuth.ts index 6025176..0c4d2cc 100644 --- a/src/utils/extractAuth.ts +++ b/src/utils/extractAuth.ts @@ -43,7 +43,7 @@ export const applyAuth = ( } /** - * Add baseUrl credentials to internal links using simple @ split approach + * Add baseUrl credentials to internal links * @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 @@ -57,28 +57,13 @@ export const addCredentialsToInternalLinks = ( typeof Cypress !== 'undefined' ? Cypress.config('baseUrl') : undefined } - // Return original links if no baseUrl or no credentials - if (!baseUrl || !baseUrl.includes('@')) return links + if (!baseUrl) return links - // Extract credential part (everything before @) - const credentialPart = baseUrl.split('@')[0] // e.g., "https://nca:nca" + const auth = extractAuth(baseUrl) + if (!auth) return links 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 + return applyAuth(link, auth) }) } From 46313f401c378f1443c49450f67c73d09d551efd Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:27 +0100 Subject: [PATCH 14/17] Update tests for ttEveryInternalLinkStatusOk async fix Add cy.then mock and tests verifying the final assertion behavior with both valid and invalid link statuses. --- .../tt-every-internal-link-status-ok.test.ts | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/__test__/tt-every-internal-link-status-ok.test.ts b/__test__/tt-every-internal-link-status-ok.test.ts index ca21588..90df5e3 100644 --- a/__test__/tt-every-internal-link-status-ok.test.ts +++ b/__test__/tt-every-internal-link-status-ok.test.ts @@ -12,9 +12,17 @@ describe('ttEveryInternalLinkStatusOk', () => { its: vi.fn(() => ({ should: vi.fn() })) })), ttGetInternalLinks: vi.fn(() => ({ then: (cb: any) => cb([]) })), - request: vi.fn() + request: vi.fn(), + then: vi.fn((cb: any) => cb()) } global.cy = cy + ;(global as any).expect = (value: any) => ({ + to: { + have: { + length: vi.fn() + } + } + }) }) const setupTest = (urls: string[], responses: Record) => { @@ -90,4 +98,55 @@ describe('ttEveryInternalLinkStatusOk', () => { ttEveryInternalLinkStatusOk(5) }) + + test('calls cy.then for final assertion after all requests', () => { + setupTest(['https://example.com/ok'], { + default: { status: 200, headers: { 'content-type': 'text/html' } } + }) + + ttEveryInternalLinkStatusOk() + + expect(cy.then).toHaveBeenCalled() + }) + + test('final assertion passes when all links are valid', () => { + const assertionSpy = vi.fn() + ;(global as any).expect = (value: any) => ({ + to: { + have: { + length: assertionSpy + } + } + }) + + setupTest(['https://example.com/ok'], { + default: { status: 200, headers: { 'content-type': 'text/html' } } + }) + + ttEveryInternalLinkStatusOk() + + expect(assertionSpy).toHaveBeenCalledWith(0, expect.any(String)) + }) + + test('final assertion receives failed links when status is invalid', () => { + const assertionSpy = vi.fn() + ;(global as any).expect = (value: any) => ({ + to: { + have: { + length: assertionSpy + } + } + }) + + setupTest(['https://example.com/404'], { + default: { status: 404, headers: { 'content-type': 'text/html' } } + }) + + ttEveryInternalLinkStatusOk() + + expect(assertionSpy).toHaveBeenCalledWith( + 0, + expect.stringContaining('https://example.com/404') + ) + }) }) From 166783c3e71aeb98d444cc3413e12bef4748761f Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 14:49:30 +0100 Subject: [PATCH 15/17] Rebuild dist files --- dist/api-version.d.ts | 6 +- dist/api-version.js | 18 +- dist/commands/tt-accessibility.d.ts | 2 +- dist/commands/tt-accessibility.js | 20 +- dist/commands/tt-click-if-element-exist.d.ts | 4 +- dist/commands/tt-click-if-element-exist.js | 31 +- dist/commands/tt-cookie-all-accept.d.ts | 4 +- dist/commands/tt-cookie-all-accept.js | 82 ++-- dist/commands/tt-detect-http.d.ts | 2 +- dist/commands/tt-detect-http.js | 43 +- dist/commands/tt-el.d.ts | 5 +- dist/commands/tt-el.js | 36 +- dist/commands/tt-element-exists.d.ts | 4 +- dist/commands/tt-element-exists.js | 18 +- dist/commands/tt-invalid-path-404.d.ts | 2 +- dist/commands/tt-invalid-path-404.js | 42 +- dist/commands/tt-only-one-h1.d.ts | 2 +- dist/commands/tt-only-one-h1.js | 16 +- dist/commands/tt-page-loaded.d.ts | 2 +- dist/commands/tt-page-loaded.js | 39 +- .../tt-setup-console-error-listener.d.ts | 2 +- .../tt-setup-console-error-listener.js | 68 ++-- dist/commands/tt-threshold.d.ts | 2 +- dist/commands/tt-threshold.js | 135 ++++--- ...alidate-all-images-response-status-ok.d.ts | 2 +- ...-validate-all-images-response-status-ok.js | 370 +++++++++--------- .../tt-validate-imprint-clickable.d.ts | 2 +- .../commands/tt-validate-imprint-clickable.js | 55 ++- dist/commands/tt-validate-language-tag.d.ts | 2 +- dist/commands/tt-validate-language-tag.js | 28 +- .../tt-validate-no-google-services.d.ts | 2 +- .../tt-validate-no-google-services.js | 36 +- .../tt-validate-subpages-and-images.d.ts | 5 +- .../tt-validate-subpages-and-images.js | 44 +-- dist/e2e.d.ts | 4 +- dist/e2e.js | 8 +- dist/index.js | 17 +- dist/pages/BasePage.d.ts | 7 +- dist/pages/BasePage.js | 38 +- 39 files changed, 575 insertions(+), 630 deletions(-) diff --git a/dist/api-version.d.ts b/dist/api-version.d.ts index 65937d9..ffda379 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 72431da..4741520 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/tt-accessibility.d.ts b/dist/commands/tt-accessibility.d.ts index ca9aa3a..6c69423 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 2299db7..af69e50 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 b305874..a1ce976 100644 --- a/dist/commands/tt-click-if-element-exist.d.ts +++ b/dist/commands/tt-click-if-element-exist.d.ts @@ -1,3 +1 @@ -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 61bf7c2..1b07da2 100644 --- a/dist/commands/tt-click-if-element-exist.js +++ b/dist/commands/tt-click-if-element-exist.js @@ -1,17 +1,18 @@ -'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 8406367..3aee45f 100644 --- a/dist/commands/tt-cookie-all-accept.d.ts +++ b/dist/commands/tt-cookie-all-accept.d.ts @@ -1,3 +1 @@ -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 b74971d..8ce0699 100644 --- a/dist/commands/tt-cookie-all-accept.js +++ b/dist/commands/tt-cookie-all-accept.js @@ -1,49 +1,41 @@ -'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 +"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) { - 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' - ) + // 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; + }); } - return null - }) - } - return null - }) -} -exports.ttCookieAllAcceptClick = ttCookieAllAcceptClick + return null; + }); +}; +exports.ttCookieAllAcceptClick = ttCookieAllAcceptClick; diff --git a/dist/commands/tt-detect-http.d.ts b/dist/commands/tt-detect-http.d.ts index c6d23fc..395b746 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 5374569..3b601b5 100644 --- a/dist/commands/tt-detect-http.js +++ b/dist/commands/tt-detect-http.js @@ -1,23 +1,22 @@ -'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 7902201..2f6b439 100644 --- a/dist/commands/tt-el.d.ts +++ b/dist/commands/tt-el.d.ts @@ -1,4 +1 @@ -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 d6e61f8..6bcdfaf 100644 --- a/dist/commands/tt-el.js +++ b/dist/commands/tt-el.js @@ -1,19 +1,21 @@ -'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 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) => { - const logName = name || extractCallerName() || selector - cy.log(logName) - 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 563a8fd..1cb542f 100644 --- a/dist/commands/tt-element-exists.d.ts +++ b/dist/commands/tt-element-exists.d.ts @@ -1,3 +1 @@ -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 2253ace..bf23236 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-invalid-path-404.d.ts b/dist/commands/tt-invalid-path-404.d.ts index 84c6e4e..3601474 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 949c008..1358ddd 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 cff3a23..7644647 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 8293784..cac141c 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 07c54ed..0e549e6 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 9bc7ed4..366b338 100644 --- a/dist/commands/tt-page-loaded.js +++ b/dist/commands/tt-page-loaded.js @@ -1,21 +1,22 @@ -'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 5a53efa..dfc0008 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 01151cb..b233457 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 6958a0f..89a4377 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 4e726f5..f8d601a 100644 --- a/dist/commands/tt-threshold.js +++ b/dist/commands/tt-threshold.js @@ -1,70 +1,67 @@ -'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 b3437cf..0c6ac1b 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 5dace62..95f93d2 100644 --- a/dist/commands/tt-validate-all-images-response-status-ok.js +++ b/dist/commands/tt-validate-all-images-response-status-ok.js @@ -1,202 +1,190 @@ -'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 - } + 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}` + }); } - } - 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}` - }) - } - }) - } - } - }) - return cssImageUrls -} + } + }); + 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}`) - } - }) - 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}`) + 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 (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 + }); + 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 (auth) { - requestOptions.auth = { - username: auth.username, - password: auth.password - } + else { + cy.log('No elements found'); } - 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}` - ) - } - }) - }) + return null; }) -} -exports.ttValidateAllImagesResponseStatusOk = - ttValidateAllImagesResponseStatusOk + .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; diff --git a/dist/commands/tt-validate-imprint-clickable.d.ts b/dist/commands/tt-validate-imprint-clickable.d.ts index ba84965..d0702f0 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 6ae8717..d02244b 100644 --- a/dist/commands/tt-validate-imprint-clickable.js +++ b/dist/commands/tt-validate-imprint-clickable.js @@ -1,32 +1,29 @@ -'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 e6cda39..768ce3c 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 ee8b04b..9d0b2b6 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 e110711..1d3597f 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 d93c6dd..f423da1 100644 --- a/dist/commands/tt-validate-no-google-services.js +++ b/dist/commands/tt-validate-no-google-services.js @@ -1,21 +1,17 @@ -'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-subpages-and-images.d.ts b/dist/commands/tt-validate-subpages-and-images.d.ts index 7b0368c..689c643 100644 --- a/dist/commands/tt-validate-subpages-and-images.d.ts +++ b/dist/commands/tt-validate-subpages-and-images.d.ts @@ -1,4 +1 @@ -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 e638c4e..0d091f2 100644 --- a/dist/commands/tt-validate-subpages-and-images.js +++ b/dist/commands/tt-validate-subpages-and-images.js @@ -1,24 +1,22 @@ -'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 b43e8c4..9951b51 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 0da3e4e..49e92d8 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 13135ef..26ce575 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,11 +1,6 @@ -'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 2370f59..e40d4b4 100644 --- a/dist/pages/BasePage.d.ts +++ b/dist/pages/BasePage.d.ts @@ -1,7 +1,4 @@ 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 e5377ed..913e2e9 100644 --- a/dist/pages/BasePage.js +++ b/dist/pages/BasePage.js @@ -1,25 +1,19 @@ -'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; From 1d5270cfdd1c26e7c74ae638217b66f32388bb35 Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 15:05:43 +0100 Subject: [PATCH 16/17] Add page URL context to image validation errors When validating images on subpages, broken image errors now show which page the image was found on, making it much easier to debug 404s during multi-page crawls. The error message format is now structured as: Image validation failed on page: Image URL: Status: Source: Co-Authored-By: Claude Opus 4.6 --- cypress/index.d.ts | 7 +- .../tt-every-internal-link-is-loading.js | 2 +- ...alidate-all-images-response-status-ok.d.ts | 2 +- ...-validate-all-images-response-status-ok.js | 177 +++++++-------- .../tt-validate-subpages-and-images.js | 2 +- dist/index.d.ts | 2 +- .../tt-every-internal-link-is-loading.ts | 2 +- ...-validate-all-images-response-status-ok.ts | 201 ++++++++++-------- .../tt-validate-subpages-and-images.ts | 2 +- src/index.d.ts | 2 +- 10 files changed, 211 insertions(+), 188 deletions(-) diff --git a/cypress/index.d.ts b/cypress/index.d.ts index caa767d..8a9ef5d 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -25,7 +25,12 @@ declare namespace Cypress { ttPageLoaded(): Chainable ttSetupConsoleErrorListener(): Chainable ttThreshold(threshold?: number): Chainable - ttValidateAllImagesResponseStatusOk(): Chainable + /** + * Validate that all images on the page return HTTP 200. + * Checks both elements (src and srcset) and CSS background images. + * @param pageUrl - Optional page URL for error context. Falls back to cy.url() if not provided. + */ + ttValidateAllImagesResponseStatusOk(pageUrl?: string): Chainable ttValidateImprintClickable(): Chainable ttValidateLanguageTag(language: string): Chainable ttValidateNoGoogleServices(): Chainable diff --git a/dist/commands/tt-every-internal-link-is-loading.js b/dist/commands/tt-every-internal-link-is-loading.js index efbaa6f..2bcebe8 100644 --- a/dist/commands/tt-every-internal-link-is-loading.js +++ b/dist/commands/tt-every-internal-link-is-loading.js @@ -21,7 +21,7 @@ const ttEveryInternalLinkIsLoading = (limit = 10) => { else { cy.visit(href); cy.get('body').should('not.be.empty'); - cy.ttValidateAllImagesResponseStatusOk(); + cy.ttValidateAllImagesResponseStatusOk(href); } cy.clearAllLocalStorage(); }); 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..9b50599 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: (pageUrl?: string) => 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..368b5be 100644 --- a/dist/commands/tt-validate-all-images-response-status-ok.js +++ b/dist/commands/tt-validate-all-images-response-status-ok.js @@ -21,7 +21,7 @@ const buildImageSourceInfo = (img, index, type, pageUrl) => { const suffix = type === 'srcset' ? ' srcset' : ''; return `IMG${id}${classes}${suffix} (alt: "${alt}", element ${index + 1}${parentInfo} on page ${pageUrl})`; }; -const extractCssImageUrls = () => { +const extractCssImageUrls = (pageUrl) => { const cssImageUrls = []; const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:']; const isExcludedUrl = (url) => { @@ -83,7 +83,7 @@ const extractCssImageUrls = () => { } cssImageUrls.push({ url, - source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList}` + source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList} on page ${pageUrl}` }); } }); @@ -92,97 +92,100 @@ const extractCssImageUrls = () => { }); return cssImageUrls; }; -const ttValidateAllImagesResponseStatusOk = () => { +const ttValidateAllImagesResponseStatusOk = (pageUrl) => { 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}`); + cy.url().then((currentUrl) => { + const resolvedPageUrl = pageUrl !== null && pageUrl !== void 0 ? pageUrl : currentUrl; + cy.log(`Validating images on page: ${resolvedPageUrl}`); + cy.log('Collecting images from DOM and CSS...'); + // First, collect CSS background images + cy.window().then((win) => { + const cssImages = win.eval(`(${extractCssImageUrls.toString()})(${JSON.stringify(resolvedPageUrl)})`); + 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`); } }); - 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}`); + // 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`); + 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', resolvedPageUrl); + imageMap.set(normalizedSrc, imgSource); + cy.log(`📍 ${imgSource}: ${src}`); } - }); - } - 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 - }; - if (auth) { - requestOptions.auth = { - username: auth.username, - password: auth.password - }; + } + 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', resolvedPageUrl); + 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`); + } + }); } - 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}`); + 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 + }; + 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 on page: ${resolvedPageUrl}\n Image URL: ${url}\n Status: ${response.status}\n Source: ${source}`); + } + }); }); }); }); diff --git a/dist/commands/tt-validate-subpages-and-images.js b/dist/commands/tt-validate-subpages-and-images.js index 0d091f2..6a9956a 100644 --- a/dist/commands/tt-validate-subpages-and-images.js +++ b/dist/commands/tt-validate-subpages-and-images.js @@ -9,7 +9,7 @@ const ttValidateSubpagesAndImages = (limit = 20, linkSelector) => { urls.slice(0, limit).forEach((url) => { if (!url.includes('.pdf')) { cy.visit(url); - (0, tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk)(); + (0, tt_validate_all_images_response_status_ok_1.ttValidateAllImagesResponseStatusOk)(url); } else { cy.log('PDF detected' + url); diff --git a/dist/index.d.ts b/dist/index.d.ts index c2dc469..230056b 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -19,7 +19,7 @@ declare global { ttPageLoaded(): Chainable ttSetupConsoleErrorListener(): Chainable ttThreshold(threshold?: number): Chainable - ttValidateAllImagesResponseStatusOk(): Chainable + ttValidateAllImagesResponseStatusOk(pageUrl?: string): Chainable ttValidateImprintClickable(): Chainable ttValidateLanguageTag(language: string): Chainable ttValidateNoGoogleServices(): Chainable diff --git a/src/commands/tt-every-internal-link-is-loading.ts b/src/commands/tt-every-internal-link-is-loading.ts index 5feb7fa..941e032 100644 --- a/src/commands/tt-every-internal-link-is-loading.ts +++ b/src/commands/tt-every-internal-link-is-loading.ts @@ -23,7 +23,7 @@ export const ttEveryInternalLinkIsLoading = (limit: number = 10): void => { } else { cy.visit(href) cy.get('body').should('not.be.empty') - cy.ttValidateAllImagesResponseStatusOk() + cy.ttValidateAllImagesResponseStatusOk(href) } cy.clearAllLocalStorage() diff --git a/src/commands/tt-validate-all-images-response-status-ok.ts b/src/commands/tt-validate-all-images-response-status-ok.ts index e16015a..81ca06a 100644 --- a/src/commands/tt-validate-all-images-response-status-ok.ts +++ b/src/commands/tt-validate-all-images-response-status-ok.ts @@ -27,7 +27,9 @@ const buildImageSourceInfo = ( return `IMG${id}${classes}${suffix} (alt: "${alt}", element ${index + 1}${parentInfo} on page ${pageUrl})` } -const extractCssImageUrls = (): Array<{ url: string; source: string }> => { +const extractCssImageUrls = ( + pageUrl: string +): Array<{ url: string; source: string }> => { const cssImageUrls: Array<{ url: string; source: string }> = [] const excludedUrlPrefixes = ['data:', 'blob:', 'javascript:', 'about:'] const isExcludedUrl = (url: string): boolean => { @@ -99,7 +101,7 @@ const extractCssImageUrls = (): Array<{ url: string; source: string }> => { cssImageUrls.push({ url, - source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList}` + source: `CSS background on ${elementInfo}${cssRuleInfo}${cssFilesList} on page ${pageUrl}` }) } }) @@ -110,116 +112,129 @@ const extractCssImageUrls = (): Array<{ url: string; source: string }> => { return cssImageUrls } -export const ttValidateAllImagesResponseStatusOk = (): void => { +export const ttValidateAllImagesResponseStatusOk = ( + pageUrl?: string +): void => { const imageMap = new Map() // URL -> source description - cy.log('Collecting images from DOM and CSS...') + cy.url().then((currentUrl) => { + const resolvedPageUrl = pageUrl ?? currentUrl + + cy.log(`Validating images on page: ${resolvedPageUrl}`) + cy.log('Collecting images from DOM and CSS...') + + // First, collect CSS background images + cy.window().then((win) => { + const cssImages = win.eval( + `(${extractCssImageUrls.toString()})(${JSON.stringify(resolvedPageUrl)})` + ) + cssImages.forEach((item: { url: string; source: string }) => { + const normalizedUrl = normalizeUrl(item.url) + if (!isExcludedUrl(normalizedUrl)) { + imageMap.set(normalizedUrl, item.source) + cy.log(`📍 ${item.source}: ${item.url}`) + } + }) - // First, collect CSS background images - cy.window().then((win) => { - const cssImages = win.eval(`(${extractCssImageUrls.toString()})()`) - cssImages.forEach((item: { url: string; source: string }) => { - 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`) } }) - 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) => { - const img = $img[0] as HTMLImageElement - 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( + // 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`) + cy.get('img').each(($img, index) => { + const img = $img[0] as HTMLImageElement + 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, - 'srcset', - pageUrl + 'src', + resolvedPageUrl ) - imageMap.set(url, srcsetSource) - cy.log(`📍 ${srcsetSource}: ${url}`) + imageMap.set(normalizedSrc, imgSource) + cy.log(`📍 ${imgSource}: ${src}`) } - }) - } + } - if (src === null && srcset === null) { - const alt = img.getAttribute('alt') ?? '' - 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 (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', + resolvedPageUrl + ) + imageMap.set(url, srcsetSource) + cy.log(`📍 ${srcsetSource}: ${url}`) + } + }) + } - if (totalImages === 0) { - cy.log('✅ No images found to validate') - return - } + if (src === null && srcset === null) { + const alt = img.getAttribute('alt') ?? '' + 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 - cy.log(`🔍 Validating ${totalImages} total images (IMG + CSS)`) + if (totalImages === 0) { + cy.log('✅ No images found to validate') + return + } - const baseUrl = Cypress.config('baseUrl') - const auth = extractAuth(baseUrl) + cy.log(`🔍 Validating ${totalImages} total images (IMG + CSS)`) - Array.from(imageMap.entries()).forEach(([url, source]) => { - const requestOptions: Partial = { - method: 'HEAD', - url: url, - failOnStatusCode: false - } + const baseUrl = Cypress.config('baseUrl') + const auth = extractAuth(baseUrl) - if (auth) { - requestOptions.auth = { - username: auth.username, - password: auth.password + Array.from(imageMap.entries()).forEach(([url, source]) => { + const requestOptions: Partial = { + method: 'HEAD', + url: url, + failOnStatusCode: false } - } - 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}` - ) + 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 on page: ${resolvedPageUrl}\n Image URL: ${url}\n Status: ${response.status}\n Source: ${source}` + ) + } + }) }) }) - }) + }) } diff --git a/src/commands/tt-validate-subpages-and-images.ts b/src/commands/tt-validate-subpages-and-images.ts index a7dc0bc..3073a9b 100644 --- a/src/commands/tt-validate-subpages-and-images.ts +++ b/src/commands/tt-validate-subpages-and-images.ts @@ -10,7 +10,7 @@ export const ttValidateSubpagesAndImages = ( urls.slice(0, limit).forEach((url) => { if (!url.includes('.pdf')) { cy.visit(url) - ttValidateAllImagesResponseStatusOk() + ttValidateAllImagesResponseStatusOk(url) } else { cy.log('PDF detected' + url) } diff --git a/src/index.d.ts b/src/index.d.ts index c2dc469..230056b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -19,7 +19,7 @@ declare global { ttPageLoaded(): Chainable ttSetupConsoleErrorListener(): Chainable ttThreshold(threshold?: number): Chainable - ttValidateAllImagesResponseStatusOk(): Chainable + ttValidateAllImagesResponseStatusOk(pageUrl?: string): Chainable ttValidateImprintClickable(): Chainable ttValidateLanguageTag(language: string): Chainable ttValidateNoGoogleServices(): Chainable From 8b304cd1f330bd5ef8e0480816a2b54f41adcdbd Mon Sep 17 00:00:00 2001 From: Roland Golla Date: Fri, 13 Feb 2026 15:11:12 +0100 Subject: [PATCH 17/17] Bump version to 2.1.74 Co-Authored-By: Claude Opus 4.6 --- package.json | 2 +- update.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index be2c2ab..203ec28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cypress-ncatestify-plugin", - "version": "2.1.73", + "version": "2.1.74", "description": "NCA TESTIFY commands and tests", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/update.md b/update.md index f9e8cb8..d0f79b9 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,18 @@ # Update md file +2.1.74 + +- Add page URL context to image validation error messages +- Fix async boolean bug in ttEveryInternalLinkStatusOk +- Fix type declarations with `declare global` and align signatures across index.d.ts files +- Add `minLinksRequired` param to ttEveryInternalLinkStatusOk type definition +- Remove `@ts-nocheck`/`@ts-ignore` directives from commands.ts, ttEveryInternalLinkIsLoading, ttValidatePageContent +- Remove dead NCA special-case logic from isInternal +- Remove unused domainMapping module and its tests +- Use URL API for credential injection instead of string splitting +- Handle protocol-relative URLs in ttGetInternalLinks normalizeUrl +- Rebuild dist files + 2.1.73 - Add ttEl type definition with JSDoc to cypress/index.d.ts