Skip to content

Commit

Permalink
chore: import with chained actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jun 4, 2024
1 parent c6bf68d commit 8f8f8f0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tests/e2e/specs/feed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
tryCloseTourModal,
deleteAllFeedImports,
addFeeds,
runFeedImport,
addContentMapping
runFeedImport
} from '../utils';

test.describe( 'Feed Settings', () => {
Expand Down
41 changes: 40 additions & 1 deletion tests/e2e/specs/import.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
* WordPress dependencies
*/
import { test, expect } from '@wordpress/e2e-test-utils-playwright';
import {tryCloseTourModal, deleteAllFeedImports, addFeeds, runFeedImport, addFeaturedImage} from '../utils';
import {
tryCloseTourModal,
deleteAllFeedImports,
addFeeds,
runFeedImport,
addFeaturedImage,
addContentMapping
} from '../utils';

test.describe( 'Feed Import', () => {

Expand Down Expand Up @@ -132,4 +139,36 @@ test.describe( 'Feed Import', () => {
await page.getByRole('button', { name: 'Featured image' }).click({ force: true });
await expect( page.getByLabel('Edit or replace the image') ).toBeVisible(); // Featured image is added.
});

test( 'importing feed with chained actions', async({ admin, page }) => {
await admin.createNewPost();

const importName = 'Test Title: importing feed from URL with featured image';

await page.goto('/wp-admin/post-new.php?post_type=feedzy_imports');
await tryCloseTourModal( page );

await page.getByPlaceholder('Add a name for your import').fill(importName);
await addFeeds( page, [FEED_URL] );
await addContentMapping( page, '[[{"value":"%5B%7B%22id%22%3A%22trim%22%2C%22tag%22%3A%22item_content%22%2C%22data%22%3A%7B%22trimLength%22%3A%2230%22%7D%7D%5D"}]] '); // Trim the content with 30 words max.
await addFeaturedImage( page, '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_image%22%2C%22data%22%3A%7B%7D%7D%5D"}]] ' );

await page.getByRole('button', { name: 'Save & Activate importing' }).click({ force: true });

await runFeedImport( page );

// Select the first post created by feeds import. Check the featured image.
await page.getByRole('link', { name: 'Posts', exact: true }).click({ force: true });
await page.locator('#the-list tr').first().locator('a.row-title').click({ force: true });

await expect( page.getByLabel('Add title') ).toBeVisible(); // Post title.

// Content should be trimmed to 30 words.
const content = await page.getByPlaceholder('Write HTML…').inputValue();
expect( content ).toContain('<p>');
expect( content.split(' ').length ).toBeLessThanOrEqual(30);

await page.getByRole('button', { name: 'Featured image' }).click({ force: true });
await expect( page.getByLabel('Edit or replace the image') ).toBeVisible(); // Featured image is added.

Check failure on line 172 in tests/e2e/specs/import.spec.js

View workflow job for this annotation

GitHub Actions / E2E

[chromium] › import.spec.js:143:6 › Feed Import › importing feed with chained actions

1) [chromium] › import.spec.js:143:6 › Feed Import › importing feed with chained actions ───────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: getByLabel('Edit or replace the image') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByLabel('Edit or replace the image') 170 | 171 | await page.getByRole('button', { name: 'Featured image' }).click({ force: true }); > 172 | await expect( page.getByLabel('Edit or replace the image') ).toBeVisible(); // Featured image is added. | ^ 173 | }); 174 | }); 175 | at /home/runner/work/feedzy-rss-feeds/feedzy-rss-feeds/tests/e2e/specs/import.spec.js:172:64
});
});

0 comments on commit 8f8f8f0

Please sign in to comment.