Skip to content

Commit

Permalink
Merge pull request #74 from rogoit/main
Browse files Browse the repository at this point in the history
Fix typescript errors with copilot.
  • Loading branch information
rogoit authored Oct 7, 2023
2 parents cc697a7 + beb5924 commit 0fbe3dc
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "all",
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
13 changes: 10 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
4 changes: 2 additions & 2 deletions src/commands/tt-element-exists.js
Original file line number Diff line number Diff line change
@@ -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;
});
};
8 changes: 5 additions & 3 deletions src/commands/tt-element-exists.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const ttElementExists = (selector: string): boolean => {
export const ttElementExists = (
selector: string
): Cypress.Chainable<boolean> => {
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
})
}
25 changes: 15 additions & 10 deletions src/commands/tt-validate-imprint-clickable.js
Original file line number Diff line number Diff line change
@@ -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');
});
};
30 changes: 17 additions & 13 deletions src/commands/tt-validate-imprint-clickable.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> => {
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')
})
}
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Subject>
Expand Down
12 changes: 10 additions & 2 deletions update.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 0fbe3dc

Please sign in to comment.