Skip to content
Merged

V73 #143

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions __test__/domainMapping.test.ts

This file was deleted.

61 changes: 60 additions & 1 deletion __test__/tt-every-internal-link-status-ok.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>) => {
Expand Down Expand Up @@ -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')
)
})
})
21 changes: 19 additions & 2 deletions cypress/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
/// <reference types="cypress" />
/// <reference types="cypress-axe" />

declare namespace Cypress {
interface Chainable<Subject = any> {
/**
* 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<JQuery<HTMLElement>>

ttAccessibility(context?: any, options?: any): Chainable<Subject>
ttClickIfElementExist(element: string): Chainable<Subject>
ttCookieAllAcceptClick(): Chainable<Subject>
ttDetectHttp(): Chainable<Subject>
ttElementExists(element: string): Chainable<boolean>
ttEveryInternalLinkIsLoading(limit?: number): Chainable<Subject>
ttEveryInternalLinkStatusOk(): Chainable<Subject>
ttEveryInternalLinkStatusOk(minLinksRequired?: number): Chainable<Subject>
ttGetInternalLinks(linkSelector?: string): Chainable<string[]>
ttInvalidPath404(): Chainable<Subject>
ttOnlyOneH1(): Chainable<Subject>
ttPageLoaded(): Chainable<Subject>
ttSetupConsoleErrorListener(): Chainable<Subject>
ttThreshold(threshold?: number): Chainable<Subject>
ttValidateAllImagesResponseStatusOk(): Chainable<Subject>
/**
* Validate that all images on the page return HTTP 200.
* Checks both <img> 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<Subject>
ttValidateImprintClickable(): Chainable<Subject>
ttValidateLanguageTag(language: string): Chainable<Subject>
ttValidateNoGoogleServices(): Chainable<Subject>
Expand Down
6 changes: 3 additions & 3 deletions dist/api-version.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export declare enum APIVersion {
'latest' = 'latest',
'default' = 'default',
'v14' = 'v14'
'latest' = "latest",
'default' = "default",
'v14' = "v14"
}
18 changes: 9 additions & 9 deletions dist/api-version.js
Original file line number Diff line number Diff line change
@@ -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 = {}));
2 changes: 1 addition & 1 deletion dist/commands.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {}
export {};
Loading
Loading