Skip to Content
Documentation
QA
CypressTest CasesProduct Development Team

πŸ“‘ Working with Test Cases: Product Development Team

Cypress test cases are designed to check different parts of the website. Below are the two main tests:

πŸ–₯️ Demo Site Testing – AI.DemoSite.test.js

This test suite focuses on the demo site’s front end, ensuring that core functionalities are working correctly.

  • It verifies UI structure, navigation, and form interactions to provide a smooth user experience.

πŸ”§ Marketing Site Testing – AI.MarketingSite.test.js

This test suite focuses on the marketing site’s front end, ensuring accessibility and usability.

  • It follows the same validation checks as the demo site but is applied to the marketing platform.

βœ… Test Cases for Demo Site and Marketing Site Testing:

  1. Should load the website with the correct structure

    • Checks if the correct URL is loaded

      • βœ… If the URL matches the expected base URL, logs β€βœ… URL matches the expected base URL: {baseUrl}”.
      • ❌ If the URL does not match, logs β€βŒ URL mismatch: Expected {baseUrl} but got {currentUrl}” and adds it to errors.
    • Checks for essential page elements

      • βœ… If the Header, Body, and Footer exist and are visible, logs β€βœ… {Element} is visible”.
      • ❌ If an element is missing or not visible, logs β€βŒ {Element} is missing or not visible” and adds it to errors.
    • Final Assertion

      • βœ… If no issues are found, logs β€βœ… Website loaded successfully with all expected elements visible!”.
      • ❌ If errors exist, logs β€πŸš¨ The following issues were detected:” followed by the list of issues and fails the test.
  2. Should have no broken links

    • Scanning all links on the pages

      • βœ… If a valid <a> tag is found, logs β€πŸ” Scanning all links on the page…”.
    • Checks for broken or invalid links

      • βœ… If a link has a valid destination, it sends a request to check its status.
      • ❌ If a link is empty, #, javascript:void(0), or ends with /#, logs β€βŒ Broken link detected: {link text} ({href}) - Invalid destination” and adds it to deadLinks.
    • Skips non-testable links

      • βœ… If a link starts with mailto:, tel:, or sms:, logs β€œβš οΈ Skipping non-testable link: {link text} ({href})”.
      • βœ… If a link is a social media link (Facebook or LinkedIn), logs β€œβš οΈ Skipping Social Media link: {link text} ({href}) - Requires manual testing” and adds it to manualTest.
    • Checks for link response status

      • βœ… If the request returns a 200 status, logs β€βœ… Link working: {link text} ({href})”.
      • ⚠️ If the request returns 403, logs β€œβš οΈ {link text} ({href}) returned 403 - Cypress has no access, manual check required.” and adds it to manualTest.
      • ❌ If the request returns a status greater than 399, logs β€βŒ Broken link detected: {link text} ({href}) with status {status}” and adds it to deadLinks.
    • Final Assertion

      • ⚠️ If manual test links exist, logs β€œβš οΈ The following links require manual testing:” followed by the list of links.
      • βœ… If no broken links are found, logs β€βœ… No broken links detected on the page.”.
      • ❌ If broken links exist, logs β€πŸš¨ The following links are broken:” followed by the list of broken links and fails the test.
  3. Checks the contact form

    • Checks if a contact form exists

      • βœ… Finds all forms on the page.
      • βœ… If a form with the required fields is detected, logs β€βœ… Contact form found.”
      • ❌ If no suitable form is found, logs β€œβš οΈ No suitable contact form found. Visiting /contact page…” and navigates to /contact.
    • Fills out the contact form

      • βœ… Locates the input fields for first name, last name, email, phone, and message.
      • βœ… Clears existing values and inputs test data.
      • βœ… Clicks the submit button.
    • Handles form submission

      • βœ… Intercepts the form submission request (/wp-json/contact-form-7/v1/contact-forms/*/feedback)
      • βœ… Waits for the request to complete.
      • βœ… If the URL remains unchanged after submission, logs β€βœ… Contact form responded (intercepted request detected).”
      • ❌ If the URL unexpectedly changes, logs β€βŒ Unexpected URL change detected! Initial: {initialUrl} | Current: {currentUrl}” and fails the test.
    • Final Assertion

      • βœ… If the form submission request is intercepted, confirms form submission was successful.
      • ❌ If no form submission request is detected, logs an error and fails the test.
  4. Should have all images loaded

    • Scanning for Images

      • βœ… Scrolls to the bottom of the page and waits for all images to load.
      • βœ… Counts the total number of β€˜img’ elements on the page and logs the result.
    • Checking <img> Elements

      • βœ… Loops through all <img> elements, checking if they have a valid source (data-src, src, or data-aios-lazy-src).
      • ❌ If an image lacks a valid source, logs β€œβš οΈ Skipping Image {index}: No valid image source.”
      • βœ… If an image has a valid source, it scrolls into view and logs β€βœ… Image {index}: Valid source detected.”
    • Testing Image Requests

      • βœ… If an image source is valid, sends a request to verify if it loads successfully.
      • βœ… If the request returns a 200-399 status, logs β€βœ… Image {index}: Working properly ({status}).”
      • ❌ If the request returns a 400+ status, logs β€βŒ Image {index}: Request failed with status {status}.” and adds it to brokenImages.
    • Checking <canvas> Elements with Background Images

      • βœ… Detects if there are any <canvas> elements on the page.
      • ❌ If no <canvas> elements exist, logs β€œβš οΈ No <canvas> elements found on this page, skipping canvas image checks.”
      • βœ… If <canvas> elements exist, extracts background-image URLs from inline styles.
      • ❌ If a <canvas> element lacks a background image, logs β€œβš οΈ Skipping Canvas {index}: No background image found, but does not mean it’s a broken image.”
    • Testing Canvas Background Image Requests

      • βœ… If a <canvas> element has a background-image, it sends a request to check if it loads successfully.
      • βœ… If the request returns a 200-399 status, logs β€βœ… Canvas {index}: Background image attribute is valid.”
      • ❌ If the request returns a 400+ status, logs β€βŒ Canvas {index}: Request failed with status {status}.” and adds it to brokenImages.
    • Final Assertion

      • βœ… If no broken images exist, logs β€βœ… All images and canvas background images loaded successfully!”
      • ❌ If broken images exist, logs all issues and fails the test with β€πŸš¨ The following images are broken:” and lists the broken image URLs.
Last updated on