Skip to content

Commit

Permalink
CPS-356: Backstop Suite Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deb1990 committed Feb 25, 2021
1 parent e284964 commit 02d6910
Show file tree
Hide file tree
Showing 32 changed files with 911 additions and 1,299 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/backstop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ on:
civicase_test_branch:
description: CiviCase Test Branch/tag Name
required: true
civicrm_version:
description: CiviCRM Version
default: master
civicrm_reference_version:
description: CiviCRM Reference Version
default: 5.28 # change this to the current civicrm version in use
required: true
civicrm_test_version:
description: CiviCRM Test Version
default: 5.28 # change this to the current civicrm version in use
required: true
reference_shoreditch_branch:
description: Shoreditch Reference Branch/Tag Name
Expand Down Expand Up @@ -57,14 +61,14 @@ jobs:
echo "IncludeOptional $HOME/.amp/apache.d/*.conf" >> /etc/apache2/apache2.conf
/usr/sbin/apache2ctl restart
- name: Build Reference Drupal site (CiviCRM - ${{ github.event.inputs.civicrm_version }}, CiviCase - ${{ github.event.inputs.civicase_reference_branch }}, Shoreditch - ${{ github.event.inputs.reference_shoreditch_branch }})
- name: Build Reference Drupal site (CiviCRM - ${{ github.event.inputs.civicrm_reference_version }}, CiviCase - ${{ github.event.inputs.civicase_reference_branch }}, Shoreditch - ${{ github.event.inputs.reference_shoreditch_branch }})
run: |
civibuild create drupal-clean --civi-ver ${{ github.event.inputs.civicrm_version }} --cms-ver 7.74 --web-root $GITHUB_WORKSPACE/${{ env.REFERENCE_SITE_FOLDER }} --url ${{ env.REFERENCE_SITE_URL }}
civibuild create drupal-clean --civi-ver ${{ github.event.inputs.civicrm_reference_version }} --cms-ver 7.74 --web-root $GITHUB_WORKSPACE/${{ env.REFERENCE_SITE_FOLDER }} --url ${{ env.REFERENCE_SITE_URL }}
chmod -R 777 $GITHUB_WORKSPACE/${{ env.REFERENCE_SITE_FOLDER }}
- name: Build Test Drupal site (CiviCRM - ${{ github.event.inputs.civicrm_version }}, CiviCase - ${{ github.event.inputs.civicase_test_branch }}, Shoreditch - ${{ github.event.inputs.test_shoreditch_branch }})
- name: Build Test Drupal site (CiviCRM - ${{ github.event.inputs.civicrm_test_version }}, CiviCase - ${{ github.event.inputs.civicase_test_branch }}, Shoreditch - ${{ github.event.inputs.test_shoreditch_branch }})
run: |
civibuild create drupal-clean --civi-ver ${{ github.event.inputs.civicrm_version }} --cms-ver 7.74 --web-root $GITHUB_WORKSPACE/${{ env.TEST_SITE_FOLDER }} --url ${{ env.TEST_SITE_URL }}
civibuild create drupal-clean --civi-ver ${{ github.event.inputs.civicrm_test_version }} --cms-ver 7.74 --web-root $GITHUB_WORKSPACE/${{ env.TEST_SITE_FOLDER }} --url ${{ env.TEST_SITE_URL }}
chmod -R 777 $GITHUB_WORKSPACE/${{ env.TEST_SITE_FOLDER }}
- name: Installing CiviCase and Shoreditch in Reference Site
Expand Down Expand Up @@ -99,8 +103,7 @@ jobs:
npm install
npx gulp backstopjs:setup-data
- name: Reference Screenshots in (CiviCRM - ${{ github.event.inputs.civicrm_version }}, CiviCase - ${{ github.event.inputs.civicase_reference_branch }}, Shoreditch - ${{ github.event.inputs.reference_shoreditch_branch }})
continue-on-error: true
- name: Reference Screenshots in (CiviCRM - ${{ github.event.inputs.civicrm_reference_version }}, CiviCase - ${{ github.event.inputs.civicase_reference_branch }}, Shoreditch - ${{ github.event.inputs.reference_shoreditch_branch }})
working-directory: ${{ env.REFERENCE_SITE_FOLDER }}/${{ env.CIVICRM_EXTENSIONS_DIR }}/${{ env.CIVICASE_BACKSTOP_DIR }}
run: |
npx gulp backstopjs:reference
Expand Down Expand Up @@ -143,22 +146,19 @@ jobs:
sed -i 's+${{ env.REFERENCE_SITE_URL }}+${{ env.TEST_SITE_URL }}+' site-config.json
sed -i 's+${{ env.REFERENCE_SITE_FOLDER }}+${{ env.TEST_SITE_FOLDER }}+' site-config.json
- name: Test Screenshots in (CiviCRM - ${{ github.event.inputs.civicrm_version }}, CiviCase - ${{ github.event.inputs.civicase_test_branch }}, Shoreditch - ${{ github.event.inputs.test_shoreditch_branch }})
- name: Test Screenshots in (CiviCRM - ${{ github.event.inputs.civicrm_test_version }}, CiviCase - ${{ github.event.inputs.civicase_test_branch }}, Shoreditch - ${{ github.event.inputs.test_shoreditch_branch }})
working-directory: ${{ env.REFERENCE_SITE_FOLDER }}/${{ env.CIVICRM_EXTENSIONS_DIR }}/${{ env.CIVICASE_BACKSTOP_DIR }}
continue-on-error: true
run: |
npx gulp backstopjs:test
- name: Prepare test report for download
if: ${{ always() }}
working-directory: ${{ env.REFERENCE_SITE_FOLDER }}/${{ env.CIVICRM_EXTENSIONS_DIR }}/${{ env.CIVICASE_BACKSTOP_DIR }}
run: |
mkdir backstop_report
cp -r html_report backstop_report
cp -r screenshots backstop_report
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: backstop-report
path: ${{ env.REFERENCE_SITE_FOLDER }}/${{ env.CIVICRM_EXTENSIONS_DIR }}/${{ env.CIVICASE_BACKSTOP_DIR }}/backstop_report
1 change: 0 additions & 1 deletion tests/backstop_data/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ This test suite is customised for angular app specific to civicase, so it uses s
```
waitForAjaxComplete // Set to true if any event (click/hover) loads some content through AJAX
isUIBPopover // Set to true if the hover state opens a uib popover
captureLoadingScreen // Sets to true if backstop don't want to wait for loading state to complete and capture the loading screen
```
2 changes: 1 addition & 1 deletion tests/backstop_data/backstop.tpl.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"--no-sandbox"
]
},
"asyncCaptureLimit": 3,
"asyncCaptureLimit": 1,
"asyncCompareLimit": 50,
"debug": false,
"debugWindow": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = async (page, scenario, vp) => {
await page.click('.civicase__activity-feed__body__details .edit.button');
await page.waitFor('.blockUI.blockOverlay', { hidden: true });
await utility.openAllAccordions();
await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = async (page, scenario, vp) => {

await page.click('.civicase__bulkactions-actions-dropdown .dropdown-menu li:nth-child(3) a');

await page.waitFor(500);
await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ module.exports = async (page, scenario, vp) => {
await require('./bulk-actions')(page, scenario, vp);

await page.click('.civicase__bulkactions-actions-dropdown .dropdown-menu li:nth-child(2) a');

await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ module.exports = async (page, scenario, vp) => {
await require('./bulk-actions')(page, scenario, vp);

await page.click('.civicase__bulkactions-actions-dropdown .dropdown-menu li:nth-child(6) a');

await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ module.exports = async (page, scenario, vp) => {
await require('./bulk-actions')(page, scenario, vp);

await page.click('.civicase__bulkactions-actions-dropdown .dropdown-menu li:nth-child(1) a');

await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = async (page, scenario, vp) => {

await page.click('.civicase__bulkactions-actions-dropdown .dropdown-menu li:nth-child(4) a');

await page.waitFor(500);
await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = async (page, scenario, vp) => {

await page.click('.civicase__activity-feed-pager__more .btn');
await page.waitForSelector('.civicase__activity-feed-pager__more .civicase__spinner', { hidden: true });
await page.waitFor(1000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Utility = require('./../utility.js');
module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await utility.waitForAngular();
await page.waitFor('.blockUI.blockOverlay', { hidden: true });
await page.waitForSelector('#civicaseActivitiesTab #bootstrap-theme .civicase__activity-feed');
await utility.waitForLoadingComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = async (page, scenario, vp) => {

await page.click('.civicase__case-body_tab > li:nth-child(2) a');
await utility.waitForLoadingComplete();
await page.waitFor(500);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module.exports = async (page, scenario, vp) => {
await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(9) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-trash');
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

module.exports = async (page, scenario, vp) => {
await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(2) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-tags');
await page.waitFor(2000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module.exports = async (page, scenario, vp) => {
await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(4) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-envelope-o');
await page.waitFor('.civicase__email-role-selector');
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(6) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-file-excel-o');
await utility.waitForUIModalLoad();
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict';

const Utility = require('./../utility.js');

module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(7) a');
await utility.waitForUIModalLoad();
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-link');
await page.waitFor(2000);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(8) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-lock');
await utility.waitForUIModalLoad();
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await require('./action-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li:nth-child(5) a');
await page.click('.civicase__case-header__action-menu .btn-group:last-child .dropdown-menu li .fa-file-pdf-o');
await utility.waitForUIModalLoad();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const Utility = require('./../utility.js');

module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

await utility.waitForAngular();
await utility.waitForLoadingComplete();

await page.click('.civicase__case-header__expand_button');

await page.waitFor(2000);
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
'use strict';

const Utility = require('./../utility.js');

module.exports = async (page, scenario, vp) => {
const utility = new Utility(page, scenario, vp);

console.log(scenario.url);

await require('./status-dropdown')(page, scenario, vp);
await page.click('.civicase__case-header__action-menu .btn-group:first-child .dropdown-menu li:nth-child(2) a');
await utility.waitForUIModalLoad();
await page.waitFor(1000);
};
11 changes: 8 additions & 3 deletions tests/backstop_data/engine_scripts/puppet/mouse-events-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Utility = require('./utility.js');

module.exports = async (page, scenario, viewport) => {
module.exports = async (page, scenario, viewport, dontWait) => {
const actions = [
{ name: 'hoverSelector', execute: hoverSelectorAction },
{ name: 'hoverSelectors', execute: hoverSelectorAction },
Expand All @@ -13,7 +13,7 @@ module.exports = async (page, scenario, viewport) => {
for (const action of actions) {
const scenarioHasAction = !!scenario[action.name];

scenarioHasAction && await action.execute(page, scenario, viewport);
scenarioHasAction && await action.execute(page, scenario, viewport, dontWait);
}
};

Expand Down Expand Up @@ -43,8 +43,9 @@ async function hoverSelectorAction (page, scenario, viewport) {
* @param {object} page pupettter engine object
* @param {object} scenario object of each scenario
* @param {object} viewport viewport configurations
* @param {boolean} dontWait whether to apply additional wait
*/
async function clickSelectorAction (page, scenario, viewport) {
async function clickSelectorAction (page, scenario, viewport, dontWait) {
const clickSelectors = scenario.clickSelectors || [scenario.clickSelector];
const utility = new Utility(page, scenario, viewport);

Expand All @@ -58,5 +59,9 @@ async function clickSelectorAction (page, scenario, viewport) {
if (scenario.waitForUIModalLoad) {
await utility.waitForUIModalLoad();
}

if (!dontWait) {
await page.waitFor(1000);
}
}
}
5 changes: 4 additions & 1 deletion tests/backstop_data/engine_scripts/puppet/on-before.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

const cv = require('civicrm-cv')({ mode: 'sync' });
const loadCookies = require('./load-cookies');
var fs = require('fs');

module.exports = async (page, scenario, vp) => {
console.log('--------------------------------------------');
console.log('Running Scenario "' + scenario.label + '" ' + scenario.count);

var cwd = JSON.parse(fs.readFileSync('site-config.json')).root;

// Execute api calls defined in the scenario
if (scenario.apiCalls) {
scenario.apiCalls.forEach((apiCall) => {
cv('api ' + apiCall);
cv(`--cwd=${cwd} api ${apiCall}`);
});
}

Expand Down
6 changes: 1 addition & 5 deletions tests/backstop_data/engine_scripts/puppet/on-ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ module.exports = async (page, scenario, vp) => {

await utility.waitForAngular();

if (!scenario.captureLoadingScreen) {
await utility.waitForLoadingComplete(scenario.waitForLoadingComplete);
}

await mouseEventsHelper(page, scenario);
await mouseEventsHelper(page, scenario, null, true);

if (scenario.isUIBPopover) {
// Clone the popover to a new element so that it doesn't get lost
Expand Down
35 changes: 35 additions & 0 deletions tests/backstop_data/engine_scripts/puppet/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ module.exports = class CrmPage {
*/
async waitForAngular () {
await this.engine.waitForSelector('#bootstrap-theme');

// remove drupal/civicrm error logging, which creates difference
await this.removeElements('#console');

await this.closeSystemErrorNotification();
}

/**
Expand All @@ -129,6 +134,7 @@ module.exports = class CrmPage {
await this.engine.waitFor('.modal-dialog > form');
await this.cleanups();
await this.openAllAccordions();
await this.engine.waitFor(1000);
}

/**
Expand Down Expand Up @@ -203,4 +209,33 @@ module.exports = class CrmPage {
console.log('Selector "' + selector + '" not found');
}
}

/**
* Waits for the System Error Notification to close.
*/
async closeSystemErrorNotification () {
try {
const isSystemErrorNotificationVisible = await this.isElementVisible('#crm-notification-container a[title="close"]');

if (isSystemErrorNotificationVisible) {
await this.engine.click('#crm-notification-container a[title="close"]');
await this.engine.waitFor(1000);
}
} catch (e) {
console.log('System Error Notification not found');
}
}

/**
* @param {string} selector - the css selector for the element to wait
*/
async removeElements (selector) {
try {
await this.engine.evaluate((selector) => {
CRM.$(selector).hide();
}, selector);
} catch (e) {
console.log('Selector not found');
}
}
};
Loading

0 comments on commit 02d6910

Please sign in to comment.