From feb08d520830527aa495866a7b0b1eceb47716ee Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 7 Oct 2023 21:48:53 +0200 Subject: [PATCH 1/5] Remove trailling commas in prettierrc. --- .prettierrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc.json b/.prettierrc.json index d50a919..c50384f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "trailingComma": "all", + "trailingComma": "none", "tabWidth": 2, "semi": false, "singleQuote": true From d8a1bfb349563a6da07dffc63826e5bcbf52c2a2 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 7 Oct 2023 22:24:46 +0200 Subject: [PATCH 2/5] Go to version 38. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 008e75c..72d9e5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cypress-ncatestify-plugin", - "version": "2.0.37", + "version": "2.0.38", "description": "NCA TESTIFY commands and tests", "main": "src", "types": "src", From 5c516a12f87ea4ba4244535e66abc23c63f281d2 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 7 Oct 2023 22:25:33 +0200 Subject: [PATCH 3/5] Fix typescript commands and improve code. --- src/commands.js | 9 +++++- src/commands.ts | 13 ++++++-- src/commands/tt-element-exists.js | 4 +-- src/commands/tt-element-exists.ts | 8 +++-- src/commands/tt-validate-imprint-clickable.js | 25 +++++++++------- src/commands/tt-validate-imprint-clickable.ts | 30 +++++++++++-------- 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/commands.js b/src/commands.js index 26f66d9..7a95a2e 100644 --- a/src/commands.js +++ b/src/commands.js @@ -41,10 +41,11 @@ import { ttCookieAllAcceptClick } from './commands/tt-cookie-all-accept'; Cypress.Commands.add('ttEveryInternalLinkStatusOk', ttEveryInternalLinkStatusOk); Cypress.Commands.add('ttValidateAllImagesResponseStatusOk', ttValidateAllImagesResponseStatusOk); Cypress.Commands.add('ttEveryInternalLinkIsLoading', ttEveryInternalLinkIsLoading); +// @ts-ignore +Cypress.Commands.add('ttElementExists', ttElementExists); Cypress.Commands.add('ttGetInternalLinks', ttGetInternalLinks); Cypress.Commands.add('ttValidateImprintClickable', ttValidateImprintClickable); Cypress.Commands.add('ttValidateNoGoogleServices', ttValidateNoGoogleServices); -Cypress.Commands.add('ttElementExists', ttElementExists); Cypress.Commands.add('ttRunTestifyBaseTests', ttRunTestifyBaseTests); Cypress.Commands.add('ttAccessibility', ttAccessibility); Cypress.Commands.add('ttValidatePageContent', ttValidatePageContent); @@ -53,3 +54,9 @@ Cypress.Commands.add('ttInvalidPath404', ttInvalidPath404); Cypress.Commands.add('ttValidateLanguageTag', ttValidateLanguageTag); Cypress.Commands.add('ttDetectHttp', ttDetectHttp); Cypress.Commands.add('ttCookieAllAcceptClick', ttCookieAllAcceptClick); +Cypress.Commands.add('ttValidatePageContent', ttValidatePageContent); +Cypress.Commands.add('ttOnlyOneH1', ttOnlyOneH1); +Cypress.Commands.add('ttInvalidPath404', ttInvalidPath404); +Cypress.Commands.add('ttValidateLanguageTag', ttValidateLanguageTag); +Cypress.Commands.add('ttDetectHttp', ttDetectHttp); +Cypress.Commands.add('ttCookieAllAcceptClick', ttCookieAllAcceptClick); diff --git a/src/commands.ts b/src/commands.ts index fce70fd..55bbaa0 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -43,16 +43,17 @@ import { ttCookieAllAcceptClick } from './commands/tt-cookie-all-accept' Cypress.Commands.add('ttEveryInternalLinkStatusOk', ttEveryInternalLinkStatusOk) Cypress.Commands.add( 'ttValidateAllImagesResponseStatusOk', - ttValidateAllImagesResponseStatusOk, + ttValidateAllImagesResponseStatusOk ) Cypress.Commands.add( 'ttEveryInternalLinkIsLoading', - ttEveryInternalLinkIsLoading, + ttEveryInternalLinkIsLoading ) +// @ts-ignore +Cypress.Commands.add('ttElementExists', ttElementExists) Cypress.Commands.add('ttGetInternalLinks', ttGetInternalLinks) Cypress.Commands.add('ttValidateImprintClickable', ttValidateImprintClickable) Cypress.Commands.add('ttValidateNoGoogleServices', ttValidateNoGoogleServices) -Cypress.Commands.add('ttElementExists', ttElementExists) Cypress.Commands.add('ttRunTestifyBaseTests', ttRunTestifyBaseTests) Cypress.Commands.add('ttAccessibility', ttAccessibility) Cypress.Commands.add('ttValidatePageContent', ttValidatePageContent) @@ -61,3 +62,9 @@ Cypress.Commands.add('ttInvalidPath404', ttInvalidPath404) Cypress.Commands.add('ttValidateLanguageTag', ttValidateLanguageTag) Cypress.Commands.add('ttDetectHttp', ttDetectHttp) Cypress.Commands.add('ttCookieAllAcceptClick', ttCookieAllAcceptClick) +Cypress.Commands.add('ttValidatePageContent', ttValidatePageContent) +Cypress.Commands.add('ttOnlyOneH1', ttOnlyOneH1) +Cypress.Commands.add('ttInvalidPath404', ttInvalidPath404) +Cypress.Commands.add('ttValidateLanguageTag', ttValidateLanguageTag) +Cypress.Commands.add('ttDetectHttp', ttDetectHttp) +Cypress.Commands.add('ttCookieAllAcceptClick', ttCookieAllAcceptClick) diff --git a/src/commands/tt-element-exists.js b/src/commands/tt-element-exists.js index a9ef28c..da2ec79 100644 --- a/src/commands/tt-element-exists.js +++ b/src/commands/tt-element-exists.js @@ -1,6 +1,6 @@ export const ttElementExists = (selector) => { cy.log('ttElementExists - NCA TESTIFY'); - cy.window().then(($window) => { - return $window.document.querySelector(selector); + return cy.window().then(($window) => { + return $window.document.querySelector(selector) !== null; }); }; diff --git a/src/commands/tt-element-exists.ts b/src/commands/tt-element-exists.ts index 528fa86..75bb1b0 100644 --- a/src/commands/tt-element-exists.ts +++ b/src/commands/tt-element-exists.ts @@ -1,6 +1,8 @@ -export const ttElementExists = (selector: string): boolean => { +export const ttElementExists = ( + selector: string +): Cypress.Chainable => { cy.log('ttElementExists - NCA TESTIFY') - cy.window().then(($window) => { - return $window.document.querySelector(selector) + return cy.window().then(($window) => { + return $window.document.querySelector(selector) !== null }) } diff --git a/src/commands/tt-validate-imprint-clickable.js b/src/commands/tt-validate-imprint-clickable.js index e257401..b7cecfa 100644 --- a/src/commands/tt-validate-imprint-clickable.js +++ b/src/commands/tt-validate-imprint-clickable.js @@ -1,14 +1,19 @@ +/** + * Validates that the 'impressum' link is clickable and redirects to the correct page. + * @returns A Cypress Chainable that resolves to a boolean indicating whether the link is clickable and redirects to the correct page. + */ export const ttValidateImprintClickable = () => { cy.log('validateImprintClickable - NCA TESTIFY'); - cy.ttElementExists('.sg-cookie-optin-box-footer-links').then((htmlElement) => { - if (htmlElement) { - cy.contains('.sg-cookie-optin-box-footer-links a', 'impressum', { - matchCase: false, - }).click(); - } - else { - cy.wait(5000); - cy.contains('a:visible', 'impressum', { matchCase: false }).click(); - } + if (cy.ttElementExists('.sg-cookie-optin-box-footer-links')) { + cy.contains('.sg-cookie-optin-box-footer-links a', 'impressum', { + matchCase: false + }).click(); + } + else { + cy.wait(5000); + cy.contains('a:visible', 'impressum', { matchCase: false }).click(); + } + return cy.window().then((win) => { + return win.location.href.includes('/impressum'); }); }; diff --git a/src/commands/tt-validate-imprint-clickable.ts b/src/commands/tt-validate-imprint-clickable.ts index 30947fe..e43def6 100644 --- a/src/commands/tt-validate-imprint-clickable.ts +++ b/src/commands/tt-validate-imprint-clickable.ts @@ -1,16 +1,20 @@ -export const ttValidateImprintClickable = () => { +/** + * Validates that the 'impressum' link is clickable and redirects to the correct page. + * @returns A Cypress Chainable that resolves to a boolean indicating whether the link is clickable and redirects to the correct page. + */ +export const ttValidateImprintClickable = (): Cypress.Chainable => { cy.log('validateImprintClickable - NCA TESTIFY') - cy.ttElementExists('.sg-cookie-optin-box-footer-links').then( - (htmlElement) => { - if (htmlElement) { - cy.contains('.sg-cookie-optin-box-footer-links a', 'impressum', { - matchCase: false, - }).click() - } else { - cy.wait(5000) - cy.contains('a:visible', 'impressum', { matchCase: false }).click() - } - }, - ) + if (cy.ttElementExists('.sg-cookie-optin-box-footer-links')) { + cy.contains('.sg-cookie-optin-box-footer-links a', 'impressum', { + matchCase: false + }).click() + } else { + cy.wait(5000) + cy.contains('a:visible', 'impressum', { matchCase: false }).click() + } + + return cy.window().then((win) => { + return win.location.href.includes('/impressum') + }) } From 6c660b14839679d48819c399e4099944a9e37fa7 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 7 Oct 2023 22:30:16 +0200 Subject: [PATCH 4/5] Add boolean definition for element exits method in index d file. --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 6375146..4fed82b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -5,7 +5,7 @@ declare namespace Cypress { ttEveryInternalLinkStatusOk(): void ttEveryInternalLinkIsLoading(): void ttValidateNoGoogleServices(): void - ttElementExists(element: string): void + ttElementExists(element: string): boolean ttRunTestifyBaseTests(): void ttValidateAllImagesResponseStatusOk(): void ttAccessibility(context?: any, options?: any): Chainable From 6e627d6d6e64aeb9ea6fb3a1b0172867066dfe71 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 7 Oct 2023 22:30:56 +0200 Subject: [PATCH 5/5] Add new information to update.md. --- update.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/update.md b/update.md index 4816e17..5db4c2a 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,13 @@ # Update md file +2.0.38 +Fix typescript errors + +- ttElementExist boolean and null operator. +- ttValidateImprint use new method signature and improve. + 2.0.37 -Add cy.clearAllLocalStorage() to everyInternalLinkIsLoading for better memory handling. -Update npm dependencies. +Do something for the planet + +- Add cy.clearAllLocalStorage() to everyInternalLinkIsLoading for better memory handling. +- Update npm dependencies.