diff --git a/backstop.config.js b/backstop.config.js index 5f708a08d..93f497505 100644 --- a/backstop.config.js +++ b/backstop.config.js @@ -1,14 +1,10 @@ -const { urls } = require('./urls'); +const { urls, baseUrl } = require('./urls'); -// Helper function to automatically generate scenarios from the URLs -const createScenariosFromUrls = (urlsObj, delay = 1000) => { - return Object.keys(urlsObj).map((label) => ({ +const createScenariosFromUrls = (urls, delay = 1000) => { + return Object.keys(urls).map((label) => ({ label, - url: urlsObj[label], - hideSelectors: [], - removeSelectors: [], + url: urls[label], selectors: ['document'], - selectorExpansion: true, misMatchThreshold: 0.1, requireSameDimensions: true, delay, @@ -16,7 +12,7 @@ const createScenariosFromUrls = (urlsObj, delay = 1000) => { }; module.exports = { - id: 'my_project_tests', + id: 'backstop_test', viewports: [ { label: 'desktop', @@ -24,7 +20,18 @@ module.exports = { height: 768, }, ], - scenarios: createScenariosFromUrls(urls), + scenarios: [ + ...createScenariosFromUrls(urls), + // example page with script + { + label: 'Get Started Page - Highlight Trial Mode', + url: `${baseUrl}/using-notify/get-started`, + selectors: ['document'], + misMatchThreshold: 0.1, + requireSameDimensions: true, + onBeforeScript: 'puppeteer/onBefore.js', + }, + ], paths: { bitmaps_reference: 'backstop_data/bitmaps_reference', bitmaps_test: 'backstop_data/bitmaps_test', @@ -38,5 +45,5 @@ module.exports = { timeout: 30000, }, report: ['browser'], - debug: true, + debug: false, }; diff --git a/backstop_data/bitmaps_reference/my_project_tests_Accounts_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Accounts_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Accounts_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Accounts_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Add_Service_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Add_Service_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Add_Service_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Add_Service_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Delivery_Status_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Delivery_Status_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Delivery_Status_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Delivery_Status_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Features_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Features_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Features_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Features_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Get_Started_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Get_Started_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Get_Started_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Get_Started_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/backstop_test_Get_Started_Page_-_Highlight_Trial_Mode_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Get_Started_Page_-_Highlight_Trial_Mode_0_document_0_desktop.png new file mode 100644 index 000000000..a84d9db34 Binary files /dev/null and b/backstop_data/bitmaps_reference/backstop_test_Get_Started_Page_-_Highlight_Trial_Mode_0_document_0_desktop.png differ diff --git a/backstop_data/bitmaps_reference/my_project_tests_Guidance_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Guidance_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Guidance_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Guidance_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Homepage_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Homepage_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Homepage_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Homepage_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Pricing_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Pricing_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Pricing_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Pricing_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/backstop_test_Roadmaps_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Roadmaps_0_document_0_desktop.png new file mode 100644 index 000000000..cd316a93a Binary files /dev/null and b/backstop_data/bitmaps_reference/backstop_test_Roadmaps_0_document_0_desktop.png differ diff --git a/backstop_data/bitmaps_reference/my_project_tests_Security_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Security_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Security_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Security_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Support_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Support_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Support_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Support_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Trial_Mode_0_document_0_desktop.png b/backstop_data/bitmaps_reference/backstop_test_Trial_Mode_0_document_0_desktop.png similarity index 100% rename from backstop_data/bitmaps_reference/my_project_tests_Trial_Mode_0_document_0_desktop.png rename to backstop_data/bitmaps_reference/backstop_test_Trial_Mode_0_document_0_desktop.png diff --git a/backstop_data/bitmaps_reference/my_project_tests_Roadmaps_0_document_0_desktop.png b/backstop_data/bitmaps_reference/my_project_tests_Roadmaps_0_document_0_desktop.png deleted file mode 100644 index 23e2349f7..000000000 Binary files a/backstop_data/bitmaps_reference/my_project_tests_Roadmaps_0_document_0_desktop.png and /dev/null differ diff --git a/backstop_data/engine_scripts/puppeteer/onBefore.js b/backstop_data/engine_scripts/puppeteer/onBefore.js new file mode 100644 index 000000000..44413e80b --- /dev/null +++ b/backstop_data/engine_scripts/puppeteer/onBefore.js @@ -0,0 +1,18 @@ +module.exports = async (page, scenario) => { + await page.goto(scenario.url, { waitUntil: 'networkidle2' }); + + console.log('Page loaded.'); + + // Count the number of items in the side navigation and log their text + const navItems = await page.$$eval('nav ul li.usa-sidenav__item a', (items) => + items.map((item) => item.textContent.trim()) + ); + + console.log(`Found ${navItems.length} navigation items:`); + navItems.forEach((itemText, index) => { + console.log(`${index + 1}: ${itemText}`); + }); + + // Wait a moment for the logging to complete + await new Promise((resolve) => setTimeout(resolve, 1000)); +}; diff --git a/urls.js b/urls.js index ec8659b1b..60afe1642 100644 --- a/urls.js +++ b/urls.js @@ -1,19 +1,19 @@ -const baseUrl = "http://localhost:6012"; +const baseUrl = 'http://localhost:6012'; // List of routes with paths and labels const sublinks = [ - { label: "Homepage", path: "/" }, - { label: "Accounts", path: "/accounts" }, - { label: "Add Service", path: "/add-service" }, - { label: "Get Started", path: "/using-notify/get-started" }, - { label: "Trial Mode", path: "/using-notify/trial-mode" }, - { label: "Pricing", path: "/using-notify/pricing" }, - { label: "Delivery Status", path: "/using-notify/delivery-status" }, - { label: "Guidance", path: "/using-notify/guidance" }, - { label: "Features", path: "/features" }, - { label: "Roadmaps", path: "/features/roadmaps" }, - { label: "Security", path: "/features/security" }, - { label: "Support", path: "/support" }, + { label: 'Homepage', path: '/' }, + { label: 'Accounts', path: '/accounts' }, + { label: 'Add Service', path: '/add-service' }, + { label: 'Get Started', path: '/using-notify/get-started' }, + { label: 'Trial Mode', path: '/using-notify/trial-mode' }, + { label: 'Pricing', path: '/using-notify/pricing' }, + { label: 'Delivery Status', path: '/using-notify/delivery-status' }, + { label: 'Guidance', path: '/using-notify/guidance' }, + { label: 'Features', path: '/features' }, + { label: 'Roadmaps', path: '/features/roadmaps' }, + { label: 'Security', path: '/features/security' }, + { label: 'Support', path: '/support' }, // Add more links here as needed ]; @@ -26,5 +26,6 @@ const constructUrls = (base, sublinks) => }, {}); module.exports = { + baseUrl, urls: constructUrls(baseUrl, sublinks), };