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

364 add the integration card for google site kit #21946

Open
wants to merge 15 commits into
base: trunk
Choose a base branch
from

Conversation

vraja-pro
Copy link
Contributor

@vraja-pro vraja-pro commented Jan 3, 2025

Context

Summary

This PR can be summarized in the following changelog entry:

  • Removes "New" badges from the integration page.
  • Enables translation for the "Learn more" in the integration cards.
  • Adds unreleased integration card for Google Site Kit.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Go to Yoast integrations page, check you no longer see "New" badges on the cards.
  • Check you don't see a card for Google Site Kit (GSK)
  • Enable the feature flag by adding this code ( use Snippets plugin or add to wp-config.php ):
define( 'YOAST_SEO_GOOGLE_SITE_KIT_FEATURE', true );
  • Check you now see a card for Google Site Kit (GSK)
  • Without GSK installed, go to integration page and check you see a card in the recommended integrations section:
    • Check it has a button to install GSK and the status is "Plugin not detected" with red x.
    • Check the card header is greyed
    • Check you see a button to install the plugin
    • Click on the install button and check you are redirected to install GSK.
  • With GSK installed but not activate go back to Yoast integrations page
    • Check you see a button on GSK to activate
    • Check the card header is greyed out.
    • Check it has a button to install GSK and the status is "Plugin not detected" with red x.
    • Click on the "activate" button and check you are redirected to the plugins page.
  • With GSK activated but not configured go back to Yoast integrations page
    • Activate GSK and check the card header is not greyed
    • The status is "Not connected" with red x
    • There is a button to setup GSK
    • Click on the button and check you re redirected to GSK settings page.
  • With GSK connected and configured go back to Yoast integrations page
    • Check the status is "not connected"
    • Check the button is to connect
    • Click on the button and check you see a modal ( design for the modal would be added in a later stage )
  • With GSK configured and connected.
    • Go to the data base options table and search for 'google_site_kit_connected'
    • Set it to 1
    • Go back to integration page and check that the status is "Successfully connected"
    • Check you have a white button to disconnect.
    • Disable the GSK and check you get the "activate" button label and status from above.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes Figure out how we can detect if Site Kit is configured and add the integration card

@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jan 3, 2025
And renaming

tests links
fix tests to run in separate process.

This is done because the conditional foe jetpack and elementor returns different results when running the test separately.
@vraja-pro vraja-pro force-pushed the 364-add-the-integration-card-for-google-site-kit branch from c304683 to 4c3bbdd Compare January 6, 2025 07:23
@coveralls
Copy link

Pull Request Test Coverage Report for Build 5027634b5b73f99fb989cd278943550041725a0a

Details

  • 44 of 48 (91.67%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+20.1%) to 54.732%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/integrations-page/recommended-integrations.js 0 4 0.0%
Totals Coverage Status
Change from base Build 870b6c8a8759df89487e8bbc077b82dd90e470a4: 20.1%
Covered Lines: 30173
Relevant Lines: 55515

💛 - Coveralls

Copy link
Member

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR 🏗️

About the changelog entries

Removes "New" badges from the integration page.

That is for sure user-facing. Whether that is worth mentioning is another. But I don't see any decisions, so I mention it.

Enables translation for the "Learn more" in the integration cards.

Isn't that a bugfix? E.g. something like

  • Fixes a bug where Learn more on the integrations page would not be translated.

Adds unreleased integration card for Google Site Kit.
Unreleased? You mean behind feature flag.

Comment on lines +32 to +35
global.wpseoScriptData = {
isPremium: 0,
};

Copy link
Member

Choose a reason for hiding this comment

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

Why would you add this for all tests?

install: sprintf(
/* translators: 1: Site Kit by Google */
__( "Install %1$s", "wordpress-seo" ),
"Site Kit by Google"
Copy link
Member

Choose a reason for hiding this comment

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

* @returns {WPElement} The Site Kit integration component.
*/
export const GoogleSiteKitIntegration = () => {
const { isActive, afterSetup, isInstalled, isConnected } = get( window, "wpseoIntegrationsData.googleSiteKit", { isActive: false, afterSetup: false, isInstalled: false, isConnected: false } );
Copy link
Member

Choose a reason for hiding this comment

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

I think you should not read the window state inside this component.
Instead, take an example of the Woo integration and use props to connect it from the recommended plugins in this case.

That would've made your tests also more straight forward to use normal props for component rendering.

const { isActive, afterSetup, isInstalled, isConnected } = get( window, "wpseoIntegrationsData.googleSiteKit", { isActive: false, afterSetup: false, isInstalled: false, isConnected: false } );
const [ isModalOpen, toggleModal ] = useToggleState( false );

const getButtonConfig = useCallback( () => {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of config. These are the props, right?

E.g. getButtonProps

<>
<SimpleIntegration
integration={ integration }
isActive={ isInstalled && isActive }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
isActive={ isInstalled && isActive }
isActive={ isInstalled && isActive }


if ( ! isInstalled ) {
button.children = buttonLabels.install;
button.href = "/wp-admin/plugin-install.php?s=google%2520site%2520kit&tab=search&type=term";
Copy link
Member

Choose a reason for hiding this comment

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

This and below, the admin URLs should be retrieved from PHP to ensure compatibility for changes. See the integration' use of self_admin_url

id: "google-site-kit-button",
};

if ( ! isInstalled ) {
Copy link
Member

Choose a reason for hiding this comment

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

This giant if/else is a bit bewildering.

Later on you combine states as well. I wonder if this can be done in an easier way.
Really, you have just a button in the content and a status in the footer.

logo: SiteKitLogo,
};

const buttonLabels = {
Copy link
Member

Choose a reason for hiding this comment

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

Why only labels and not also the rest of the button props?

Comment on lines +95 to +97
const notConnected = useMemo( () => ! isConnected || ! afterSetup, [ isConnected, afterSetup ] );
const pluginNotDetected = useMemo( () => ! isActive || ! isInstalled, [ isActive, isInstalled ] );
const successfullyConnected = useMemo( () => isActive && afterSetup && isConnected, [ isActive, afterSetup, isConnected ] );
Copy link
Member

Choose a reason for hiding this comment

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

These useMemo usages seem a bit overkill for simple boolean logic

import { GoogleSiteKitIntegration } from "../../src/integrations-page/google-site-kit-integration";
import { expect } from "@jest/globals";

describe( "GoogleSiteKitIntegration", () => {
Copy link
Member

Choose a reason for hiding this comment

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

These are the happy paths.
I wonder, with all that logic if/else, what would happen if you brute force all the combinations 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants