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

Update empty state for product attributes tab #38126

Merged
merged 17 commits into from May 10, 2023

Conversation

mattsherman
Copy link
Contributor

@mattsherman mattsherman commented May 4, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR updates the empty state for the product Attributes tab so that it always shows an empty local attribute form, which makes it quicker for users to add attributes to a product. This empty local attribute form is shown regardless of whether any global attributes are in the system.

Also, it is mentioned in the issue acceptance criteria, but bears calling out here as well.. the header buttons are now always the Add new and Add existing ones, replacing the older Custom product attribute dropdown and Add button.

The implementation of this change required some updates to the logging of the following Tracks events:

  • wcadmin_product_attributes_buttons with action: 'add_new'
    • Logged when the Add new button is clicked
  • wcadmin_product_attributes_buttons with action: 'add_existing'
    • Logged when an existing global attribute is selected from the Add existing dropdown
  • wcadmin_product_attributes_add_term
    • Logged when Create value is clicked to create a new value for a global attribute (this is logged regardless of whether a new value is actually created, to keep behavior consistent with how it was prior to this PR)

The e2e tests were updated to reflect the change in CSS classes used in the implementation.

Before

Empty state when no global attributes exist:

Screenshot 2023-05-04 at 09 22 57

Empty state when global attributes exist:

Screenshot 2023-05-04 at 09 21 08

After

Screenshot 2023-05-05 at 15 08 08

Closes #38104.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Common instructions

  • To create a new product, go to Products > Add New
  • To edit an existing product, go to Products > All Products
  • To add or remove global attributes, go to Products > Attributes
  • To save attributes, click Save attributes button on the Attributes tab
  • To save a product, click Publish (or Update, if an existing product)
  • To see Tracks events
    • Tools > WCA Test Helper > Tools > Enable wc-admin Tracking
    • Filter by recordevent in the browser dev console

No global attributes in system

  1. Remove all global attributes from the system
  2. Create a new product
  3. Go to the Attributes tab
  4. Verify that the empty attribute form is shown
  5. Fill out the attribute and save it
  6. Save the product and verify the attributes are correct
  7. Reload the product and verify the attributes are correct

Global attributes in system, adding a new local attribute

  1. Add at least one global attribute to the system, and configure terms for it
  2. Create a new product
  3. Go to the Attributes tab
  4. Verify that the empty attribute form is shown
  5. Fill out the attribute and save it
  6. Save the product and verify the attributes are correct
  7. Reload the product and verify the attributes are correct

Global attributes in system, adding a global attribute

  1. Add at least one global attribute to the system, and configure terms for it
  2. Create a new product
  3. Go to the Attributes tab
  4. Verify that the empty attribute form is shown
  5. Select a global attribute from the Add existing dropdown
  6. Verify the empty attribute form is removed
  7. Verify the same global attribute cannot be selected again from the Add existing dropdown
  8. Select terms for the global attribute and save it
  9. Save the product and verify the attributes are correct
  10. Reload the product and verify the attributes are correct

Editing an existing product with no attributes

  1. Edit one of your existing products no attributes
  2. Verify the empty attribute form is automatically shown when the Attributes tab is shown

Editing an existing product with local attributes

  1. Edit one of your existing products with local attributes (either saved from above or before)
  2. Verify the empty attribute form is not automatically shown when the Attributes tab is shown
  3. Verify the attributes are correct

Editing an existing product with global attributes

  1. Edit one of your existing products with global attributes (either saved from above or before)
  2. Verify the empty attribute form is not automatically shown when the Attributes tab is shown
  3. Verify the attributes are correct

Tracks events

  1. Clicking on Add new should log wcadmin_product_attributes_buttons with action: 'add_new'
  2. Clicking on an existing attribute in Add existing should log wcadmin_product_attributes_buttons with action: 'add_existing'
  3. Clicking on Create value for a global attribute should log wcadmin_product_attributes_add_term

@mattsherman mattsherman self-assigned this May 4, 2023
@github-actions github-actions bot added focus: e2e tests Issues related to e2e tests focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels May 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2023

Test Results Summary

Commit SHA: 190820c

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests26700202690m 55s
E2E Tests1880010019815m 40s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@codecov
Copy link

codecov bot commented May 5, 2023

Codecov Report

Merging #38126 (e1f6bdd) into trunk (fa6ee94) will decrease coverage by 0.0%.
The diff coverage is 2.6%.

❗ Current head e1f6bdd differs from pull request most recent head 190820c. Consider uploading reports for the commit 190820c to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             trunk   #38126     +/-   ##
==========================================
- Coverage     51.3%    51.2%   -0.0%     
- Complexity   17409    17417      +8     
==========================================
  Files          440      440             
  Lines        80584    80634     +50     
==========================================
- Hits         41311    41310      -1     
- Misses       39273    39324     +51     
Impacted Files Coverage Δ
...ocommerce/includes/admin/class-wc-admin-assets.php 0.0% <ø> (ø)
...ugins/woocommerce/includes/class-wc-post-types.php 0.9% <0.0%> (-<0.1%) ⬇️
...merce/includes/emails/class-wc-email-new-order.php 62.4% <0.0%> (-1.0%) ⬇️
...ins/woocommerce/includes/emails/class-wc-email.php 53.1% <ø> (ø)
...ludes/tracks/events/class-wc-products-tracking.php 0.0% <0.0%> (ø)
plugins/woocommerce/includes/class-wc-cart.php 79.4% <50.0%> (-0.1%) ⬇️
...ocommerce/includes/abstracts/abstract-wc-order.php 76.4% <100.0%> (ø)

... and 1 file with indirect coverage changes

@mattsherman mattsherman requested a review from a team May 5, 2023 19:12
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

Hi @nathanss,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@mattsherman mattsherman added type: enhancement The issue is a request for an enhancement. focus: product management Related to product creation and editing. and removed focus: react admin [team:Ghidorah] labels May 5, 2023
@mattsherman mattsherman marked this pull request as ready for review May 5, 2023 19:14
Copy link
Contributor

@nathanss nathanss left a comment

Choose a reason for hiding this comment

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

I had this problem while clicking 'Add new'. Can you check if it's related?

image image

EDIT: recording

Screen.Recording.2023-05-09.at.11.08.45.mov

@mattsherman
Copy link
Contributor Author

@nathanss Your screen recording shows the add_first_attribute action param being logged, which was changed in this PR. So, it looks like you might not be running the code from this PR. Can you please double-check this?

@mattsherman mattsherman requested a review from nathanss May 9, 2023 15:54
@nathanss
Copy link
Contributor

nathanss commented May 9, 2023

@mattsherman I'll double check. But I was checked out at the branch and ran build.

@nathanss
Copy link
Contributor

nathanss commented May 9, 2023

@mattsherman It is happening in this branch. Here's a print from the minified code:

image

@mattsherman
Copy link
Contributor Author

@nathanss That is not the minified code from the source in this PR. That is from older source. The minified code from this branch is...

var e, o, r;
null === (o = document.querySelector("#product_attributes .add_custom_attribute")) || void 0 === o || o.addEventListener("click", (()=>{
    (0,
    t.recordEvent)("product_attributes_buttons", {
        action: "add_new"
    })
}
)),
null === (r = window) || void 0 === r || r.jQuery("select.wc-attribute-search").on("select2:select", (function() {
    (0,
    t.recordEvent)("product_attributes_buttons", {
        action: "add_existing"
    })
}
)),

What build command are you running? The product-tracking/shared.ts source file is part of plugins/woocommerce-admin, so you need to make sure that is re-building. From the error you are getting, and the minified code you shared, it clearly isn't getting built for some reason!

@nathanss
Copy link
Contributor

nathanss commented May 9, 2023

@mattsherman Sorry. It was a problem at my end. All manual tests are passing!

@@ -400,6 +394,14 @@ jQuery( function ( $ ) {
.find( '.woocommerce_attribute' )
.get();

// If the product has no attributes, add an empty attribute to be filled out by the user.
$( function add_blank_custom_attribute_if_no_attributes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function doesn't necessarily need to be named, especially if it's only being used in this one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming functions is very helpful when you are looking at an outline of the code in an editor, debugging a stack trace, and to help document what the code is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: e2e tests Issues related to e2e tests focus: product management Related to product creation and editing. plugin: woocommerce Issues related to the WooCommerce Core plugin. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updated empty state for Attributes
3 participants