Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Mwindo
Copy link
Contributor

@Mwindo Mwindo commented Jul 13, 2023

There have been multiples instances in the past of Affiliate widgets not rendering properly in the WordPress editor, both upon insertion (i.e., our SDK didn't re-process the page to properly render the newly inserted widget) and upon navigating back to the post (i.e., our SDK didn't process the page correctly to properly render the previously saved widget). This PR expands our Selenium tests to account for these two cases.

// Keep track of posts created during the tests so that we can delete them on tear down.
static $postIDsToDelete = [];

static function tearDownAfterClass(): void
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://docs.phpunit.de/en/10.0/fixtures.html for documentation on PHPUnit's tearDownAfterClass.

* @return void
* @throws Exception
*/
function deletePosts( array $postIDs ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any way to permanently delete posts without first moving them to the trash. Note that we don't have access to functions like wp_delete_post() because we aren't in the WordPress instance.

try {
$browser->deletePosts( WidgetsTest::$postIDsToDelete );
} catch ( Exception $e ) {
error_log( 'Failed to delete test posts: ' . $e->getMessage() );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't really matter for CI, but should be flagged for local dev.

}

/**
* Find and return the Organic Affiliate widgets iframe.
Copy link
Contributor Author

@Mwindo Mwindo Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make this comment slightly more explicit since there are two iframes, the widget selection iframe (the editor logs in and customizes the widget) and the widget display iframe ("the widget"--what will be rendered on the actual site).

@Mwindo Mwindo requested a review from rrdial July 13, 2023 20:56
@Mwindo Mwindo marked this pull request as ready for review July 13, 2023 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants