π 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:
-
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.
- β
If the URL matches the expected base URL, logs ββ
URL matches the expected base URL:
-
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.
- β
If the Header, Body, and Footer exist and are visible, logs ββ
-
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.
-
-
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β¦β.
- β
If a valid
-
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.
- β
If a link starts with mailto:, tel:, or sms:, logs ββ οΈ Skipping non-testable link:
-
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.
- β
If the request returns a 200 status, logs ββ
Link working:
-
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.
-
-
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.
- β
Intercepts the form submission request
-
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.
-
-
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.β
- β
Loops through all
-
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.β
- β
Detects if there are any
-
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.
- β
If a
-
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.
-