Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitemap checker added #97

Merged
merged 2 commits into from
Jun 28, 2023
Merged
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
29 changes: 29 additions & 0 deletions src/commands/check-sitemap-exists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable tsdoc/syntax */
/**
* Check Sitemap Exists.
*
* @example
* Use the command without any argument, sitemap.xml will be used:
* ```
* cy.checkSitemap()
* ```
*
* @example
* Use the command with custom sitemap path:
* ```
* cy.checkSitemap( '/alternative-sitemap.xml')
* ```
*/

export const checkSitemap = (sitemap_url = '/sitemap.xml'): void => {
cy.request(sitemap_url).then(response => {
if (response.status === 200) {
cy.log('Sitemap exists');
} else {
cy.log('Sitemap does not exist');
// Send an alert to the team
// You can use a messaging service like Slack or email to send an alert
cy.task('sendAlert', 'Sitemap has disappeared');
}
});
};
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { logout } from './commands/logout';
import { login } from './commands/login';
import { createPost } from './commands/create-post';
import { uploadMedia } from './commands/upload-media';
import { checkSitemap } from './commands/check-sitemap-exists';

declare global {
namespace Cypress {
Expand All @@ -46,6 +47,7 @@ declare global {
uploadMedia: typeof uploadMedia;
logout: typeof logout;
login: typeof login;
checkSitemap: typeof checkSitemap;
}
}
}
Expand Down Expand Up @@ -74,3 +76,4 @@ Cypress.Commands.add('createPost', createPost);
Cypress.Commands.add('uploadMedia', uploadMedia);
Cypress.Commands.add('logout', logout);
Cypress.Commands.add('login', login);
Cypress.Commands.add('checkSitemap', checkSitemap);
5 changes: 5 additions & 0 deletions tests/cypress/e2e/check-sitemap-exists.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Command: checkSitemap', () => {
it('Test sitemap existence', () => {
cy.checkSitemap();
});
});