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

Remove pre launch checklist items #2555

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 3 additions & 50 deletions src/API/Site/Controllers/MerchantCenter/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function get_settings_endpoint_edit_callback(): callable {
*/
protected function get_schema_properties(): array {
return [
'shipping_rate' => [
'shipping_rate' => [
'type' => 'string',
'description' => __(
'Whether shipping rate is a simple flat rate or needs to be configured manually in the Merchant Center.',
Expand All @@ -105,7 +105,7 @@ protected function get_schema_properties(): array {
'manual',
],
],
'shipping_time' => [
'shipping_time' => [
'type' => 'string',
'description' => __(
'Whether shipping time is a simple flat time or needs to be configured manually in the Merchant Center.',
Expand All @@ -118,7 +118,7 @@ protected function get_schema_properties(): array {
'manual',
],
],
'tax_rate' => [
'tax_rate' => [
'type' => 'string',
'description' => __(
'Whether tax rate is destination based or need to be configured manually in the Merchant Center.',
Expand All @@ -131,53 +131,6 @@ protected function get_schema_properties(): array {
'manual',
],
],
'website_live' => [
'type' => 'boolean',
'description' => __( 'Whether the store website is live.', 'google-listings-and-ads' ),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'default' => false,
],
'checkout_process_secure' => [
'type' => 'boolean',
'description' => __(
'Whether the checkout process is complete and secure.',
'google-listings-and-ads'
),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'default' => false,
],
'payment_methods_visible' => [
'type' => 'boolean',
'description' => __(
'Whether the payment methods are visible on the website.',
'google-listings-and-ads'
),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'default' => false,
],
'refund_tos_visible' => [
'type' => 'boolean',
'description' => __(
'Whether the refund policy and terms of service are visible on the website.',
'google-listings-and-ads'
),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'default' => false,
],
'contact_info_visible' => [
'type' => 'boolean',
'description' => __(
'Whether the phone number, email, and/or address are visible on the website.',
'google-listings-and-ads'
),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'default' => false,
],
];
}

Expand Down
30 changes: 1 addition & 29 deletions src/MerchantCenter/MerchantCenterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function get_setup_status(): array {
if ( $this->saved_target_audience() && $this->saved_shipping_and_tax_options() ) {
$step = 'store_requirements';

if ( $this->is_mc_contact_information_setup() && $this->checked_pre_launch_checklist() ) {
if ( $this->is_mc_contact_information_setup() ) {
$step = 'paid_ads';
}
}
Expand Down Expand Up @@ -348,34 +348,6 @@ protected function is_mc_contact_information_setup(): bool {
return $is_setup['phone_number'] && $is_setup['phone_number_verified'] && $is_setup['address'];
}

/**
* Check if all items in the pre-launch checklist have been checked.
*
* NOTE: This is a temporary method that will be replaced by the Policy Compliance Checks project.
*
* @return bool If all required items in the pre-launch checklist have been checked.
*
* @since 2.2.0
*/
protected function checked_pre_launch_checklist(): bool {
$settings = $this->options->get( OptionsInterface::MERCHANT_CENTER, [] );
$keys = [
'website_live',
'checkout_process_secure',
'payment_methods_visible',
'refund_tos_visible',
'contact_info_visible',
];

foreach ( $keys as $key ) {
if ( empty( $settings[ $key ] ) || $settings[ $key ] !== true ) {
return false;
}
}

return true;
}

/**
* Check if the taxes + shipping rate and time + free shipping settings have been saved.
*
Expand Down
56 changes: 0 additions & 56 deletions src/Value/MerchantCenterSettings.php

This file was deleted.

7 changes: 6 additions & 1 deletion tests/Tools/HelperTrait/ProductTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ protected function generate_mock_image_attachment( int $product_id, string $imag
* @return WCProductAdapter The adapted products with the rules applied.
*/
protected function generate_attribute_mapping_adapted_product( $rules, $categories = [] ) {
$product = WC_Helper_Product::create_simple_product( false );
$product = WC_Helper_Product::create_simple_product(
false,
[
'sku' => 'Mapped Product SKU',
]
);

$attributes = [
WC_Helper_Product::create_product_attribute_object( 'size', [ 's', 'xs' ] ),
Expand Down
12 changes: 2 additions & 10 deletions tests/Unit/MerchantCenter/MerchantCenterServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,26 +511,18 @@ public function test_get_setup_status_step_paid_ads() {
$this->options->method( 'get_merchant_id' )->willReturn( 1234 );
$this->merchant_account_state->method( 'last_incomplete_step' )->willReturn( '' );
$this->ads_service->method( 'connected_account' )->willReturn( true );
$this->options->method( 'get' )
$this->options->expects( $this->exactly( 3 ) )->method( 'get' )
->withConsecutive(
[ OptionsInterface::MC_SETUP_COMPLETED_AT, false ],
[ OptionsInterface::TARGET_AUDIENCE ],
[ OptionsInterface::MERCHANT_CENTER, [] ],
[ OptionsInterface::MERCHANT_CENTER, [] ]
)->willReturnOnConsecutiveCalls(
false,
[
'location' => 'selected',
'countries' => [ 'GB' ],
],
[],
[
'website_live' => true,
'checkout_process_secure' => true,
'payment_methods_visible' => true,
'refund_tos_visible' => true,
'contact_info_visible' => true,
]
[]
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I wanted to mention here was that this test data is not a valid replacement. Because we no longer use the function checked_pre_launch_checklist the options are not fetched a fourth time.

We can confirm that by checking specifically for how many times it's called by using something like:

$this->options->expects( $this->exactly( 4 ) )->method( 'get' )

Which will fail with a message:

Expectation failed for method name is "get" when invoked 4 time(s).
Method was expected to be called 4 times, actually called 3 times.

So I'd suggest to actually check that it's invoked 3 times as well as remove the parameters and response for the fourth time.

		$this->options->expects( $this->exactly( 3 ) )->method( 'get' )
			->withConsecutive(
				[ OptionsInterface::MC_SETUP_COMPLETED_AT, false ],
				[ OptionsInterface::TARGET_AUDIENCE ],
				[ OptionsInterface::MERCHANT_CENTER, [] ]
			)->willReturnOnConsecutiveCalls(
				false,
				[
					'location'  => 'selected',
					'countries' => [ 'GB' ],
				],
				[]
			);

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏻 @kt-12 can you make these updates and request another review from me?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you @mikkamp and @joemcgill, I have addressed this comment.

);
$this->shipping_time_query->method( 'get_results' )
->willReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function test_maps_rules_product_fields_sku() {
$adapted_product = $this->generate_attribute_mapping_adapted_product( $rules );
$adapted_variation = $this->generate_attribute_mapping_adapted_product_variant( $rules );

$this->assertEquals( 'DUMMY SKU', $adapted_product->getGtin() );
$this->assertEquals( 'Mapped Product SKU', $adapted_product->getGtin() );
$this->assertEquals( 'DUMMY SKU VARIABLE HUGE BLUE ANY NUMBER', $adapted_variation->getGtin() );
}

Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/specs/setup-mc/step-2-product-listings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ test.describe( 'Configure product listings', () => {
productListingsPage.fulfillSettings(
{
shipping_rate: 'automatic',
website_live: false,
checkout_process_secure: false,
payment_methods_visible: false,
refund_tos_visible: false,
contact_info_visible: false,
},
200,
[ 'GET' ]
Expand Down