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

Enhance/5450 twg tag infra #5565

Merged
merged 14 commits into from
Jul 21, 2022
Merged

Conversation

kuasha420
Copy link
Contributor

@kuasha420 kuasha420 commented Jul 18, 2022

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 4.7 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@kuasha420 kuasha420 force-pushed the enhance/5450-twg-tag-infra branch from a853289 to 3562c44 Compare July 18, 2022 06:20
@kuasha420 kuasha420 marked this pull request as ready for review July 18, 2022 19:49
Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

Thanks, @kuasha420. This is a good start, but there are things that we need to improve before merging this PR. Please, check my comments and make appropriate changes.

includes/Modules/Thank_With_Google/Tag_Interface.php Outdated Show resolved Hide resolved
includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
Comment on lines 122 to 141
public function test_content_placeholder() {
remove_all_filters( 'the_content' );

$this->thank_with_google->register();
do_action( 'template_redirect' );

$mock_content = '<p>Hello World</p>';

$output = apply_filters( 'the_content', $mock_content );

// Snippet should not be present on non singular pages.
$this->assertEquals( $output, $mock_content );

$post_ID = $this->factory()->post->create();
$this->go_to( get_permalink( $post_ID ) );

$output = apply_filters( 'the_content', '<p>Hello World</p>' );

$this->assertStringContainsString( 'Thank with Google snippet added by Site Kit', $output );
$this->assertStringContainsString( '<button twg-button', $output );
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be moved into a new test file for the Web_Tag class and more tests should be added to cover all three use cases.

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 have moved it to separate file and added more tests. However, the tests are failing on PHP 5.6 and/or WP 4.7. Can you help me with it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kuasha420, not sure why it doesn't work, maybe try to add 'post_status' => 'publish', when you generate a new post?

Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

Thanks, @kuasha420. One more suggestion and this is good to go. I'll apply it by myself.

includes/Modules/Thank_With_Google/Web_Tag.php Outdated Show resolved Hide resolved
@eugene-manuilov eugene-manuilov merged commit bbfd552 into develop Jul 21, 2022
@eugene-manuilov eugene-manuilov deleted the enhance/5450-twg-tag-infra branch July 21, 2022 13:05
Comment on lines +59 to +61
public function set_publication_id( $publication_id ) {
$this->publication_id = $publication_id;
}
Copy link
Member

Choose a reason for hiding this comment

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

This method is unnecessary. The publication ID for this tag is the "main" ID to pass into the constructor, so it should rather be looked up from the property in the parent class. It's a bit redundant to set it here too.

Copy link
Collaborator

@eugene-manuilov eugene-manuilov Jul 27, 2022

Choose a reason for hiding this comment

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

Good catch. I have created a follow up PR to address this: #5616

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.

3 participants