Created
March 16, 2021 20:28
-
-
Save NickStees/0eb72f7ef996e05bc45cbe20f06c7a01 to your computer and use it in GitHub Desktop.
drupalmdoulespart1.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="Cypress" /> | |
Cypress.on("uncaught:exception", (err, runnable) => { | |
// returning false here prevents Cypress from | |
// failing the test | |
return false; | |
}); | |
// https://www.drupal.org/project/routes_list to find routes to test | |
var urls | |
function checkIfShouldIgnore(msg) { | |
// This function will check to see if the error message is a known one and should be ignored or not | |
if ( | |
msg.includes( | |
"There are security updates available for one or more of your modules or themes" | |
) | |
) { | |
// developers will be aware of outdated modules via other means | |
return true; | |
} | |
if ( | |
msg.includes( | |
"One or more problems were detected with your Drupal installation. Check the status report for more information." | |
) | |
) { | |
// This just means to check the status page | |
// was on admin/config | |
return true; | |
} | |
if ( | |
msg.includes( | |
"There may be a problem with your Memcache configuration. Please review README.txt and visit the Drupal admin page for more information" | |
) | |
) { | |
// This work on the acquia servers only https://www.tampa.gov/admin/reports/memcache | |
return true; | |
} | |
return false; | |
} | |
describe("Drupal Module Pages load", () => { | |
beforeEach(() => {}); | |
before(() => { | |
urls = [ | |
"/admin", | |
"/admin/config", | |
"/admin/config/content", | |
"/admin/config/development", | |
"/admin/config/media", | |
"/admin/config/regional", | |
"/admin/config/search", | |
"/admin/config/services", | |
"/admin/config/system", | |
"/admin/config/user-interface", | |
"/admin/config/workflow", | |
"/admin/content", | |
"/admin/index", | |
"/admin/reports", | |
"/admin/structure", | |
"/admin/config/system/cron", | |
"/admin/config/media/file-system", | |
"/admin/config/media/image-toolkit", | |
"/admin/config/development/logging", | |
"/admin/modules", | |
"/admin/modules/uninstall", | |
"/admin/config/development/performance", | |
"/admin/reports/status/php", | |
"/admin/config/regional/settings", | |
"/admin/config/services/rss-publishing", | |
"/admin/config/system/site-information", | |
"/admin/config/development/maintenance", | |
"/admin/reports/status", | |
"/admin/appearance", | |
"/admin/appearance/settings", | |
// Access Unpublished | |
"/admin/content/access_token", | |
"/admin/config/content/access_unpublished", | |
// Acquia Connector | |
"/admin/config/system/acquia-connector/credentials", | |
"/admin/config/system/acquia-connector/environment-change", | |
"/admin/config/system/acquia-connector", | |
"/admin/config/system/acquia-connector/setup", | |
"/admin/config/system/acquia-connector/start", | |
// Admin Audit Trail | |
"/admin/reports/audit-trail", | |
"/admin/config/development/audit-trail/settings", | |
// Admin Toolbar Extra Tools | |
// '/admin/flush/cssjs', | |
// '/admin/flush', | |
// '/admin/flush/menu', | |
// '/admin/flush/rendercache', | |
// '/admin/flush/static-caches', | |
// '/admin/flush/twig', | |
// '/admin/flush/views', | |
// '/admin/flush/plugin', | |
// '/admin/flush/theme_rebuild', | |
// API Proxy | |
"/admin/config/services/api-proxy", | |
"/admin/config/services/api-proxy/settings", | |
// Audit Files | |
"/admin/config/system/auditfiles_config", | |
// '/admin/reports/auditfiles/managednotused', | |
// '/admin/reports/auditfiles/mergefilereferences', | |
// '/admin/reports/auditfiles/notonserver', | |
// '/admin/reports/auditfiles/referencednotused', | |
// '/admin/reports/auditfiles/usednotmanaged', | |
// '/admin/reports/auditfiles/usednotreferenced', | |
// '/admin/reports/auditfiles/notindatabase', | |
"/admin/reports/auditfiles", | |
// Blazy | |
"/admin/config/media/blazy", | |
// Block | |
"/admin/structure/block", | |
// Custom Block | |
"/block/add", | |
"/admin/structure/block/block-content/types/add", | |
// Browser update | |
"/admin/config/system/browser-update", | |
// Charts | |
"/admin/config/content/charts", | |
// Highcharts | |
"/admin/config/content/charts/highcharts", | |
// Chosen | |
"/admin/config/user-interface/chosen", | |
// ClamAV Anti-Virus | |
"/admin/config/media/clamav", | |
// CloudFlare | |
"/admin/config/services/cloudflare", | |
// Colorbox | |
"/admin/config/media/colorbox", | |
// Conditional Fields | |
"/admin/structure/conditional_fields", | |
"/admin/config/people/accounts/conditionals", | |
// Configuration Manager | |
"/admin/config/development/configuration/full/export", | |
"/admin/config/development/configuration/full/import", | |
"/admin/config/development/configuration/single/import", | |
"/admin/config/development/configuration", | |
// Content Moderation | |
"/admin/content/moderated", | |
// cot-adminjs | |
"/admin/config/system/cot-adminjs", | |
// COT Custom Spellcheck | |
"/admin/config/system/cot-spellcheck", | |
// Crop API | |
"/admin/config/media/crop", | |
"/admin/config/media/crop/add", | |
// Database Logging | |
"/admin/reports/access-denied", | |
"/admin/reports/dblog/confirm", | |
"/admin/reports/dblog", | |
"/admin/reports/page-not-found", | |
// DB Log Filter | |
"/admin/reports/dblog-filter", | |
// Diff | |
"/admin/config/content/diff/fields", | |
"/admin/config/content/diff/general", | |
// Easy Breadcrumb | |
"/admin/config/user-interface/easy-breadcrumb", | |
// Encrypt | |
"/admin/config/system/encryption/profiles/settings", | |
// Entity Usage | |
"/admin/config/entity-usage/batch-update", | |
"/admin/config/entity-usage/settings", | |
// Environment indicator | |
"/admin/config/development/environment-indicator", | |
// Environment indicator UI | |
"/admin/config/development/environment-indicator/current", | |
// Field Defaults | |
"/admin/config/system/field_defaults/settings", | |
// Field Permissions | |
"/admin/reports/fields/permissions", | |
// Field UI | |
"/admin/structure/display-modes", | |
"/admin/structure/display-modes/form/add", | |
"/admin/structure/display-modes/view/add", | |
"/admin/config/people/accounts/display/add-group", | |
"/admin/config/people/accounts/form-display/add-group", | |
"/admin/config/people/accounts/fields/add-field", | |
// File metadata manager | |
"/admin/config/system/file_mdm", | |
// Filter | |
"/admin/config/content/formats", | |
"/admin/config/content/formats/add", | |
"/filter/tips", | |
// Font Awesome | |
"/admin/config/content/fontawesome", | |
// Full Calendar View Plugin | |
// '/fullcalendar-view-event-add', | |
// '/fullcalendar-view-event-update', | |
// Geocoder | |
// '/geocoder/api/geocode', | |
// '/geocoder/api/reverse_geocode', | |
"/admin/config/system/geocoder", | |
// Geolocation | |
"/admin/config/services/geolocation", | |
// Google Analytics | |
"/admin/config/system/google-analytics", | |
// Google Analytics Counter | |
"/admin/config/system/google-analytics-counter/authentication", | |
"/admin/config/system/google-analytics-counter/dashboard/revoke", | |
"/admin/config/system/google-analytics-counter/dashboard", | |
"/admin/config/system/google-analytics-counter", | |
"/admin/config/system/google-analytics-counter-configure-types", | |
// Help | |
"/admin/help", | |
// Honeypot | |
"/admin/config/content/honeypot", | |
// Image | |
"/admin/config/media/image-styles/add", | |
// ImageWidgetCrop | |
"/admin/config/media/crop-widget", | |
// Juicebox | |
"/admin/config/media/juicebox", | |
// Language | |
"/admin/config/regional/language/add", | |
"/admin/config/regional/content-language", | |
"/admin/config/regional/language/detection", | |
"/admin/config/regional/language/detection/browser", | |
"/admin/config/regional/language/detection/selected", | |
"/admin/config/regional/language/detection/session", | |
"/admin/config/regional/language/detection/url", | |
// Mail System | |
"/admin/config/system/mailsystem", | |
// Mail Safety | |
"/admin/config/development/mail_safety/clear", | |
"/admin/config/development/mail_safety", | |
"/admin/config/development/mail_safety/settings", | |
// Masquerade | |
"/masquerade", | |
// Media | |
// '/media/oembed', | |
"/admin/config/media/media-settings", | |
// Media Library | |
"/admin/config/media/media-library", | |
// Memcache Admin | |
"/admin/reports/memcache", | |
"/admin/config/system/memcache", | |
// Menu Link Attributes | |
"/admin/config/menu_link_attributes/config", | |
// Metatag | |
"/admin/reports/metatag-plugins", | |
"/admin/config/search/metatag/settings", | |
// Mime Mail | |
"/admin/config/system/mimemail", | |
// Module filter | |
"/admin/config/user-interface/module-filter", | |
]; | |
}); | |
// for each url test it loads properly | |
it(`Drupal Routes load without error`, () => { | |
// Login once we will test these with and admin account | |
cy.login(Cypress.env("cyAdminUser"), Cypress.env("cyAdminPassword")); | |
// loop over all the URLS and test the load | |
urls.forEach((url) => { | |
// load each url, the test will fail if they are not 200's | |
cy.visit(url); | |
// Check there are no drupal error messages | |
cy.get("body").then(($body) => { | |
// see if any PHP errors happen only way I see to check is look for the | |
// php error template HTML on the page | |
if ($body.html().includes("</b> on line <b>")) { | |
throw new Error(`PHP issue on ${url}`); | |
} | |
// Check if the body contains a drupal error class message | |
if ($body.find(".messages--error").length > 0) { | |
// There is either a single error or multiple error messages | |
if ($body.find(".messages--error .messages__item").length > 0) { | |
// if multiple they are put into an HTML list | |
cy.get(".messages--error .messages__item").then(function ( | |
$elems | |
) { | |
// Loop over messages and evaluate | |
let i = 0; | |
for (i = 0; i < $elems.length; i++) { | |
let thisMsg = $elems[i].innerText; | |
if (checkIfShouldIgnore(thisMsg)) { | |
// ignore this message | |
} else { | |
// This is a problem message so trigger a fail | |
cy.log(thisMsg.trim()); | |
throw new Error(thisMsg.trim()); | |
} | |
} | |
}); | |
} else { | |
// else single | |
cy.get(".messages--error").then(function ($elem) { | |
let thisMsg = $elem.text(); | |
if (checkIfShouldIgnore(thisMsg)) { | |
// ignore this message | |
} else { | |
// This is a problem message so trigger a fail | |
cy.log(thisMsg.trim()); | |
throw new Error(thisMsg.trim()); | |
} | |
}); | |
} | |
} | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment