Skip to content

Commit

Permalink
chore: add E2E test for general setting upgrade links
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed May 27, 2024
1 parent 4076792 commit 72a168a
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions tests/e2e/specs/upsell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
* WordPress dependencies
*/
import { test, expect } from '@wordpress/e2e-test-utils-playwright';
import {tryCloseTourModal, deleteAllFeedImports} from '../utils';
import { tryCloseTourModal, deleteAllFeedImports } from '../utils';

test.describe( 'Upsell', () => {

const FEED_URL = 'https://s3.amazonaws.com/verti-utils/sample-feed-import.xml';

test.beforeEach( async ( { requestUtils, page } ) => {
await deleteAllFeedImports( requestUtils );
await requestUtils.deleteAllPosts();
Expand All @@ -21,10 +18,10 @@ test.describe( 'Upsell', () => {
await expect( bannerLinkElement ).toBeVisible();

const bannerLink = new URL( await bannerLinkElement.getAttribute('href') );
expect( bannerLink.host ).toBe('themeisle.com');
expect( bannerLink.searchParams.get('utm_source') ).toBe('wpadmin');
expect( bannerLink.searchParams.get('utm_medium') ).toBe('import-screen');
expect( bannerLink.searchParams.get('utm_content') ).toBe('feedzy-rss-feeds');
expect( bannerLink.host ).toBe( 'themeisle.com' );
expect( bannerLink.searchParams.get( 'utm_source' ) ).toBe( 'wpadmin');
expect( bannerLink.searchParams.get( 'utm_medium' ) ).toBe('import-screen');
expect( bannerLink.searchParams.get( 'utm_content' ) ).toBe('feedzy-rss-feeds');
});

test( 'filters', async({ editor, page }) => {
Expand All @@ -38,15 +35,15 @@ test.describe( 'Upsell', () => {

const filterByKeywordAlert = await filtersTab.locator('.upgrade-alert').first();
let upgradeLink = new URL( await filterByKeywordAlert.locator('a').first().getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('filter-keyword');
expect( upgradeLink.searchParams.get( 'utm_campaign' ) ).toBe('filter-keyword');

const excludeItemsAlert = await filtersTab.locator('.upgrade-alert').nth(1);
upgradeLink = new URL( await excludeItemsAlert.locator('a').first().getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('exclude-items');
expect( upgradeLink.searchParams.get( 'utm_campaign' ) ).toBe('exclude-items');

const filterByTimeRangeAlert = await filtersTab.locator('.upgrade-alert').nth(2);
upgradeLink = new URL( await filterByTimeRangeAlert.locator('a').first().getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('filter-time-range');
expect( upgradeLink.searchParams.get( 'utm_campaign' ) ).toBe('filter-time-range');
} );

test( 'map content', async({ editor, page }) => {
Expand All @@ -57,4 +54,20 @@ test.describe( 'Upsell', () => {
const upgradeLink = new URL( await magicTagsUpsell.getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('magictags');
} );

test( 'general settings', async({ editor, page }) => {
await page.getByRole('button', { name: 'Step 4 General feed settings' }).click({ force: true });

await page.locator('#feedzy_delete_days').hover({ force: true });
let upgradeAlert = page.locator('#feedzy-import-form').getByRole('link', { name: 'upgrading to Feedzy Pro', exact: true });
let upgradeLink = new URL( await upgradeAlert.getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('auto-delete');

await page.locator('.fz-form-group:has( #feed-post-default-thumbnail )').hover({ force: true });
upgradeAlert = page.locator('#feedzy-import-form').getByRole('link', { name: 'upgrading to Feedzy Pro', exact: true })
upgradeLink = new URL( await upgradeAlert.getAttribute('href') );
expect( upgradeLink.searchParams.get('utm_campaign') ).toBe('fallback-imaget'); // The type is intentional.

await page.waitForTimeout(1000);
} );
});

0 comments on commit 72a168a

Please sign in to comment.