-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4153 from dolbi-digital/WV-694-Automate-negative-…
…scenarious-for-Donate-page Added negative scenarious, used eslint to improve code
- Loading branch information
Showing
2 changed files
with
122 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import { driver, expect, $ } from '@wdio/globals'; | ||
import { driver, expect } from '@wdio/globals'; | ||
import ReadyPage from '../page_objects/ready.page'; | ||
import DonatePage from '../page_objects/donate.page'; | ||
|
||
/* eslint-disable no-undef | ||
This eslint-disable turns off warnings for describe() and it() | ||
We don't need those warnings, because describe() and it() are available at runtime | ||
Refer to https://webdriver.io/docs/pageobjects for guidance */ | ||
/* eslint-disable no-undef */ | ||
// This eslint-disable turns off warnings for describe() and it() | ||
// We don't need those warnings, because describe() and it() are available at runtime | ||
// https://webdriver.io/docs/pageobjects | ||
|
||
var fillDonationForm = async (name, lastName, email) => { | ||
const requiredError = 'This field is required'; | ||
const validEmailError = 'Please enter a valid email address'; | ||
const validEmail = '[email protected]'; | ||
|
||
const fillDonationForm = async (name, lastName, email) => { | ||
await DonatePage.getFirstName().setValue(name); | ||
await DonatePage.getLasttName().setValue(lastName); | ||
await DonatePage.getEmail().setValue(email); | ||
(await DonatePage.getNextButton()).click(); | ||
}; | ||
|
||
async function nextButtonScrollIntoView() { | ||
async function nextButtonScrollIntoView () { | ||
const nextButton = await DonatePage.getNextButton(); | ||
await nextButton.scrollIntoView(); | ||
await expect(nextButton).toBeDisplayed(); | ||
await nextButton.click(); | ||
} | ||
|
||
var checkAmounts = async (interval, processingFee, fullAmount, withoutFeeAmount, amountLabel) => { | ||
const elementText = await DonatePage.getIntervalLabel().getText(); | ||
const amount = await amountLabel; | ||
expect(elementText.includes(interval)); | ||
await expect(DonatePage.getProcessingFeeLabel()).toHaveText(processingFee); | ||
await expect(amount).toHaveText(fullAmount); | ||
driver.pause(3000); | ||
(await DonatePage.getOptionalFeesCheckbox()).click(); | ||
driver.pause(3000); | ||
await expect(amount).toHaveText(withoutFeeAmount); | ||
|
||
(await DonatePage.getDonateButton()).click(); | ||
await expect(driver).toHaveTitle('Log in to your PayPal account'); | ||
}; | ||
const checkAmounts = async (interval, processingFee, fullAmount, withoutFeeAmount, amountLabel) => { | ||
const elementText = await DonatePage.getIntervalLabel().getText(); | ||
const amount = await amountLabel; | ||
expect(elementText.includes(interval)); | ||
await expect(DonatePage.getProcessingFeeLabel()).toHaveText(processingFee); | ||
await expect(amount).toHaveText(fullAmount); | ||
(await DonatePage.getOptionalFeesCheckbox()).click(); | ||
await expect(amount).toHaveText(withoutFeeAmount); | ||
|
||
(await DonatePage.getDonateButton()).click(); | ||
await expect(driver).toHaveTitle('Log in to your PayPal account'); | ||
}; | ||
|
||
describe('DonatePage', () => { | ||
|
||
// Donate_001 | ||
it('verifyDonatePageAfterClickDonateLinks', async () => { | ||
await ReadyPage.load(); | ||
|
@@ -55,20 +55,20 @@ describe('DonatePage', () => { | |
it('verifyTextAndDonationWidget', async () => { | ||
await DonatePage.load(); | ||
await expect(DonatePage.getDonateHeader()).toHaveText('Want more Americans to vote?'); | ||
await expect(DonatePage.getFirstParagraph()).toHaveText('Thank you for being a voter! For every $10 donated, ' | ||
+ 'you help 50 Americans be voters too.'); | ||
await expect(DonatePage.getSecondParagraph()).toHaveText('Our budgets are small,so every tax-deductible ' | ||
+ 'donation helps us reach more voters.' | ||
+ '\n\n' | ||
+ 'Expenses include server costs ($600 - $2,500 per ' | ||
+ 'month), data fees (~$40,000 per year), collaboration tools and other hard costs.'); | ||
await expect(DonatePage.getFirstParagraph()).toHaveText('Thank you for being a voter! For every $10 donated, ' + | ||
'you help 50 Americans be voters too.'); | ||
await expect(DonatePage.getSecondParagraph()).toHaveText('Our budgets are small,so every tax-deductible ' + | ||
'donation helps us reach more voters.' + | ||
'\n\n' + | ||
'Expenses include server costs ($600 - $2,500 per ' + | ||
'month), data fees (~$40,000 per year), collaboration tools and other hard costs.'); | ||
}); | ||
|
||
// Donate_003 | ||
it('verifyNonProfitExplorerLink', async () => { | ||
await DonatePage.load(); | ||
const element = await DonatePage.getTextLink(); | ||
await driver.execute("arguments[0].click();", element); | ||
await driver.execute('arguments[0].click();', element); | ||
const allWindowHandles = await driver.getWindowHandles(); | ||
await driver.switchToWindow(allWindowHandles[allWindowHandles.length - 1]); | ||
await expect(driver).toHaveTitle('We Vote - Nonprofit Explorer - ProPublica'); | ||
|
@@ -81,11 +81,11 @@ describe('DonatePage', () => { | |
|
||
(await DonatePage.getOneTimeButton()).click(); | ||
(await DonatePage.getDonateAmountButton(120)).click(); | ||
|
||
const checkbox = await DonatePage.getCommentCheckbox(); | ||
const isChecked = await checkbox.isSelected(); | ||
if (!isChecked) { | ||
await checkbox.click(); | ||
await checkbox.click(); | ||
} | ||
|
||
await DonatePage.getCommentField().setValue('Hello, WeVote!'); | ||
|
@@ -95,7 +95,7 @@ describe('DonatePage', () => { | |
await nextButtonScrollIntoView(); | ||
|
||
await DonatePage.getPayPalButton().click(); | ||
await expect(DonatePage.getOneTimeLabel()).toHaveText("One-time"); | ||
await expect(DonatePage.getOneTimeLabel()).toHaveText('One-time'); | ||
await expect(DonatePage.getOneTimeAmount()).toHaveText('$125.17'); | ||
|
||
await driver.switchToFrame(await DonatePage.getPayPalIFrame()); | ||
|
@@ -131,7 +131,7 @@ describe('DonatePage', () => { | |
const checkbox = await DonatePage.getDisplayDonationCheckbox(); | ||
const isChecked = await checkbox.isSelected(); | ||
if (!isChecked) { | ||
await checkbox.click(); | ||
await checkbox.click(); | ||
} | ||
|
||
await nextButtonScrollIntoView(); | ||
|
@@ -186,10 +186,74 @@ describe('DonatePage', () => { | |
(await DonatePage.getDisplayFirstNameCheckbox()).click(); | ||
await expect(DonatePage.getHideDonationAmountCheckbox()).not.toBeChecked(); | ||
(await DonatePage.getHideDonationAmountCheckbox()).click(); | ||
|
||
await nextButtonScrollIntoView(); | ||
await fillDonationForm('Dmytro', 'Dolbilov', '[email protected]'); | ||
await checkAmounts('Anually', '$12.16', '$312.16', '$300', DonatePage.getAnnuallyAmount()); | ||
}); | ||
|
||
|
||
// Donate_008 | ||
it('verifyEmptyFieldsErrorMessagesFirstPage', async () => { | ||
await DonatePage.load(); | ||
await driver.switchToFrame(await DonatePage.getDonorBoxIFrame()); | ||
|
||
(await DonatePage.getOneTimeButton()).click(); | ||
(await DonatePage.getCustomAmountField()).click(); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getCustomAmountError()).toHaveText('Please select or enter an amount'); | ||
(await DonatePage.getCustomAmountField()).setValue(4.99); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getCustomAmountError()).toHaveText('Please enter an amount of at least $5'); | ||
(await DonatePage.getDedicateMyDonationCheckbox()).click(); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getFieldRequiredError(1)).toHaveText(requiredError); | ||
await expect(DonatePage.getFieldRequiredError(2)).toHaveText(requiredError); | ||
(await DonatePage.getCommentCheckbox()).click(); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getFieldRequiredError(3)).toHaveText(requiredError); | ||
}); | ||
|
||
// Donate_009 | ||
it('verifyFirstLastEmailEmptyFields', async () => { | ||
await DonatePage.load(); | ||
await driver.switchToFrame(await DonatePage.getDonorBoxIFrame()); | ||
|
||
await nextButtonScrollIntoView(); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getFieldRequiredError(1)).toHaveText(requiredError); | ||
await expect(DonatePage.getFieldRequiredError(2)).toHaveText(requiredError); | ||
await expect(DonatePage.getFieldRequiredError(3)).toHaveText(requiredError); | ||
await expect(DonatePage.getFixErrors()).toHaveText('Please fix the errors above.'); | ||
}); | ||
|
||
// Donate_010 | ||
it('verifyValidEmail', async () => { | ||
await DonatePage.load(); | ||
await driver.switchToFrame(await DonatePage.getDonorBoxIFrame()); | ||
|
||
(await DonatePage.getDedicateMyDonationCheckbox()).click(); | ||
(await DonatePage.getRecipientEmailField()).setValue(`${validEmail}1`); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getFieldRequiredError(2)).toHaveText(validEmailError); | ||
(await DonatePage.getHonoreeNameField()).setValue('John Wick'); | ||
(await DonatePage.getRecipientEmailField()).setValue(validEmail); | ||
await nextButtonScrollIntoView(); | ||
(await DonatePage.getEmail()).setValue(validEmail.replace('@', '')); | ||
await nextButtonScrollIntoView(); | ||
await expect(DonatePage.getFieldRequiredError(1)).toHaveText(validEmailError); | ||
await expect(DonatePage.getFixErrors()).toHaveText('Please fix the errors above.'); | ||
}); | ||
|
||
// Donate_011 https://wevoteusa.atlassian.net/browse/WV-699 Uncomment when fixed | ||
it('verifyPostalAddress', async () => { | ||
await DonatePage.load(); | ||
await driver.switchToFrame(await DonatePage.getDonorBoxIFrame()); | ||
|
||
(await DonatePage.getDedicateMyDonationCheckbox()).click(); | ||
const postalRadiobox = await DonatePage.getPostalMailRadioButton(); | ||
await postalRadiobox.scrollIntoView(); | ||
await postalRadiobox.click(); | ||
await nextButtonScrollIntoView(); | ||
// await expect(DonatePage.getFieldRequiredError(2)).toHaveText(requiredError); | ||
}); | ||
}); |