Skip to content

[UPMERGE] 2.0 -> 2.1#17724

Merged
GSadee merged 5 commits into2.1from
upmerge/2.0_2.1
Mar 11, 2025
Merged

[UPMERGE] 2.0 -> 2.1#17724
GSadee merged 5 commits into2.1from
upmerge/2.0_2.1

Conversation

@SyliusBot
Copy link
Copy Markdown
Contributor

@SyliusBot SyliusBot commented Mar 8, 2025

This PR has been generated automatically.
For more details see upmerge_pr.yaml.

Remember! The upmerge should always be merged with using Merge pull request button.

In case of conflicts, please resolve them manually with usign the following commands:

git fetch upstream
gh pr checkout <this-pr-number>
git merge upstream/2.1 -m "Resolve conflicts between 2.0 and 2.1"

If you use other name for the upstream remote, please replace upstream with the name of your remote pointing to the Sylius/Sylius repository.

Once the conflicts are resolved, please run git merge --continue and push the changes to this PR.

Summary by CodeRabbit

  • New Features

    • Enhanced product attribute validations to ensure that options like "Mug material" are accurately assigned.
    • Improved product listing checks for more reliable display of products in orders.
  • Refactor

    • Optimized dynamic collection management for smoother overall operation.

NoResponseMate and others added 5 commits March 5, 2025 09:09
| Q               | A
|-----------------|-----
| Branch?         | 2.0
| Bug fix?        | in behats
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | -
| License         | MIT

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Improved the accuracy of product detection in order details, ensuring
a more reliable display of items in your orders.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
| Q               | A
|-----------------|-----
| Branch?         | 2.0
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes #17713, related #17685
| License         | MIT

The fix for collection items being substituted when removing an item
from anywhere but the end of the collection and adding a new item has
inadvertently caused a different bug to prop up, breaking the adding of
multiple select product attributes due to their collection keys not
being comparable.

Curiously, we have an UI test for this exact case, but it seems to just
ignore the exception popup and continue with other steps; Updated to
check the saved values so we can be sure of the outcome.
@SyliusBot SyliusBot requested review from a team as code owners March 8, 2025 02:14
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2025

Walkthrough

The changes introduce new Behat assertions and step definitions for verifying product attribute values in both API and UI contexts. A new regex transformation has been added to support an alternative input format for product attributes. Additionally, the approach for checking product presence on the admin order show page has been updated, and configuration files now include an extra transform context entry. Finally, a trait has been updated to encapsulate collection index calculation and to change a method’s visibility for broader access.

Changes

File(s) Change Summary
features/admin/…/adding_select_product_attribute.feature Added assertions to verify "Mug material" includes values "Banana Skin" and "Plastic".
src/Sylius/Behat/Context/Api/Admin/ManagingProductAttributesContext.php
src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php
Added new Behat step definition `@Then /^the ("[^"]+" product attribute) should(?:
src/Sylius/Behat/Context/Transform/ProductAttributeContext.php Added regex transformation @Transform /^"([^"]+)" product attribute$/ to support an additional input format.
src/Sylius/Behat/Page/Admin/Order/ShowPage.php Updated isProductInTheList to use hasElement for a more generalized product existence check.
src/Sylius/Behat/Resources/config/suites/api/product/managing_product_attributes.yml
src/Sylius/Behat/Resources/config/suites/ui/product/managing_product_attributes.yml
Added context sylius.behat.context.transform.product_attribute to the Behat suite configurations.
src/Sylius/Bundle/UiBundle/Twig/Component/LiveCollectionTrait.php Replaced index calculation with provideNewCollectionItemIndex method and changed fieldNameToPropertyPath visibility from private to protected.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Behat Test
    participant MAC as ManagingProductAttributesContext
    participant TAC as ProductAttributeContext
    Test->>MAC: Execute step for product attribute verification
    MAC->>TAC: Transform attribute string using regex pattern
    TAC-->>MAC: Return product attribute details
    MAC->>Test: Confirm attribute values ("Banana Skin", "Plastic")
Loading

Suggested labels

Admin, Behat, Maintenance

Suggested reviewers

  • mpysiak
  • GSadee

Poem

I'm a bunny with a code delight,
Hopping through tests both day and night,
Carrots of assertions, steps of fun,
Transforming strings 'til the task is done.
With every change, I wiggle in glee! 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82a63ae and 4962e55.

📒 Files selected for processing (8)
  • features/admin/product/managing_product_attributes/adding_select_product_attribute.feature (1 hunks)
  • src/Sylius/Behat/Context/Api/Admin/ManagingProductAttributesContext.php (1 hunks)
  • src/Sylius/Behat/Context/Transform/ProductAttributeContext.php (1 hunks)
  • src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php (1 hunks)
  • src/Sylius/Behat/Page/Admin/Order/ShowPage.php (1 hunks)
  • src/Sylius/Behat/Resources/config/suites/api/product/managing_product_attributes.yml (1 hunks)
  • src/Sylius/Behat/Resources/config/suites/ui/product/managing_product_attributes.yml (1 hunks)
  • src/Sylius/Bundle/UiBundle/Twig/Component/LiveCollectionTrait.php (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Static checks / PHP 8.3, Symfony ^7.1
  • GitHub Check: Static checks / PHP 8.2, Symfony ^6.4
  • GitHub Check: Static checks / PHP 8.3, Symfony ^7.1
  • GitHub Check: Static checks / PHP 8.2, Symfony ^6.4
🔇 Additional comments (10)
features/admin/product/managing_product_attributes/adding_select_product_attribute.feature (1)

32-33: Good addition of verification steps.

The new assertion steps properly verify that both "Banana Skin" and "Plastic" values are correctly associated with the "Mug material" product attribute after creation. This enhances the test coverage by ensuring that multiple values are properly stored and retrievable.

src/Sylius/Behat/Resources/config/suites/ui/product/managing_product_attributes.yml (1)

13-13: Appropriate context addition.

Adding the product attribute transformation context to the UI test suite is necessary to support the new assertions in the feature file. This ensures that the product attribute references in the feature file can be properly transformed into actual product attribute objects.

src/Sylius/Behat/Resources/config/suites/api/product/managing_product_attributes.yml (1)

11-11: Consistent context configuration.

Adding the same transformation context to the API test suite maintains consistency between the UI and API testing approaches. This is a good practice that ensures both test suites can process product attribute references in the same way.

src/Sylius/Behat/Context/Api/Admin/ManagingProductAttributesContext.php (1)

373-373: Enhanced step definition flexibility.

The new regex pattern adds support for an alternative input format when referring to product attributes. This flexibility allows for more natural language in the feature files and makes the test more readable while reusing the existing method implementation.

The pattern @Then /^the ("[^"]+" product attribute) should(?:| also) have value "([^"]+)"/ nicely complements the existing one and supports assertions like the "Mug material" product attribute should have value "Banana Skin".

src/Sylius/Behat/Context/Ui/Admin/ManagingProductAttributesContext.php (1)

367-370: Excellent addition of alternative step definition pattern

This regex addition enhances the test expressiveness by allowing direct reference to product attributes by name (e.g., "Mug material" product attribute) rather than requiring a previous definition with "this product attribute".

src/Sylius/Behat/Context/Transform/ProductAttributeContext.php (1)

28-32: Good complementary transformation for the new step definition

This transformation pattern perfectly complements the new step definition in ManagingProductAttributesContext, allowing Behat to convert a string like "Mug material" product attribute into a ProductAttributeInterface object.

src/Sylius/Behat/Page/Admin/Order/ShowPage.php (1)

150-153: Simplified implementation with equivalent behavior

The method now directly uses hasElement() instead of calling getRowWithItem(). This is a cleaner approach that maintains the same functionality while removing an unnecessary intermediate method call.

src/Sylius/Bundle/UiBundle/Twig/Component/LiveCollectionTrait.php (3)

42-43: Good refactoring to extract complex logic into a dedicated method

Moving the collection index calculation to a separate method improves readability and maintainability.


64-65: Appropriate change of method visibility for extensibility

Changing visibility from private to protected allows subclasses to override this method, improving the trait's extensibility without breaking encapsulation.


79-97: Robust implementation with proper edge case handling

This new method handles all edge cases elegantly:

  1. Empty arrays
  2. Arrays with only non-numeric keys
  3. Arrays with mixed key types
  4. Arrays with only numeric keys

The implementation is more robust than the previous direct calculation and includes proper PHPDoc type annotation.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy the environment

@GSadee GSadee added the Maintenance CI configurations, READMEs, releases, etc. label Mar 11, 2025
@GSadee GSadee merged commit 4f6ee17 into 2.1 Mar 11, 2025
72 of 76 checks passed
@GSadee GSadee deleted the upmerge/2.0_2.1 branch March 11, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants