Skip to content

Commit

Permalink
Added major Tagged Test Filter configurations (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yemaneberhan-Lemma authored Nov 27, 2024
1 parent cdb1cc7 commit c2553cc
Show file tree
Hide file tree
Showing 16 changed files with 487 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ jobs:
- name: Change admin password to make it easier for Cypress tests
run: ddev drush upwd "$CYPRESS_ADMIN_USERNAME" "$CYPRESS_ADMIN_PASSWORD"

- name: Cypress Test
run: ddev cypress-run
- name: Cypress Test (excluding expensive tests)
run: ddev cypress-run --env grepTags=-expensive

- name: Save Cypress recordings
if: always()
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Cypress Tests

on:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday midnight

jobs:
cypress_tests:
runs-on: ubuntu-latest

env:
CYPRESS_ADMIN_USERNAME: ct-admin
CYPRESS_ADMIN_PASSWORD: ct-admin

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Setup DDEV
uses: ddev/github-action-setup-ddev@v1
with:
autostart: false

- name: Set the platform.sh token
run: |
ddev config global --web-environment-add="PLATFORMSH_CLI_TOKEN=${{ secrets.PLATFORMSH_CLI_TOKEN }}"
ddev start
- name: Install dependencies
run: |
ddev composer install
ddev pull platform -y
cd web/themes/custom/contribtracker
npm ci --prefer-offline --no-audit
- name: Change admin password for Cypress
run: ddev drush upwd "$CYPRESS_ADMIN_USERNAME" "$CYPRESS_ADMIN_PASSWORD"

- name: Run expensive tests (weekly)
run: ddev cypress-run --env grepTags=expensive

- name: Save Cypress recordings
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-recordings
path: |
web/themes/custom/contribtracker/cypress/screenshots
web/themes/custom/contribtracker/cypress/videos
retention-days: 3
9 changes: 8 additions & 1 deletion web/themes/custom/contribtracker/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { defineConfig } from 'cypress';

import grepPlugin from '@cypress/grep/src/plugin';
export default defineConfig({
projectId: 'contrib-tracker',
chromeWebSecurity: false, // To Bypass Same-Origin Policy - Useful for social-media-link-check test
video: process.env.CYPRESS_VIDEO !== 'false', // Defaults to true unless explicitly set to 'false'
e2e: {
baseUrl: process.env.CYPRESS_BASE_URL || 'https://contrib.axelerant.com', // Default to prod url if no base URL is set
env: {
grepTags: '',
},
setupNodeEvents(on, config) {
grepPlugin(config); // Use the imported plugin directly
return config;
},
},
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Form Auto-Suggestions Validation with Extracted User Name
describe('Form Auto-Suggestions Validation with Extracted User Name', () => {
describe('Form Auto-Suggestions Validation with Extracted User Name', { tags: ['critical-path'] }, () => {
it('should show auto-suggestions when typing the first user name', () => {
// Visit the page with the form
cy.visit('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Date Picker Validation with Random Date Selection
describe('Date Picker Filter Validation with Random Date Selection', () => {
describe('Date Picker Filter Validation with Random Date Selection', { tags: ['critical-path'] }, () => {
// Before test, visit the base URL
before(() => {
cy.visit('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Form Filter Validation with Positive and Negative Scenarios
describe('Form Filter Validation with Positive and Negative Scenarios', () => {
describe('Form Filter Validation with Positive and Negative Scenarios', { tags: ['critical-path'] }, () => {
// Before each test, visit the base URL to ensure a fresh start
beforeEach(() => {
cy.visit('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for verifying form reset functionality with positive and negative scenarios
describe('Form Reset Button Validation with Positive and Negative Scenarios', () => {
describe('Form Reset Button Validation with Positive and Negative Scenarios', { tags: ['critical-path'] }, () => {
// Before each test, visit the page containing the form
beforeEach(() => {
cy.visit('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Hover Actions Verification
describe('Hover Actions Verification', () => {
describe('Hover Actions Verification', { tags: ['critical-path'] }, () => {
// Before each test, visit the base URL
beforeEach(() => {
cy.viewport('macbook-13');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Importing the fixture containing URLs
import pageUrls from '../fixtures/page-check-urls.json';

describe('Visual Testing', () => {
describe('Visual Testing', { tags: ['critical-path'] }, () => {
Object.keys(pageUrls).forEach((key) => {
const url = pageUrls[key].url;
const userType = pageUrls[key].hasOwnProperty('userType')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Main Page Sublinks Response Code Validation
describe('Main Page Sublinks Response Code Validation', () => {
describe('Main Page Sublinks Response Code Validation', { tags: ['expensive', 'critical-path'] }, () => {
// Before each test, visit the main page
beforeEach(() => {
cy.visit('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Pagination Handling and Validation
describe('Pagination Handling and Validation', () => {
describe('Pagination Handling and Validation', { tags: ['critical-path'] }, () => {
// Define the test case
it('should filter results with selected contribution type on each page', () => {
// Visit the page with the form
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for Social Media Icons Redirection Validation
describe('Social Media Icons Redirection Validation', () => {
describe('Social Media Icons Redirection Validation', { tags: ['critical-path'] }, () => {
// List of social media icons with their selectors
const socialMediaLinks = [
{ selector: '.icon-facebook' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Describe the test suite for XSS Attack Simulation in Form Fields Verification
describe('XSS Attack Simulation in Form Fields Verification', () => {
describe('XSS Attack Simulation in Form Fields Verification', { tags: ['security', 'critical-path'] }, () => {
before(() => {
// Visit the page with the form
cy.visit('/');
Expand Down
3 changes: 3 additions & 0 deletions web/themes/custom/contribtracker/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import './commands';
import 'cypress-real-events'; // cypress inbuilt trigger() will only affect events in JavaScript and will not trigger any effects in CSS. See for more details: https://docs.cypress.io/api/commands/hover

import registerCypressGrep from '@cypress/grep';
registerCypressGrep();
Loading

0 comments on commit c2553cc

Please sign in to comment.