Skip to content

Commit 3d7f5d1

Browse files
authored
Merge pull request #123 from thebiggive/REG-34-donation-funds-test
REG-34: Stop skipping credit donation test
2 parents 6def80d + e9373a1 commit 3d7f5d1

File tree

11 files changed

+36
-31
lines changed

11 files changed

+36
-31
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
paths:
2626
- ~/.cache
2727
- run: yarn lint
28-
- run: yarn tsc || echo "Typescript errors found, not failing build"
28+
- run: yarn tsc
2929
- run: yarn test:testingbot-all
3030
# - run: yarn test:testingbot-chrome
3131
# - run: yarn test:testingbot-edge

features/donation-with-credits.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@skip()
21
Feature: Existing donor: credit donation completes successfully
32

43
As a donor who doesn't have access to a card that can be used to donate via Big Give's platform
@@ -18,7 +17,7 @@ Feature: Existing donor: credit donation completes successfully
1817
Then I should see my populated first name is "RegressionTest"
1918
And I should see my populated surname is "User"
2019
And I should see my populated email is "[email protected]"
21-
And I should see "Your credit balance will be applied against this donation. No further funds will be taken." instead of asking for my bank details.
20+
And I should see "Your donation funds balance will be applied against this donation. No further funds will be taken." instead of asking for my bank details.
2221
When I continue through this step with no changes
2322
And I choose a preference for charity and TBG communications
2423
And I press Donate

pages/DonateStartPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class DonateStartPage {
6868
* while keeping the step definitions simple.
6969
*
7070
* @param {string} selector Element selector.
71-
* @returns {any} click() result on success.
71+
* @returns {Promise<any>} click() result on success.
7272
*/
7373
async clickActiveSelector(selector) {
7474
let bestButton;
@@ -93,7 +93,7 @@ export default class DonateStartPage {
9393
*
9494
* @param {string} selector Element selector.
9595
* @param {string} inputValue The new value.
96-
* @returns {any} setValue() result on success.
96+
* @returns {Promise<any>} setValue() result on success.
9797
*/
9898
async inputSelectorValue(selector, inputValue) {
9999
return inputSelectorValue(selector, inputValue);

pages/PledgeFormPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class PledgeFormPage {
2121
/**
2222
* Get the input field corresponding to the given label text.
2323
* @param {string} label Full or partial label text. No single quotes.
24-
* @returns {string} Input selector
24+
* @returns {Promise<string>} Input selector
2525
*/
2626
async getCommunitiesInputForLabel(label) {
2727
return `//label[contains(text(), '${label}')]//..//input`;
@@ -32,7 +32,7 @@ export default class PledgeFormPage {
3232
* seems to put the label text in an inner <span>.
3333
*
3434
* @param {string} label Full or partial label text. No single quotes.
35-
* @returns {string} Select selector
35+
* @returns {Promise<string>} Select selector
3636
*/
3737
async getCommunitiesSelectForLabel(label) {
3838
return `//span[contains(text(), '${label}')]//..//..//select`;

steps/donation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ BeforeAll(() => {
2929
// Steps
3030
Given(
3131
/^that I am on my chosen ([a-zA-Z]+)-enabled charity's Donate page$/,
32+
// eslint-disable-next-line no-unused-vars
3233
async (psp) => {
3334
page.nextStepIndex = 0;
34-
await page.open(psp);
35+
await page.open();
3536
await page.checkReady();
3637
}
3738
);

steps/hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ before(async (scenario) => {
77
after(async (scenarioResult) => {
88
// Here it is added to a failed step, but each time you call
99
// `browser.saveScreenshot()` it will automatically be added to the report
10-
if (scenarioResult.result.status !== 'passed') {
10+
if (scenarioResult.result.status !== 'PASSED') {
1111
// It will add the screenshot to the JSON
1212
await console.warn('WARNING: Step Failed - screenshot being taken...');
1313

1414
const datetime = encodeURIComponent((new Date()).toISOString());
1515
const filePath = `build/failure-${datetime}.png`;
1616
await browser.saveScreenshot(filePath);
1717
}
18-
return scenarioResult.status;
18+
return scenarioResult.result.status;
1919
});

support/action.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function clickSelector(selector, options = {}) {
2323
/**
2424
* Click an element that we have already tested for existence and clickability.
2525
*
26-
* @param {Element} element The element.
26+
* @param {HTMLElement} element The element.
2727
* @param {string} originalSelector Text used to look it up, for info log.
2828
*/
2929
export async function clickElement(element, originalSelector) {
@@ -92,7 +92,7 @@ export async function leaveStripeIframe() {
9292
* get element text
9393
*
9494
* @param {string} selector of content
95-
* @returns {string} element text
95+
* @returns {Promise<string>} element text
9696
*/
9797
export async function getSelectorText(selector) {
9898
if (!(await checkIfElementExists(selector))) {

support/check.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WAIT_SECONDS } from './constants';
44
* Check if element exists
55
*
66
* @param {string} selector to be checked
7-
* @param {int} seconds to wait
7+
* @param {number} seconds to wait
88
* @returns {Promise<boolean>} True if element exists or false if element doesn't exist
99
*/
1010
export async function checkIfElementExists(selector, seconds = WAIT_SECONDS) {
@@ -17,7 +17,7 @@ export async function checkIfElementExists(selector, seconds = WAIT_SECONDS) {
1717
* Checks whether a non-required selector is already present on the page.
1818
*
1919
* @param {string} selector DOM selector to seek
20-
* @return {boolean} Whether element exists
20+
* @return {Promise<boolean>} Whether element exists
2121
*/
2222
export async function elementExists(selector) {
2323
return $(selector).isDisplayed();
@@ -27,7 +27,7 @@ export async function elementExists(selector) {
2727
* Assert URL
2828
*
2929
* @param {string} url to be asserted
30-
* @param {int} seconds to wait
30+
* @param {number} seconds to wait
3131
* @return {Promise<boolean>} return if url matched
3232
*/
3333
export async function checkUrl(url, seconds = WAIT_SECONDS) {
@@ -46,7 +46,7 @@ export async function checkUrl(url, seconds = WAIT_SECONDS) {
4646
* Assert URL Regex
4747
*
4848
* @param {string} url to be asserted
49-
* @param {int} seconds to wait
49+
* @param {number} seconds to wait
5050
* @return {Promise<boolean>} return if url match regex
5151
*/
5252
export async function checkUrlMatch(url, seconds = WAIT_SECONDS) {
@@ -65,7 +65,7 @@ export async function checkUrlMatch(url, seconds = WAIT_SECONDS) {
6565
* Check webpage title
6666
*
6767
* @param {string} title of webpage
68-
* @param {int} seconds to wait
68+
* @param {number} seconds to wait
6969
* @return {Promise<boolean>} return if title matched
7070
*/
7171
export async function checkTitle(title, seconds = WAIT_SECONDS) {
@@ -83,10 +83,10 @@ export async function checkTitle(title, seconds = WAIT_SECONDS) {
8383
/**
8484
* Check a specific element contains certain text.
8585
*
86-
* @param {Element} element Already-located element.
86+
* @param {WebdriverIO.Element} element Already-located element.
8787
* @param {string} content Expected content.
88-
* @param {int} seconds Number of seconds to wait.
89-
* @returns {any} `waitUntil()` result.
88+
* @param {number} seconds Number of seconds to wait.
89+
* @returns {Promise<any>} `waitUntil()` result.
9090
*/
9191
async function checkText(element, content, seconds = WAIT_SECONDS) {
9292
return browser.waitUntil(
@@ -110,7 +110,7 @@ async function checkText(element, content, seconds = WAIT_SECONDS) {
110110
*
111111
* @param {string} selector of content
112112
* @param {string} content text
113-
* @param {int} seconds to wait
113+
* @param {number} seconds to wait
114114
* @return {Promise<boolean>} return if text exist
115115
*/
116116
export async function checkSelectorContent(selector, content, seconds = WAIT_SECONDS) {
@@ -130,8 +130,8 @@ export async function checkSelectorContent(selector, content, seconds = WAIT_SEC
130130
*
131131
* @param {string} selector DOM element selector.
132132
* @param {string} content text
133-
* @param {int} seconds to wait
134-
* @returns {any} `waitUntil()` result, assuming 1+ elements visible.
133+
* @param {number} seconds to wait
134+
* @returns {Promise<any>} `waitUntil()` result, assuming 1+ elements visible.
135135
*/
136136
export async function checkVisibleSelectorContent(selector, content, seconds = WAIT_SECONDS) {
137137
console.log(`CHECK: First visible element "${selector}" contains content "${content}"`);

support/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Allow for future constants by not exporting `default`.
22
// eslint-disable-next-line import/prefer-default-export
3-
export const WAIT_SECONDS = process.env.WAIT_SECONDS || 20;
3+
export const WAIT_SECONDS = Number(process.env.WAIT_SECONDS || 20);

support/mailtrap.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const axios = require('axios');
22

3+
if (!('create' in axios && typeof axios.create === 'function')) {
4+
// workaround for TS error;
5+
throw new Error('Missing axios create function');
6+
}
7+
38
const mailtrapClient = axios.create({
49
baseURL: 'https://mailtrap.io',
510
headers: {
@@ -11,7 +16,7 @@ const mailtrapClient = axios.create({
1116
* Makes an authenticated GET call to Mailtrap.io's API.
1217
*
1318
* @param {string} path Request path
14-
* @param {array} responseType Deserialised response data
19+
* @param {string} responseType Deserialised response data
1520
*/
1621
async function mailtrapGet(path, responseType) {
1722
const response = await mailtrapClient.get(path, { responseType });
@@ -22,7 +27,7 @@ async function mailtrapGet(path, responseType) {
2227
* Get the latest Mailtrap inbox message, if any.
2328
*
2429
* @param {string} toEmailAddress Only find emails addressed to this account
25-
* @returns {array} Up to {{count}} messages, if available.
30+
* @returns {Promise<array>} Up to {{count}} messages, if available.
2631
*/
2732
async function getLatestMessages(toEmailAddress) {
2833
if (typeof toEmailAddress !== 'string') {
@@ -50,7 +55,7 @@ async function getLatestMessages(toEmailAddress) {
5055
* @param {string} searchText Expected text to find anywhere in HTML
5156
* @param {string} toEmailAddress Only find emails addressed to this account
5257
* (or an account that starts with this)
53-
* @returns {boolean} Whether the expected text was found.
58+
* @returns {Promise<boolean>} Whether the expected text was found.
5459
*/
5560
export async function checkAnEmailBodyContainsText(searchText, toEmailAddress) {
5661
const messages = await getLatestMessages(toEmailAddress);
@@ -82,7 +87,7 @@ export async function checkAnEmailBodyContainsText(searchText, toEmailAddress) {
8287
*
8388
* @param {string} searchText Text to expect in latest subject line.
8489
* @param {string} toEmailAddress Only find emails addressed to this account
85-
* @returns {void}
90+
* @returns {Promise<void>} Promise that resolves when check is done.
8691
*/
8792
export async function checkAnEmailSubjectContainsText(searchText, toEmailAddress) {
8893
const messages = await getLatestMessages(toEmailAddress);

0 commit comments

Comments
 (0)