Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E tests: Onboarding Step 4 - Complete your campaign #2105

Merged
merged 12 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/e2e/specs/gtag-events/gtag-events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test.describe( 'GTag events', () => {
await page.goto( 'shop?orderby=date' );
const addToCart = `[data-product_id="${ simpleProductID }"]`;
const addToCartButton = await page.locator( addToCart ).first();
addToCartButton.click();
await addToCartButton.click();
await expect( addToCartButton.getByText( '1 in cart' ) ).toBeVisible();

await event.then( ( request ) => {
Expand Down
30 changes: 11 additions & 19 deletions tests/e2e/specs/setup-mc/step-1-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/
import SetUpAccountsPage from '../../utils/pages/setup-mc/step-1-set-up-accounts';
import { LOAD_STATE } from '../../utils/constants';
import {
getFAQPanelTitle,
getFAQPanelRow,
checkFAQExpandable,
} from '../../utils/page';

/**
* External dependencies
Expand Down Expand Up @@ -66,30 +71,17 @@ test.describe( 'Set up accounts', () => {

test.describe( 'FAQ panels', () => {
test( 'should see two questions in FAQ', async () => {
const faqTitles = setUpAccountsPage.getFAQPanelTitle();
const faqTitles = getFAQPanelTitle( page );
await expect( faqTitles ).toHaveCount( 2 );
} );

test( 'should not see FAQ rows when FAQ titles are not clicked', async () => {
const faqRows = setUpAccountsPage.getFAQPanelRow();
const faqRows = getFAQPanelRow( page );
await expect( faqRows ).toHaveCount( 0 );
} );

test( 'should see one FAQ rows when the first FAQ title is clicked', async () => {
const faqTitle = setUpAccountsPage.getFAQPanelTitle().first();
await faqTitle.click();
const faqRow = setUpAccountsPage.getFAQPanelRow();
await expect( faqRow ).toBeVisible();
} );

test( 'should see two FAQ rows when two FAQ titles are clicked', async () => {
const faqTitle2 = setUpAccountsPage.getFAQPanelTitle().nth( 1 );
await faqTitle2.click();
const faqRows = setUpAccountsPage.getFAQPanelRow();
await expect( faqRows ).toHaveCount( 2 );
for ( const faqRow of await faqRows.all() ) {
await expect( faqRow ).toBeVisible();
}
test( 'should see FAQ rows when all FAQ titles are clicked', async () => {
await checkFAQExpandable( page );
} );
} );

Expand Down Expand Up @@ -306,7 +298,7 @@ test.describe( 'Set up accounts', () => {
setUpAccountsPage.mockMCNotConnected(),
] );

await setUpAccountsPage.goto();
await page.reload();

// Mock Merchant Center create accounts
await setUpAccountsPage.mockMCCreateAccountWebsiteClaimed(
Expand Down Expand Up @@ -576,7 +568,7 @@ test.describe( 'Set up accounts', () => {
await expect( link ).toBeVisible();
await expect( link ).toHaveAttribute( 'href', cssPartersLink );

const faqTitle2 = setUpAccountsPage.getFAQPanelTitle().nth( 1 );
const faqTitle2 = getFAQPanelTitle( page ).nth( 1 );
await faqTitle2.click();
const linkInFAQ = setUpAccountsPage.getCSSPartnersLink(
'Please find more information here'
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/specs/setup-mc/step-2-product-listings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
* Internal dependencies
*/
import ProductListingsPage from '../../utils/pages/setup-mc/step-2-product-listings';
import {
getCountryInputSearchBoxContainer,
getCountryInputSearchBox,
removeCountryFromSearchBox,
selectCountryFromSearchBox,
} from '../../utils/page';

/**
* External dependencies
Expand Down Expand Up @@ -104,7 +110,7 @@ test.describe( 'Configure product listings', () => {

test( 'should see US but should not see UK in the country search box', async () => {
const countrySearchBoxContainer =
productListingsPage.getCountryInputSearchBoxContainer();
getCountryInputSearchBoxContainer( page );
await expect( countrySearchBoxContainer ).toContainText(
'United States (US)'
);
Expand All @@ -115,7 +121,7 @@ test.describe( 'Configure product listings', () => {

test( 'should see UK in the country search box and send the target audience POST request after selecting UK', async () => {
const countrySearchBoxContainer =
productListingsPage.getCountryInputSearchBoxContainer();
getCountryInputSearchBoxContainer( page );
await expect( countrySearchBoxContainer ).not.toContainText(
'United Kingdom (UK)'
);
Expand All @@ -127,9 +133,7 @@ test.describe( 'Configure product listings', () => {
request.postDataJSON().countries.includes( 'GB' )
);

await productListingsPage.selectCountryFromSearchBox(
'United Kingdom (UK)'
);
await selectCountryFromSearchBox( page, 'United Kingdom (UK)' );

await expect( countrySearchBoxContainer ).toContainText(
'United Kingdom (UK)'
Expand All @@ -147,7 +151,7 @@ test.describe( 'Configure product listings', () => {
} );

test( 'should hide country search box after clicking "All countries"', async () => {
const countrySearchBox = productListingsPage.getCountryInputSearchBox();
const countrySearchBox = getCountryInputSearchBox( page );
await expect( countrySearchBox ).toBeVisible();
await productListingsPage.checkAllCountriesRadioButton();
await expect( countrySearchBox ).not.toBeVisible();
Expand All @@ -159,9 +163,7 @@ test.describe( 'Configure product listings', () => {
test( 'should still see "Tax rate (required for U.S. only)" even if deselect US when the default country is US', async () => {
const taxRateSection = productListingsPage.getTaxRateSection();
await expect( taxRateSection ).toBeVisible();
await productListingsPage.removeCountryFromSearchBox(
'United States (US)'
);
await removeCountryFromSearchBox( page, 'United States (US)' );
await expect( taxRateSection ).toBeVisible();
} );

Expand All @@ -178,9 +180,7 @@ test.describe( 'Configure product listings', () => {
const taxRateSection = productListingsPage.getTaxRateSection();
await expect( taxRateSection ).toBeVisible();

await productListingsPage.removeCountryFromSearchBox(
'United States (US)'
);
await removeCountryFromSearchBox( page, 'United States (US)' );

await expect( taxRateSection ).not.toBeVisible();
} );
Expand Down
Loading