Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EP-5420: More thorough affiliate widgets tests #190

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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.

1 participant