From e0b748e62ec680d27644d2643ee1cc4acb626f3d Mon Sep 17 00:00:00 2001 From: Krupa Pammi Date: Thu, 6 Apr 2023 12:29:32 +0100 Subject: [PATCH] remove nightwatch tests and package (#390) * remove nightwatch tests and package * test: remove extra white space * test: lint playwright tests --- nightwatch.conf.js | 100 -------- package.json | 3 +- playwright/tests/submit/sorry.spec.js | 1 - .../tests/submit/successRedirect.spec.js | 1 - .../tests/submit/validFormSubmission.spec.js | 2 - .../update/giftaidDeclarationOptions.spec.js | 1 - playwright/yarn.lock | 2 +- tests/commands/form.js | 220 ------------------ tests/commands/giftaid.js | 47 ---- tests/feature/submit/address.js | 128 ---------- tests/feature/submit/erp.js | 63 ----- tests/feature/submit/error.js | 119 ---------- .../submit/marketingPreferencesData.js | 113 --------- .../submit/marketingPreferencesValidation.js | 160 ------------- tests/feature/submit/sorry.js | 12 - tests/feature/submit/success.js | 26 --- tests/feature/submit/validSubmission.js | 24 -- tests/feature/update/erp.js | 127 ---------- tests/feature/update/error.js | 20 -- tests/feature/update/sorry.js | 12 - tests/feature/update/success.js | 13 -- tests/feature/update/validSubmission.js | 95 -------- tests/test-urls.json | 4 - 23 files changed, 2 insertions(+), 1291 deletions(-) delete mode 100644 nightwatch.conf.js delete mode 100644 tests/commands/form.js delete mode 100644 tests/commands/giftaid.js delete mode 100644 tests/feature/submit/address.js delete mode 100644 tests/feature/submit/erp.js delete mode 100644 tests/feature/submit/error.js delete mode 100644 tests/feature/submit/marketingPreferencesData.js delete mode 100644 tests/feature/submit/marketingPreferencesValidation.js delete mode 100644 tests/feature/submit/sorry.js delete mode 100644 tests/feature/submit/success.js delete mode 100644 tests/feature/submit/validSubmission.js delete mode 100644 tests/feature/update/erp.js delete mode 100644 tests/feature/update/error.js delete mode 100644 tests/feature/update/sorry.js delete mode 100644 tests/feature/update/success.js delete mode 100644 tests/feature/update/validSubmission.js delete mode 100644 tests/test-urls.json diff --git a/nightwatch.conf.js b/nightwatch.conf.js deleted file mode 100644 index 915846d1..00000000 --- a/nightwatch.conf.js +++ /dev/null @@ -1,100 +0,0 @@ -// check https://github.com/nightwatchjs/nightwatch/issues/408 -require('events').EventEmitter.defaultMaxListeners = 100; -require('dotenv/config'); - -const nightwatch = { - src_folders: ['tests/feature'], - page_objects_path: 'tests/commands', - selenium: { - 'start_process': false, - 'host' : 'hub-cloud.browserstack.com', - port: 443, - }, - - webdriver: { - keep_alive: true, // keep session alive - }, - - globals: { - // controls the timeout value for async hooks. Expects the done() callback to be invoked within this time - // or an error is thrown - asyncHookTimeout : 600 * 1000, // timeout for .perform method for instance. - // ensure process is closing as in some cases, process hang forever. - after: (done)=> { - process.exit(0); - done(); - }, - }, - - common_capabilities: { - 'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME', - 'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY', - 'browserstack.selenium_version': "3.141.59", // latest selenium to fix element selectors. - 'browserstack.idleTimeout': 300, - acceptSslCerts: true, - silent: true, - live_output: false, - detailed_output: false, - screenshots: { - enabled: false, - path: '', - }, - request_timeout_options: { - timeout: 600 * 1000, - }, - }, - - test_settings: { - default: {}, - chrome: { - desiredCapabilities: { - os: 'Windows', - os_version: '10', - browser: 'Chrome', - browser_version: 'latest-1', - resolution: '1024x768', - name: 'Giftaid - Sanity', - }, - }, - ie: { - desiredCapabilities: { - os: 'Windows', - os_version: '10', - browser: 'IE', - browser_version: '11.0', - resolution: '1024x768', - name: 'Giftaid - Sanity', - }, - }, - // firefox: { - // desiredCapabilities: { - // os: 'Windows', - // os_version: '10', - // browser: 'firefox', - // browser_version: '69.0', - // resolution: '1024x768', - // name: 'Giftaid - Sanity', - // }, - // }, - } -}; - -// Code to support common capabilites -for(const testSetting in nightwatch.test_settings){ - const config = nightwatch.test_settings[testSetting]; - config['selenium_host'] = nightwatch.selenium.host; - config['selenium_port'] = nightwatch.selenium.port; - config['desiredCapabilities'] = config['desiredCapabilities'] || {}; - for(const commonCapability in nightwatch.common_capabilities){ - config['desiredCapabilities'][commonCapability] = config['desiredCapabilities'][commonCapability] || nightwatch.common_capabilities[commonCapability]; - } -} - -if (!process.env.RUN_SERIAL) { - nightwatch.test_workers = { - enabled: true, - workers: 'auto', - } -} - -module.exports = nightwatch; diff --git a/package.json b/package.json index 59c9340a..e32cfcdd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "scripts": { "start": "node scripts/start.js", "build": "node scripts/build.js", - "lint": "eslint --color src tests", + "lint": "eslint --color src playwright/tests", "test:sanity": "playwright test --grep '@sanity'", "cy:run": "export NODE_ENV=development; cypress run", "cy:open": "export NODE_ENV=development; cypress open", @@ -79,7 +79,6 @@ "html-webpack-plugin": "^4.0.0-beta.5", "imagemin-webpack-plugin": "2.4.2", "mini-css-extract-plugin": "^0.7.0", - "nightwatch": "^2.1.0", "node-sass": "^4.12.0", "npm-run-all": "^4.1.3", "optimize-css-assets-webpack-plugin": "^4.0.1", diff --git a/playwright/tests/submit/sorry.spec.js b/playwright/tests/submit/sorry.spec.js index 9aa35ee8..039ba968 100644 --- a/playwright/tests/submit/sorry.spec.js +++ b/playwright/tests/submit/sorry.spec.js @@ -3,7 +3,6 @@ const { expect } = require('@playwright/test'); const { test } = require('../../browserstack'); test.describe('Sorry page @sanity @nightly-sanity', () => { - test('accessing giftaid sorry page should show the sorry message', async ({ page }) => { await page.goto(process.env.BASE_URL + 'sorry', { timeout: 30000 }); diff --git a/playwright/tests/submit/successRedirect.spec.js b/playwright/tests/submit/successRedirect.spec.js index a02719ee..9207e0dc 100644 --- a/playwright/tests/submit/successRedirect.spec.js +++ b/playwright/tests/submit/successRedirect.spec.js @@ -3,7 +3,6 @@ const { expect } = require('@playwright/test'); const { test } = require('../../browserstack'); test.describe('Success page redirect @sanity @nightly-sanity', () => { - test('accessing success page should redirect to giftaid homepage', async ({ page }) => { await page.goto(process.env.BASE_URL + 'success', { timeout: 30000 }); diff --git a/playwright/tests/submit/validFormSubmission.spec.js b/playwright/tests/submit/validFormSubmission.spec.js index 0eb8760c..1f9079e9 100644 --- a/playwright/tests/submit/validFormSubmission.spec.js +++ b/playwright/tests/submit/validFormSubmission.spec.js @@ -4,7 +4,6 @@ const { test } = require('../../browserstack'); const { Commands } = require('../utils/commands'); test.describe('Valid giftaid submission @sanity @nightly-sanity', () => { - test('submit form with valid inputs', async ({ page }) => { const commands = new Commands(page); @@ -27,7 +26,6 @@ test.describe('Valid giftaid submission @sanity @nightly-sanity', () => { await expect(page.locator('div > h1')).toContainText('Thank you,\n' + 'test!'); - await page.close(); }); }); diff --git a/playwright/tests/update/giftaidDeclarationOptions.spec.js b/playwright/tests/update/giftaidDeclarationOptions.spec.js index 8f9e0d96..a717e0d2 100644 --- a/playwright/tests/update/giftaidDeclarationOptions.spec.js +++ b/playwright/tests/update/giftaidDeclarationOptions.spec.js @@ -4,7 +4,6 @@ const { test } = require('../../browserstack'); const { Commands } = require('../utils/commands'); test.describe('Giftaid declaration validation @sanity @nightly-sanity', () => { - test('select yes for giftaid claim should show as selected', async ({ page }) => { const commands = new Commands(page); diff --git a/playwright/yarn.lock b/playwright/yarn.lock index f251f34a..a895dfc7 100644 --- a/playwright/yarn.lock +++ b/playwright/yarn.lock @@ -358,7 +358,7 @@ util-deprecate@~1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -uuid@^8.3.2: +uuid@8.3.2, uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== diff --git a/tests/commands/form.js b/tests/commands/form.js deleted file mode 100644 index 781c1444..00000000 --- a/tests/commands/form.js +++ /dev/null @@ -1,220 +0,0 @@ -const faker = require('faker'); - -const randomString = faker.lorem.word(5); - -const commands = { - - /** - * Generate random string - * @return {string} - */ - randomString() { - return Date.now().toString() + faker.lorem.word(5); - }, - - /** - * Populate the giftaid form - * @param client - * @param userData - */ - fillForm( - client, - { - firstName = 'test', - lastName = 'user', - postcode = 'SW19 1NE', - address1 = '21 test road', - town = 'London', - } = {}, - ) { - return client - .click('#field-label--giftaid') - .setValue('#field-input--mobile', '07123456789') - .setValue('#field-input--firstname', firstName) - .setValue('#field-input--lastname', lastName + randomString) - .setValue('#field-input--postcode', postcode) - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', address1) - .setValue('#field-input--town', town) - }, - - /** - * Populate the giftaid using postcode lookup - * @param client - * @param userData - */ - fillFormPrefilledMobile( - client, - { - firstName = 'test', - lastName = 'user', - postcode = 'SW19 1NE', - } = {}, - ) { - return client - .click('#field-label--giftaid') - .setValue('#field-input--firstname', firstName) - .setValue('#field-input--lastname', lastName) - .setValue('#field-input--postcode', postcode) - .click('#postcode_button') - .pause(200) - .click('#field-select--addressSelect') - .click('#field-select--addressSelect>option:nth-child(6)') - .click('button[type=submit]') - .pause(5000); - }, - - /** - * Fill the donation form to the payment section - * @param client - * @param baseUrl - * @param amount - * @param donationType - * @param giftaid - * @param userData - */ - fillToPayment(client, baseUrl, amount, donationType, giftaid = false, userData = {}) { - commands.populateFromStartToGiftAidSection(client, baseUrl, donationType, amount); - - if (typeof donationType === 'undefined' || donationType === 'single') { - client.pause(3000); - client.waitForElementVisible('#giving_type_selector>div>div:nth-child(1)', 5000); - client.click('#giving_type_selector>div>div:nth-child(1)'); - } - - client.click('button#comicrelief_payinbundle_payment_amount_submit'); - if (giftaid) { - console.log('giftaid:', giftaid); - client.click('input#field-input--giftaid'); - } - client - .waitForElementVisible('#comicrelief_payinbundle_payment_card', 5000) - .click('button#comicrelief_payinbundle_payment_card') - .waitForElementVisible('#comicrelief_payinbundle_payment_submit', 3000); - - commands.populateFromAddressToPaymentSection(client, userData); - }, - - /** - * Populate the donation form from the start to the giftaid section - * @param client - * @param baseUrl - * @param donationType - * @param amount - */ - populateFromStartToGiftAidSection(client, baseUrl, donationType, amount) { - client - .url(baseUrl) - .pause(5000) - .waitForElementVisible('body', 5000, () => { - console.log('donationType:', donationType); - if (donationType === 'monthly') { - client.pause(5000).click('#giving_type_selector>div>div:nth-child(2)'); - } else if (donationType === 'single' || typeof donationType === 'undefined') { - client.pause(5000).click('#giving_type_selector>div>div:nth-child(1)'); - } - }) - .setValue('input#field-input--amount', amount); - - return client.pause(2000); - }, - - /** - * Populate the donation from address to payment section - * @param client - * @param userData - */ - populateFromAddressToPaymentSection( - client, - { - firstName = 'test', - lastName = 'user', - email = 'donate-staging@email.sls.comicrelief.com', - postcode = 'SW19 1NE', - address1 = '21 test road', - town = 'London', - } = {}, - ) { - return client.pause(2000) - .setValue('input#field-input--firstName', firstName) - .setValue('input#field-input--lastName', lastName) - .setValue('input#field-input--email', email) - .pause(1000) - .setValue('input#field-input--confirmEmail', email) - .setValue('input#field-input--postcode', postcode) - .click('main a.link') - .pause(2000) - .setValue('input#field-input--address1', address1) - .setValue('input#field-input--town', town) - .click('button#comicrelief_payinbundle_payment_submit') - .pause(5000); - }, - - /** - * Fill card form - * @param client - * @param cardNumber - * @param expiration - * @param cvc - */ - fillCardForm(client, cardNumber, expiration, cvc) { - - return client - .getLocationInView('label.card-number') - .pause(1000) - .frame(0, () => { - client.element('css selector', 'label.card-number iframe', (frame) => { - client.waitForElementVisible('input[name="cardnumber"]', 3000); - for (let i = 0; i < cardNumber.length; i += 1) { - client.sendKeys('input[name="cardnumber"]', cardNumber.charAt(i)); - } - }); - }) - .frame(null) - .getLocationInView('label.expiration-date') - .pause(2000) - .frame(1, () => { - client.element('css selector', 'label.expiration-date iframe', (frame) => { - client.waitForElementVisible('input[name="exp-date"]', 3500); - for (let i = 0; i < expiration.length; i += 1) { - client.sendKeys('input[name="exp-date"]', expiration.charAt(i)); - } - }); - }) - .frame(null) - .getLocationInView('label.cvc') - .pause(1000) - .frame(2, () => { - client.element('css selector', 'label.cvc iframe', (frame) => { - client.waitForElementVisible('input[name="cvc"]', 3500); - for (let i = 0; i < cvc.length; i += 1) { - client.sendKeys('input[name="cvc"]', cvc.charAt(i)); - } - }); - }) - .frame(null) - .pause(2000) - .click('button#comicrelief_payinbundle_payment_amount_submit') - .pause(15000); - }, - - /** - * Submit the marketing preferences form to the thank you section - * @param client - */ - submitMarketingPreferences(client) { - client.pause(3000); - - client.waitForElementVisible('.marketing-pref-form h1', 10000); - - client.click('.form__step--marketing-pref--bottom>button'); - - client.pause(10000); - }, - -}; - -module.exports = { - commands: [commands], -}; diff --git a/tests/commands/giftaid.js b/tests/commands/giftaid.js deleted file mode 100644 index 20b68b11..00000000 --- a/tests/commands/giftaid.js +++ /dev/null @@ -1,47 +0,0 @@ -const faker = require('faker'); - -const randomString = faker.lorem.word(5); - -const updateCommands = { - - /** - * Populate the giftaid update form with no to giftaid declaration - * @param client - */ - fillFormUpdateNo: function (client) { - return client - .setValue('#field-input--firstname', 'test') - .setValue('#field-input--lastname', 'user' + randomString) - .setValue('#field-input--postcode', 'SE1 7TP') - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', '21 test road') - .setValue('#field-input--town', 'London') - .click('#giftAidClaimChoice>div:nth-child(3)>label') - .click('button[type=submit]') - .pause(5000); - }, - - /** - * Populate the giftaid update form with yes to giftaid declaration - * @param client - */ - fillFormUpdateYes: function (client) { - return client - .setValue('#field-input--firstname', 'test') - .setValue('#field-input--lastname', 'user' + randomString) - .setValue('#field-input--email', `giftaid-staging-${randomString}@email.sls.comicrelief.com`) - .setValue('#field-input--postcode', 'SE1 7TP') - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', '21 test road') - .setValue('#field-input--town', 'London') - .click('#giftAidClaimChoice>div:nth-child(2)>label') - .click('button[type=submit]') - .pause(5000); - }, -}; - -module.exports = { - commands: [updateCommands], -}; diff --git a/tests/feature/submit/address.js b/tests/feature/submit/address.js deleted file mode 100644 index 9bdc32a3..00000000 --- a/tests/feature/submit/address.js +++ /dev/null @@ -1,128 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'submit', 'address'], - - 'Submit form entering address using postcode lookup': function (client) { - - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('#postcode_button'); - client.waitForElementVisible('select#field-select--addressSelect', 1000); - client.expect.element('label#field-label--addressSelect').text.to.equal('Select your address'); - client.click('select#field-select--addressSelect'); - client.click('#field-select--addressSelect > option:nth-child(5)'); - client.click('button[type="submit"]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, - - 'Submit form entering address manually': function (client) { - - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('a[aria-describedby=field-error--addressDetails]'); - client.waitForElementPresent('#field-input--address1', 1000); - client.setValue('#field-input--address1', '21 test road'); - client.setValue('#field-input--address2', 'High road'); - client.setValue('#field-input--address3', 'Waterloo'); - client.setValue('#field-input--town', 'London'); - client.click('button[type="submit"]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, - - 'Validate postcode field': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - - // postcode entered in lowercase should show error message - client.setValue('#field-input--postcode', 'se17tp'); - client.assert.textContains('div#field-error--postcode > span', 'Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode entered in uppercase should show error message - client.setValue('#field-input--postcode', 'SE17TP'); - client.assert.textContains('div#field-error--postcode > span', 'Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode with valid spaces should not show error message - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.assert.not.elementPresent('div#field-error--postcode > span'); - client.clearValue('#field-input--postcode'); - - // postcode with extra spaces should not show error message - client.setValue('#field-input--postcode', 'SE 1 7TP'); - client.assert.textContains('div#field-error--postcode > span', 'Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode with extra numbers in first part should show error message - client.setValue('#field-input--postcode', 'SE 134 7TP'); - client.expect.element('div#field-error--postcode > span').text.to.equal('Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode with 3 numbers in second part should show error message - client.setValue('#field-input--postcode', 'SE1 777TP'); - client.expect.element('div#field-error--postcode > span').text.to.equal('Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode with 2 numbers in second part should show error message - client.setValue('#field-input--postcode', 'SE1 77TP'); - client.expect.element('div#field-error--postcode > span').text.to.equal('Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // postcode with special characters should show error message - client.setValue('#field-input--postcode', 'SE1@£7tp'); - client.expect.element('div#field-error--postcode > span').text.to.equal('Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // valid postcode with lower and uppercase characters should not show error message - client.setValue('#field-input--postcode', 'sE17tP'); - client.expect.element('div#field-error--postcode > span').text.to.equal('Please enter a valid UK postcode, using a space and capital letters'); - client.clearValue('#field-input--postcode'); - - // submit form with valid postcode but not entering address field should show error messages on address fields - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('button[type="submit"]'); - client.expect.element('div#field-error--addressDetails > span').text.to.equal('Please fill in your address'); - - // click enter address manually link to see the error messages - client.expect.element('a[aria-describedby=field-error--addressDetails]').text.to.equal('Or enter your address manually'); - client.click('a[aria-describedby=field-error--addressDetails]'); - client.expect.element('div#field-error--address1 > span').text.to.equal('Please fill in your address line 1'); - client.expect.element('div#field-error--town > span').text.to.equal('Please fill in your town/city'); - - // enter address fields with valid inputs should not show error messages - client.setValue('input#field-input--address1', 'COMIC RELIEF'); - client.assert.not.elementPresent('div#field-error--address1 > span'); - client.setValue('#field-input--town', 'LONDON'); - client.assert.not.elementPresent('div#field-error--town > span'); - - // submit the form once more should go to success page - client.click('button[type="submit"]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, -}; diff --git a/tests/feature/submit/erp.js b/tests/feature/submit/erp.js deleted file mode 100644 index c1e4183d..00000000 --- a/tests/feature/submit/erp.js +++ /dev/null @@ -1,63 +0,0 @@ -const { ErpNextTester } = require('@comicrelief/test-utils/ErpNextTester'); - -const erpNextTester = new ErpNextTester('', '', '', /* retries */ 20, /* sleep */ 10 * 1000); - -const faker = require('faker'); -const firstName = faker.name.firstName(); -const lastName = faker.name.lastName(); -const mobile = faker.phone.phoneNumber('07#########'); - -module.exports = { - - '@tags': ['regression', 'submit-erp'], - - '@disabled': true, - - 'ERP receives a complete giftaid submit': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.click('#field-label--giftaid') - .setValue('#field-input--mobile', mobile) - .setValue('#field-input--firstname', firstName) - .setValue('#field-input--lastname', lastName) - .setValue('#field-input--postcode', 'SE1 7TP') - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', '21 test road') - .setValue('#field-input--town', 'London') - .click('button[type=submit]') - .pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - `${firstName}!`); - - client.perform(async (done) => { - try{ - console.log('Fetching supporter from ERP'); - const supporter = await erpNextTester.findOne('Supporter', { filters: [{field: "first_name", value: firstName}, {field: "last_name", value: lastName}] }); - - const supporterId = supporter.name; - console.log('supporterId', supporterId); - client.assert.equal(supporter.first_name, firstName, 'firstName'); - client.assert.equal(supporter.last_name, lastName, 'lastName'); - - console.log('Fetching gift aid mandate from ERP'); - const giftaidMandate = await erpNextTester.findOne('Gift Aid Mandate', { - filters: [ - { - field: 'supporter', - value: supporterId, - }, - ], - }); - console.log('giftaidMandateId', giftaidMandate.name); - client.assert.equal(giftaidMandate.supporter, supporterId, 'supporterId'); - client.assert.equal(giftaidMandate.source, 'Giftaid Submit', 'Giftaid Submit'); - } catch(error) { - client.assert.fail(error); - } - done(); - }); - client.end(); - }, - -}; diff --git a/tests/feature/submit/error.js b/tests/feature/submit/error.js deleted file mode 100644 index b331c480..00000000 --- a/tests/feature/submit/error.js +++ /dev/null @@ -1,119 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'submitError'], - - 'Verify error messages on empty giftaid submission': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.click('button[type=submit]'); - client.assert.textContains('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox'); - client.assert.textContains('#field-error--mobile>span', 'Please fill in your mobile number'); - client.assert.textContains('#field-error--firstname>span', 'Please fill in your first name'); - client.assert.textContains('#field-error--lastname>span', 'Please fill in your last name'); - client.assert.textContains('#field-error--postcode>span', 'Please enter your postcode'); - client.assert.textContains('#field-error--addressDetails>span', 'Please fill in your address'); - client.click('a[aria-describedby=field-error--addressDetails]'); - client.assert.textContains('#field-error--address1>span', 'Please fill in your address line 1'); - client.assert.textContains('#field-error--town>span', 'Please fill in your town/city'); - client.end(); - }, - - 'Submit form without checking giftaid cliam should give error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('#postcode_button'); - client.click('#field-select--addressSelect'); - client.click('#field-select--addressSelect>option:nth-child(6)'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.containsText('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox'); - client.end(); - }, - - 'Submit form with empty mobile number should give error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('#postcode_button'); - client.click('#field-select--addressSelect'); - client.click('#field-select--addressSelect>option:nth-child(6)'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.textContains('#field-error--mobile>span', 'Please fill in your mobile number'); - client.end(); - }, - - 'Submit form with empty first name should scroll to firstname error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('#postcode_button'); - client.click('#field-select--addressSelect'); - client.click('#field-select--addressSelect>option:nth-child(6)'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.textContains('#field-error--firstname', 'Please fill in your first name'); - client.end(); - }, - - 'Submit form with empty last name should scroll to lastname error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('#postcode_button'); - client.click('#field-select--addressSelect'); - client.click('#field-select--addressSelect>option:nth-child(6)'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.textContains('#field-error--lastname', 'Please fill in your last name'); - client.end(); - }, - - 'Submit form with empty postcode should scroll to postcode error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.textContains('#field-error--postcode', 'Please enter your postcode'); - client.end(); - }, - - 'Submit form with empty town should scroll to town error message': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', '07123456789'); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('a[aria-describedby=field-error--addressDetails]'); - client.pause(200); - client.setValue('#field-input--address1', '21 test road'); - client.click('button[type=submit]'); - client.pause(2000); - client.expect.element('div > h1').text.to.not.equal('Sorry!'); - client.assert.textContains('#field-error--town', 'Please fill in your town/city'); - client.end(); - }, -}; diff --git a/tests/feature/submit/marketingPreferencesData.js b/tests/feature/submit/marketingPreferencesData.js deleted file mode 100644 index 67588a9f..00000000 --- a/tests/feature/submit/marketingPreferencesData.js +++ /dev/null @@ -1,113 +0,0 @@ -const axios = require('axios'); -const faker = require('faker'); - -const { - CONTACT_SERVICE_MARKETING_PREFERENCES_REPORTING_BASE_URL: reportingUrl, - CONTACT_SERVICE_REPORTING_API_KEY: apiKey, -} = process.env; - -const testData = { - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), - mobile: faker.phone.phoneNumber('07#########'), - phone: faker.phone.phoneNumber('0208#######'), - address1: faker.address.streetName(), - address2: faker.address.streetAddress(), - address3: faker.address.city(), - postcode: 'SE1 7TP', - town: faker.address.county(), - country: 'GB', -}; - -module.exports = { - - '@tags': ['sanity', 'submit', 'marketingPreferencesData'], - - 'Verify marketing preferences data': function (client) { - - const randomString = faker.lorem.word(5); - - const email = `giftaid-staging-${randomString}@email.sls.comicrelief.com`; - - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.click('#field-label--giftaid') - .setValue('#field-input--mobile', testData.mobile) - .setValue('#field-input--firstname', testData.firstName) - .setValue('#field-input--lastname', testData.lastName) - .setValue('#field-input--postcode', testData.postcode) - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', testData.address1) - .setValue('#field-input--address2', testData.address2) - .setValue('#field-input--address3', testData.address3) - .setValue('#field-input--town', testData.town); - - // marketing preferences - // email - client.waitForElementVisible('#field-wrapper--Email', 1000); - // yes for email - client.click('#field-wrapper--Email>div:nth-child(1)'); - client.assert.elementPresent('#field-input--email'); - client.setValue('#field-input--email', email); - - // yes for Post - client.waitForElementVisible('#field-wrapper--Post', 1000); - client.click('#field-wrapper--Post div:nth-child(1)'); - - // Phone - accepts both mobile & telephone numbers - client.waitForElementVisible('#field-wrapper--Phone', 1000); - - // Yes option - client.click('#field-wrapper--Phone div:nth-child(1)'); - client.setValue('input#field-input--phone', testData.phone); - - // SMS - client.waitForElementVisible('#field-wrapper--SMS', 1000); - client.click('#field-wrapper--SMS div:nth-child(1)'); - - // submit form - client.click('button[type=submit]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - `${testData.firstName}!`); - - // Wait for the data to be ingested - client.pause(30000); - - // get MP data - client.perform((done) => { - axios.get(`${reportingUrl}/marketing-preferences/${email}`, { headers: { 'x-api-key': apiKey } }) - .then((response) => { - const { data: { data } } = response; - - client.assert.equal(response.status, 200, '200 OK'); - client.assert.equal(data.campaign, 'RND23', 'campaignCode'); - client.assert.equal(data.firstname, testData.firstName, 'firstName'); - client.assert.equal(data.lastname, testData.lastName, 'lastName'); - client.assert.equal(data.email, email, 'email'); - client.assert.equal(data.phone, testData.phone, 'phone'); - client.assert.equal(data.mobile, testData.mobile, 'mobile'); - client.assert.equal(data.address1, testData.address1, 'address1'); - client.assert.equal(data.address2, testData.address2, 'address2'); - client.assert.equal(data.address3, testData.address3, 'address3'); - client.assert.equal(data.town, testData.town, 'town'); - client.assert.equal(data.country, testData.country, 'country'); - client.assert.equal(data.transsource, 'RND23_GiftAid', 'transsource'); - client.assert.equal(data.transsourceurl, process.env.BASE_URL, 'transsourceurl'); - client.assert.equal(data.transtype, 'prefs', 'transtype'); - client.assert.equal(data.permissionemail, '1', 'permissionemail'); - client.assert.equal(data.permissionphone, '1', 'permissionphone'); - client.assert.equal(data.permissionpost, '', 'permissionpost'); - client.assert.equal(data.permissionsms, '', 'permissionsms'); - done(); - }) - .catch((error) => { - console.log(error); - client.assert.fail(error.message); - done(); - }); - }); - client.end(); - }, -}; diff --git a/tests/feature/submit/marketingPreferencesValidation.js b/tests/feature/submit/marketingPreferencesValidation.js deleted file mode 100644 index 009c7bf2..00000000 --- a/tests/feature/submit/marketingPreferencesValidation.js +++ /dev/null @@ -1,160 +0,0 @@ -const faker = require('faker'); - -const mobile = faker.phone.phoneNumber('07#########'); -const telephone = faker.phone.phoneNumber('0208#######'); - - -module.exports = { - - '@tags': ['sanity', 'submit', 'marketingPreferencesValidation'], - - 'Validate marketing prefs': function (client) { - - const email = 'giftaid-staging@email.sls.comicrelief.com'; - - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementPresent('#field-label--giftaid', 1000); - client.click('#field-label--giftaid'); - client.setValue('#field-input--mobile', mobile); - client.setValue('#field-input--firstname', 'test'); - client.setValue('#field-input--lastname', 'user'); - client.setValue('#field-input--postcode', 'SE1 7TP'); - client.click('a[aria-describedby=field-error--addressDetails]'); - client.waitForElementPresent('#field-input--address1', 1000); - client.setValue('#field-input--address1', '21 test road'); - client.setValue('#field-input--address2', 'High road'); - client.setValue('#field-input--address3', 'Waterloo'); - client.setValue('#field-input--town', 'London'); - - //email - client.waitForElementVisible('#field-wrapper--Email', 1000); - // No option - client.click('#field-wrapper--Email>div:nth-child(1)'); - client.assert.elementPresent('#field-input--email'); - // incomplete email should show error message - client.setValue('#field-input--email','test@.com'); - client.waitForElementPresent('#field-error--email', 1000); - client.expect.element('#field-error--email').text.to.equal('Please fill in a valid email address'); - // email with special chars should show error message - client.clearValue('#field-input--email'); - client.setValue('#field-input--email','test@%£$^*/.com'); - client.waitForElementPresent('#field-error--email', 2000); - client.expect.element('#field-error--email').text.to.equal('Please fill in a valid email address'); - // email without '@' should show error message - client.clearValue('#field-input--email'); - client.setValue('#field-input--email', 'email.example.com'); - client.waitForElementPresent('#field-error--email', 2000); - client.expect.element('#field-error--email').text.to.equal('Please fill in a valid email address'); - // long email should not show error message - client.clearValue('#field-input--email'); - client.setValue('#field-input--email', 'exampleexampleexampleexampleexample@exampleexampleexampleexampleexampleexample.com'); - client.assert.not.elementPresent('#field-error--email'); - // email with these special chars are allowed and should not show error message - client.clearValue('#field-input--email'); - client.setValue('#field-input--email', 'Test0-9!#$%&\'*+/=?^_{|}~-@comicrelief_9-8.com.uk'); - client.assert.not.elementPresent('#field-error--email'); - // email with these special chars are allowed and should not show error message - client.clearValue('#field-input--email'); - client.setValue('#field-input--email', 'Test0-9.%&\'+_-@comicrelief-9-8.com.uk'); - client.assert.not.elementPresent('#field-error--email'); - - // Phone - accepts both mobile & telephone numbers - client.waitForElementVisible('#field-wrapper--Phone', 2000); - client.click('#field-wrapper--Phone div:nth-child(1)'); - client.assert.elementPresent('input#field-input--phone'); - - // empty field - client.setValue('input#field-input--phone', '07123456789'); - client.clearValue('input#field-input--phone'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in your phone number'); - - // mobile number less than 11 digits shows error message - client.setValue('input#field-input--phone', '0712345678'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // mobile number more than 11 digits shows error message - client.setValue('input#field-input--phone', '071234567890'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // mobile number with spaces should show error - client.setValue('input#field-input--phone', '0712 345 6789'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number less than 11 digits shows error message - client.setValue('input#field-input--phone', '0208569424'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number more than 11 digits shows error message - client.setValue('input#field-input--phone', '020856942456'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number with spaces should show error - client.setValue('input#field-input--phone', '0208 569 4245'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number with alphabetical chars in between the number should show error - client.setValue('input#field-input--phone', '0208ab5694245'); - client.assert.elementPresent('div#field-error--phone > span'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // mobile number with alphabetical chars should show error - client.setValue('input#field-input--phone', '0780ab5694245'); - client.assert.elementPresent('div#field-error--phone > span'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number starting with alphabetical chars should show error - client.setValue('input#field-input--phone', 'abcv07805694245'); - client.assert.elementPresent('div#field-error--phone > span'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number ending with alphabetical chars should show error - client.setValue('input#field-input--phone', '07805694245dfef'); - client.assert.elementPresent('div#field-error--phone > span'); - client.expect.element('div#field-error--phone > span').text.to.equal('Please fill in a valid UK phone number, with no spaces'); - client.clearValue('input#field-input--phone'); - - // telephone number starting with '+' should not show error - client.setValue('input#field-input--phone', '+447805694245'); - client.assert.not.elementPresent('div#field-error--phone > span'); - client.clearValue('input#field-input--phone'); - - // telephone number starting with '+0044' should not show error - client.setValue('input#field-input--phone', '+00447805694245'); - client.assert.not.elementPresent('div#field-error--phone > span'); - client.clearValue('input#field-input--phone'); - - // telephone number starting with '0044' should not show error - client.setValue('input#field-input--phone', '00447805694245'); - client.assert.not.elementPresent('div#field-error--phone > span'); - client.clearValue('input#field-input--phone'); - - // clicking 'No' should not clear the value present in the phone field - client.clearValue('input#field-input--phone'); - client.setValue('input#field-input--phone', telephone); - client.assert.value('input#field-input--phone', telephone); - - // SMS - client.waitForElementVisible('#field-wrapper--SMS', 2000); - client.click('#field-wrapper--SMS div:nth-child(1) > label'); - - // enter valid email - client.setValue('#field-input--email', email); - client.assert.not.elementPresent('#field-error--email'); - client.waitForElementVisible('button[type="submit"]', 2000); - client.click('button[type="submit"]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 3000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, -}; diff --git a/tests/feature/submit/sorry.js b/tests/feature/submit/sorry.js deleted file mode 100644 index b1aee1ae..00000000 --- a/tests/feature/submit/sorry.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'submit', 'sorry'], - - 'Verify sorry page': function (client) { - client.url(process.env.BASE_URL + 'sorry').maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementVisible('div > h1', 1000); - client.expect.element('div > h1').text.to.equal('Sorry!'); - client.expect.element('div>p:nth-child(1)').text.to.equal('We’re really sorry, but with people across the UK rushing to Gift Aid their text donation, our site is a bit overwhelmed and has had to have a lie down.'); - client.end(); - }, -}; diff --git a/tests/feature/submit/success.js b/tests/feature/submit/success.js deleted file mode 100644 index d8e05dfc..00000000 --- a/tests/feature/submit/success.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'submit', 'success-page'], - - 'Ensure http redirects to https': function (client) { - // Assure that validation shows when no input is submitted - client - .url(process.env.BASE_URL.replace('https', 'http')) - .pause(500); - - client.url((result) => { - client.assert.ok(result.value.indexOf('https') !== -1); - }); - - client.end(); - }, - - 'Ensure direct access to giftaid success page redirects to main giftaid homepage': function (client) { - client.url(process.env.BASE_URL + 'success').maximizeWindow().waitForElementVisible('body', 1000); - client.expect.element('h1[class=giftaid-title]').text.to.equal('Giftaid it'); - client.assert.elementPresent('#field-label--giftaid'); - client.assert.elementPresent('#field-input--mobile'); - client.assert.not.elementPresent('div.success-wrapper--inner>h1'); - client.end(); - }, -}; diff --git a/tests/feature/submit/validSubmission.js b/tests/feature/submit/validSubmission.js deleted file mode 100644 index a3d4b244..00000000 --- a/tests/feature/submit/validSubmission.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'submit', 'submit-validSubmission'], - - 'User submits giftaid without marketing preferences selection': function (client) { - client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000); - client.page.form().fillForm(client); - client.click('button[type=submit]'); - client.pause(5000); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, - - 'User completes main giftaid journey from link with token': function (client) { - client.url(process.env.BASE_URL + 'uX8R5SzcKfk=').maximizeWindow().waitForElementVisible('body', 1000); - client.page.form().fillFormPrefilledMobile(client); - client.waitForElementVisible('div > h1', 2000); - client.expect.element('div > h1').text.to.equal('Thank you,\n' + - 'test!'); - client.end(); - }, -}; diff --git a/tests/feature/update/erp.js b/tests/feature/update/erp.js deleted file mode 100644 index 0c1a76de..00000000 --- a/tests/feature/update/erp.js +++ /dev/null @@ -1,127 +0,0 @@ -const { ErpNextTester } = require('@comicrelief/test-utils/ErpNextTester'); - -const erpNextTester = new ErpNextTester('', '', '', /* retries */ 20, /* sleep */ 10 * 1000); - -const tests = {}; -[false, true].forEach((giftaid) => { - tests[`ERP receives a complete giftaid update (${!giftaid ? 'un' : ''}claim)`] = function (client) { - const donationType = 'single'; - const randomString = client.page.form().randomString(); - const lastName = 'user' + randomString; - const email = `donate-staging-${randomString}@email.sls.comicrelief.com`; - let transactionId; - let supporterId; - client.page.form().fillToPayment( - client, - 'https://donation-staging.spa.comicrelief.com/?providers=stripe&DISABLE_AB_TEST=1', - '10', - donationType, - !giftaid, // set transaction with a different giftaid option initially. - { lastName, email }, - ); - client.page.form().fillCardForm(client, '4242424242424242', '09 / 24', '123'); - - client.pause(5000); - - client.page.form().submitMarketingPreferences(client); - - client.waitForElementVisible('.inner-content--success h1', 3500); - - client.expect.element('.inner-content--success h1').text.to.equal('Thank you, test!'); - - // Fetch the transaction id from the success page - client.getText('p.success-transactionsid', function (result) { - transactionId = result.value.replace('Transaction ID: ', ''); - console.log('transactionId:', transactionId); - }); - - client.perform(async (done) => { - try { - console.log('Fetching donation from ERP', transactionId); - const donation = await erpNextTester.get('Donation', transactionId); - - client.assert.equal(donation.id, transactionId, 'transactionId'); - client.assert.equal(donation.amount, 10, 'amount'); - // comment out this line until issue is fixed with types - // client.assert.equal(donation.type, 'Online', 'type'); - client.assert.equal(donation.status, 'Complete', 'status'); - client.assert.equal(donation.provider, 'Stripe', 'provider'); - client.assert.equal(donation.cart_id, 'DEFAULT-COMICRELIEF', 'cartId'); - - console.log('Fetching supporter from ERP'); - const supporter = await erpNextTester.findOne('Supporter', { filters: [{field: "first_name", value: 'test'}, {field: "last_name", value: lastName}] }); - - supporterId = supporter.name; - console.log('supporterId', supporterId); - client.assert.equal(supporter.first_name, 'test', 'firstName'); - client.assert.equal(supporter.last_name, lastName, 'lastName'); - - client.url(process.env.BASE_URL + 'update').maximizeWindow().waitForElementVisible('body', 1000); - client.setValue('#field-input--transactionId', transactionId); - client.setValue('#field-input--firstname', 'test') - .setValue('#field-input--lastname', lastName) - .setValue('#field-input--email', email) - .setValue('#field-input--postcode', 'SE1 7TP') - .click('a[aria-describedby=field-error--addressDetails]') - .pause(200) - .setValue('#field-input--address1', '21 test road') - .setValue('#field-input--town', 'London') - .click(`#giftAidClaimChoice>div:nth-child(${giftaid ? 2 : 3})>label`) - .click('button[type=submit]'); - client.waitForElementVisible('div.success-wrapper--inner>div>h1', 3000); - const thankYouMessage = giftaid ? 'Thank you,\ntest!' : 'Thanks for letting us know'; - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal(thankYouMessage); - - console.log('Fetching giftaid mandate from ERP'); - const giftaidMandate = await erpNextTester.findOne('Gift Aid Mandate', { - filters: [ - { - field: 'supporter', - value: supporterId, - }, - { - field: 'source', - value: 'Giftaid Update', // to avoid fetching original mandate - }, - ], - }); - console.log('giftaidMandateId', giftaidMandate.name); - client.assert.equal(giftaidMandate.supporter, supporterId, 'supporterId'); - - console.log('Fetching gift aid claim id from ERP'); - const giftaidClaim = await erpNextTester.findOne('Gift Aid Claim', { - filters: [ - { - field: 'supporter', - value: supporterId, - }, - { - field: 'mandate', - value: giftaidMandate.name, - }, - { - field: 'donation', - value: transactionId, - }, - ], - }); - console.log('giftaidClaimId', giftaidClaim.name); - client.assert.equal(giftaidClaim.claimed, giftaid, 'giftaid'); - } catch(error) { - client.assert.fail(error); - } - done(); - }); - client.end(); - } -}); - -module.exports = { - - '@tags': ['regression', 'update-erp'], - - '@disabled': true, - - ...tests, - -}; diff --git a/tests/feature/update/error.js b/tests/feature/update/error.js deleted file mode 100644 index e96799de..00000000 --- a/tests/feature/update/error.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'update', 'updateError'], - - 'Verify error messages on Giftaid update form': function (client) { - client.url(process.env.BASE_URL + 'update').maximizeWindow().waitForElementVisible('body', 1000); - client - .click('button[type=submit]') - .assert.containsText('#field-error--transactionId>span', 'Please fill in your transaction id') - .assert.containsText('#field-error--firstname>span', 'Please fill in your first name') - .assert.containsText('#field-error--lastname>span', 'Please fill in your last name') - .assert.containsText('#field-error--postcode>span', 'Please enter your postcode') - .assert.containsText('#field-error--addressDetails>span', 'Please fill in your address') - .click('a[aria-describedby=field-error--addressDetails]') - .assert.containsText('#field-error--address1>span', 'Please fill in your address line 1') - .assert.containsText('#field-error--town>span', 'Please fill in your town/city') - .assert.containsText('#field-error--giftAidClaimChoice>span','This field is required'); - client.end(); - }, -}; diff --git a/tests/feature/update/sorry.js b/tests/feature/update/sorry.js deleted file mode 100644 index 28c932b8..00000000 --- a/tests/feature/update/sorry.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'update', 'updateSorry'], - - 'Verify update sorry page': function (client) { - client.url(process.env.BASE_URL + 'update/sorry').maximizeWindow().waitForElementVisible('body', 1000); - client.waitForElementVisible('div > h1', 1000); - client.expect.element('div > h1').text.to.equal('Sorry!'); - client.expect.element('div>p:nth-child(1)').text.to.equal('We aren’t able to process your Gift Aid update request at the moment.'); - client.end(); - }, -}; diff --git a/tests/feature/update/success.js b/tests/feature/update/success.js deleted file mode 100644 index c3d8f150..00000000 --- a/tests/feature/update/success.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - - '@tags': ['sanity', 'update', 'success-page'], - - 'Ensure direct access to giftaid update success page redirects to giftaid update homepage': function (client) { - client.url(process.env.BASE_URL + 'update/success').maximizeWindow().waitForElementVisible('body', 1000); - client.expect.element('h1[class=giftaid-title]').text.to.equal('Giftaid it'); - client.assert.elementPresent('#field-input--transactionId'); - client.assert.elementPresent('#field-input--email'); - client.assert.not.elementPresent('div.success-wrapper--inner>h1'); - client.end(); - } -}; diff --git a/tests/feature/update/validSubmission.js b/tests/feature/update/validSubmission.js deleted file mode 100644 index d9ecb769..00000000 --- a/tests/feature/update/validSubmission.js +++ /dev/null @@ -1,95 +0,0 @@ -const { v4: uuidv4 } = require('uuid'); - -module.exports = { - - '@tags': ['sanity', 'update', 'validSubmission'], - - 'Verify all elements present on giftaid update': function (client) { - client.url(process.env.BASE_URL + 'update').maximizeWindow().waitForElementVisible('body', 1000); - client - .waitForElementVisible('body', 1000) - .assert.elementPresent('#field-input--transactionId') - .assert.elementPresent('#field-input--firstname') - .assert.elementPresent('#field-input--lastname') - .assert.elementPresent('#field-input--postcode') - .assert.elementPresent('#postcode_button') - .assert.elementPresent('#field-input--address1') - .assert.elementPresent('#field-input--address2') - .assert.elementPresent('#field-input--address3') - .assert.elementPresent('#field-input--town') - .assert.elementPresent('#field-select--country') - .assert.elementPresent('#form > button') - .assert.elementPresent('.form__row--just-in-time-block>div>a'); - client.end(); - }, - - 'User completes giftaid update journey': function (client) { - const transactionId = uuidv4(); - console.log('transactionId is:', transactionId); - client.url(process.env.BASE_URL + 'update').maximizeWindow().waitForElementVisible('body', 1000); - client.setValue('#field-input--transactionId', transactionId); - client.page.giftaid().fillFormUpdateYes(client); - client.waitForElementVisible('div.success-wrapper--inner>div>h1', 1000); - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal('Thank you,\n' + 'test!'); - client.end(); - }, - - 'User completes giftaid update journey from sms': function (client) { - const transactionId = uuidv4(); - console.log('transactionId is:', transactionId); - - //sms - client.url(process.env.BASE_URL + `update/${transactionId}`).maximizeWindow().waitForElementVisible('body', 1000); - client.expect.element('p.text-align-centre.transaction-id').text.to.equal(`Transaction ID: ${transactionId}`); - client.click('#donationType>div:nth-child(2)>label'); - client.page.giftaid().fillFormUpdateYes(client); - client.waitForElementVisible('div.success-wrapper--inner>div>h1', 1000); - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal('Thank you,\n' + 'test!'); - client.end(); - }, - - 'User completes giftaid update journey from online': function (client) { - const transactionId = uuidv4(); - console.log('transactionId is:', transactionId); - - //online - client.url(process.env.BASE_URL + `update/${transactionId}`).maximizeWindow().waitForElementVisible('body', 1000); - client.expect.element('p.text-align-centre.transaction-id').text.to.equal(`Transaction ID: ${transactionId}`); - client.click('#donationType>div:nth-child(3)>label'); - client.page.giftaid().fillFormUpdateYes(client); - client.waitForElementVisible('div.success-wrapper--inner > div > h1', 1000); - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal('Thank you,\n' + 'test!'); - client.end(); - }, - - 'User completes giftaid update journey from call centre': function (client) { - const transactionId = uuidv4(); - console.log('transactionId is:', transactionId); - - //call centre - client.url(process.env.BASE_URL + `update/${transactionId}`).maximizeWindow().waitForElementVisible('body', 1000); - client.expect.element('p.text-align-centre.transaction-id').text.to.equal(`Transaction ID: ${transactionId}`); - client.click('#donationType>div:nth-child(4)>label'); - client.page.giftaid().fillFormUpdateYes(client); - client.waitForElementVisible('div.success-wrapper--inner>div>h1', 1000); - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal('Thank you,\n' + 'test!'); - client.end(); - }, - - 'User selects "no" for giftaid update declaration': function (client) { - client.url(process.env.BASE_URL + 'update').maximizeWindow().waitForElementVisible('body', 1000); - client.setValue('#field-input--transactionId', 'D-BEX1501'); - client.page.giftaid().fillFormUpdateNo(client); - client.waitForElementVisible('div.success-wrapper--inner>div>h1', 1000); - client.expect.element('div.success-wrapper--inner>div>h1').text.to.equal('Thanks for letting us know'); - client.end(); - }, - - 'Verify url error message on Giftaid update form with invalid UUID': function (client) { - client.url(process.env.BASE_URL + 'update/test').maximizeWindow().waitForElementVisible('body', 1000); - client.click('#donationType>div:nth-child(3)>label'); - client.page.giftaid().fillFormUpdateYes(client); - client.assert.containsText('#field-error--urlTransID>span', 'This transaction ID doesn\'t seem to be valid, please check your donation confirmation email or letter'); - client.end(); - }, -}; diff --git a/tests/test-urls.json b/tests/test-urls.json deleted file mode 100644 index f2db189c..00000000 --- a/tests/test-urls.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "homepage": "/", - "update": "/update" -}