EP-5420: More thorough affiliate widgets tests#190
Conversation
| // Keep track of posts created during the tests so that we can delete them on tear down. | ||
| static $postIDsToDelete = []; | ||
|
|
||
| static function tearDownAfterClass(): void |
There was a problem hiding this comment.
See https://docs.phpunit.de/en/10.0/fixtures.html for documentation on PHPUnit's tearDownAfterClass.
| * @return void | ||
| * @throws Exception | ||
| */ | ||
| function deletePosts( array $postIDs ) { |
There was a problem hiding this comment.
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() ); |
There was a problem hiding this comment.
Shouldn't really matter for CI, but should be flagged for local dev.
| } | ||
|
|
||
| /** | ||
| * Find and return the Organic Affiliate widgets iframe. |
There was a problem hiding this comment.
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).
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.