Skip to content

Commit

Permalink
Set up WooCommerce on settings page before running test
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Apr 27, 2022
1 parent 87b8f74 commit 17ea300
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Shopify settings', () => {
text: 'None',
});

await expect(page).toClick('li', { text: 'Shopify' });
await expect(page).toClick('[role="listbox"] li', { text: 'Shopify' });
await expect(page).toMatchElement(shoppingProviderDropdownSelector, {
text: 'Shopify',
});
Expand All @@ -49,7 +49,7 @@ describe('Shopify settings', () => {
await expect(page).toClick(shoppingProviderDropdownSelector, {
text: 'Shopify',
});
await expect(page).toClick('li', { text: 'None' });
await expect(page).toClick('[role="listbox"] li', { text: 'None' });
await expect(page).toMatchElement(shoppingProviderDropdownSelector, {
text: 'None',
});
Expand Down
34 changes: 33 additions & 1 deletion packages/e2e-tests/src/specs/editor/shopping/woocommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
minWPVersionRequired,
previewStory,
withPlugin,
visitSettings,
} from '@web-stories-wp/e2e-test-utils';

/**
Expand All @@ -32,9 +33,20 @@ import {
import * as schema from './schema.json';

async function insertProduct(product) {
await expect(page).toClick('[aria-controls="library-pane-shopping"]');
// Switch to the Products tab and wait for initial list of products to be fetched.
await Promise.all([
page.waitForResponse(
(response) =>
response.url().includes('web-stories/v1/products') &&
response.status() === 200
),
expect(page).toClick('[aria-controls="library-pane-shopping"]'),
]);

// This clicks on the Product dropdown and waits for the dropdown menu to open.
await expect(page).toClick('[aria-label="Product"]');
await page.waitForSelector('[aria-label="Search"]');

await page.type('[aria-label="Search"]', product);
await page.keyboard.press('ArrowDown');
await page.keyboard.press('Enter');
Expand All @@ -48,6 +60,26 @@ describe('Shopping', () => {
describe('WooCommerce', () => {
withPlugin('woocommerce');

beforeAll(async () => {
await visitSettings();

// Small trick to ensure we scroll to this input.
const shoppingProviderDropdown = await page.$(
'button[aria-label="Shopping provider"]'
);
await shoppingProviderDropdown.focus();

// eslint-disable-next-line jest/no-standalone-expect
await expect(page).toClick('button[aria-label="Shopping provider"]');
// eslint-disable-next-line jest/no-standalone-expect
await expect(page).toClick('[role="listbox"] li', {
text: 'WooCommerce',
});

// eslint-disable-next-line jest/no-standalone-expect
await expect(page).toMatch('Setting saved.');
});

describe('Schema Validation', () => {
it('should match a valid schema', async () => {
await createNewStory();
Expand Down

0 comments on commit 17ea300

Please sign in to comment.