8000 [#287] Updated FileTrait. by skipper-vp · Pull Request #357 · drevops/behat-steps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[#287] Updated FileTrait. #357

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

Merged
merged 5 commits into from
Apr 21, 2025
Merged

[#287] Updated FileTrait. #357

merged 5 commits into from
Apr 21, 2025

Conversation

skipper-vp
Copy link
Contributor
@skipper-vp skipper-vp commented Apr 18, 2025

Closes #287

Summary by CodeRabbit

  • Documentation

    • Improved clarity and consistency in migration and step definition documentation, including updated mappings for cookie and file management steps.
    • Enhanced Gherkin step descriptions in documentation for better readability.
  • Style

    • Standardized the phrasing of cookie and file-related step definitions in both code annotations and feature files for uniformity and clearer English usage.
  • Tests

    • Updated feature files to use the new, more explicit step definitions and scenario titles without altering test logic or outcomes.

Copy link
coderabbitai bot commented Apr 18, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • develop
  • master

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes focus on standardizing and clarifying the phrasing of Behat step definitions and related documentation for cookie handling and file management. Step annotations in both code and feature files are updated to use more explicit and consistent English, such as including definite articles ("the", "a") and descriptive wording for managed and unmanaged file operations. Migration and documentation files are updated to reflect these new mappings and step definitions. No changes are made to the underlying logic or exported code entities; all updates are textual and documentation-related.

Changes

File(s) Change Summary
MIGRATION.md, steps.md Updated documentation to reflect new, more explicit step definition mappings for cookie and file management features.
src/CookieTrait.php Changed Behat step annotations to consistently use explicit articles and descriptive phrasing for cookie-related steps.
src/FileTrait.php Revised Behat step annotations for managed and unmanaged file steps to use explicit, consistent, and descriptive wording.
tests/behat/features/cookie.feature Updated all step definitions and scenario titles to use standardized, explicit phrasing for cookie assertions.
tests/behat/features/file.feature Reworded all managed and unmanaged file step definitions for clarity and consistency; updated scenario titles accordingly.

Suggested labels

PR: Requires more work


🪧 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.

@skipper-vp
Copy link
Contributor Author
skipper-vp commented Apr 18, 2025

This build fails because of the keyboard.feature failing with the following:

@api @javascript
  Scenario: Assert step definition "When I press the key :char on the element :selector" succeeds as expected with "tab" key # tests/behat/features/keyboard.feature:48
    Given I am an anonymous user                                                                                             # FeatureContext::assertAnonymousUser()
    When I visit "/sites/default/files/relative.html"                                                                        # Drupal\DrupalExtension\Context\MinkContext::assertAtPath()
    Then the "input2" field should not contain "h"                                                                           # Drupal\DrupalExtension\Context\MinkContext::assertFieldNotContains()
      Form field with id|name|label|value "input2" not found. (Behat\Mink\Exception\ElementNotFoundException)
    When I press the key "tab" on the element "#input1"                                                                      # FeatureContext::keyboardPressKeyOnElement()
    And I press the key "h" on the element "#input2"                                                                         # FeatureContext::keyboardPressKeyOnElement()
    Then the "input2" field should contain "h"                                                                               # Drupal\DrupalExtension\Context\MinkContext::assertFieldContains()

--- Failed scenarios:

    tests/behat/features/keyboard.feature:48

5 scenarios (4 passed, 1 failed)
29 steps (25 passed, 1 failed, 3 skipped)

This field is indeed not there.

And user.feature with the following:

    When I run "behat --no-colors"                                                                                    # BehatCliContext::iRunBehat()
    Then it should fail with an error:                                                                                # BehatCliContext::behatCliAssertFailWithError()
      """
      User "single_role" should not have roles(s) "administrator", "content_editor", but has "authenticated", "administrator", "content_editor", "content_approver".
      """
      Failed asserting that 'Feature: Stub feature';\n
      \n
        @api\n
        Scenario: Stub scenario title                                                                    # features/stub.feature:3\n
          Given users:                                                                                   # FeatureContext::createUsers()\n
            | name        | roles                                           |\n
            | single_role | administrator, content_editor, content_approver |\n
            No role "content_approver" exists. (RuntimeException)\n
          Then the user "single_role" should not have the roles "administrator, content_editor" assigned # FeatureContext::userAssertHasNoRoles()\n
      \n
      --- Failed scenarios:\n
      \n
          features/stub.feature:3\n
      \n
      1 scenario (1 failed)\n
      2 steps (1 failed, 1 skipped)' contains "User "single_role" should not have roles(s) "administrator", "content_editor", but has "authenticated", "administrator", "content_editor", "content_approver".".

I haven't touched anything in these tests, so why could they fail?
Have you seen this before @AlexSkrypnyk ?

@skipper-vp skipper-vp changed the title Feature/287 update file trait [#287] Updated FileTrait. Apr 18, 2025
@AlexSkrypnyk
Copy link
Member

@coderabbitai full review

Copy link
coderabbitai bot commented Apr 18, 2025
✅ Actions performed

Full review triggered.

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
MIGRATION.md (1)

62-63: Formatting issue in table row.

The table formatting is incorrect - missing a trailing pipe and proper column alignment.

-| `NEW`                                                                                                                        | `Then the downloaded file should be a zip archive containing the files partially named:`                                                                                                                                       |
+| `NEW`                                                                                                                        | `Then the downloaded file should be a zip archive containing the files partially named:`                                                                                                                                       |

Add a trailing pipe to the end of line 62 and ensure the table has the correct number of columns.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

63-63: Table pipe style
Expected: leading_and_trailing; Actual: leading_only; Missing trailing pipe

(MD055, table-pipe-style)


63-63: Table column count
Expected: 2; Actual: 1; Too few cells, row will be missing data

(MD056, table-column-count)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0345287 and be49f77.

📒 Files selected for processing (6)
  • MIGRATION.md (2 hunks)
  • src/CookieTrait.php (11 hunks)
  • src/FileTrait.php (8 hunks)
  • steps.md (4 hunks)
  • tests/behat/features/cookie.feature (9 hunks)
  • tests/behat/features/file.feature (10 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
MIGRATION.md

63-63: Table pipe style
Expected: leading_and_trailing; Actual: leading_only; Missing trailing pipe

(MD055, table-pipe-style)


63-63: Table column count
Expected: 2; Actual: 1; Too few cells, row will be missing data

(MD056, table-column-count)

🔇 Additional comments (13)
src/CookieTrait.php (1)

19-19: Consistent textual improvements to step definitions.

The changes standardize the language in step definitions by explicitly using definite articles like "the" before "name" and "value". These improvements make the step definitions clearer and more consistent throughout the trait.

Also applies to: 28-28, 37-37, 46-46, 55-55, 64-64, 82-82, 91-91, 100-100, 109-109, 118-118

src/FileTrait.php (3)

63-65: Documentation comment alignment with implementation.

The comment has been updated to use plural form to match the step definition annotation below it, ensuring documentation consistency.


192-193: Updated step definition to use clearer language.

Changed from singular to plural form and added "the following" to improve clarity and consistency with other similar steps in the codebase.


235-239: Improved unmanaged file step definitions.

Step definitions for unmanaged files have been updated to use more explicit and descriptive phrasing:

  • Added "the" or "an" before "unmanaged file"
  • Added "at the URI" for clarity
  • Used "should exist/not exist/contain/not contain" consistently

These changes make the steps more readable while maintaining the same functionality.

Also applies to: 255-259, 264-268, 275-279, 286-290, 304-308

MIGRATION.md (2)

16-28: Added migration mappings for CookieTrait step definitions.

The new mapping table provides clear documentation for migrating from v2 to v3 format of CookieTrait step definitions.


64-72: Added migration mappings for FileTrait step definitions.

New mappings clearly document the transition from v2 to v3 format for FileTrait step definitions, providing helpful reference for developers updating their tests.

tests/behat/features/file.feature (4)

4-6: Updated scenario title and step definitions for managed files.

Changed from singular to plural form and added "the following" for consistency with implementation in FileTrait.php.

Also applies to: 11-11


26-26: Standardized managed file step definitions.

All instances of "Given managed file:" have been updated to "Given the following managed files:" for consistency throughout the feature file.

Also applies to: 38-38, 46-46, 58-58, 66-66, 78-78, 86-86, 96-96, 104-104


113-128: Updated unmanaged file step definitions.

The step definitions for unmanaged files have been revised to use more explicit and descriptive phrasing, consistently using "at the URI" and "should exist/contain" patterns.


134-134: Updated scenario descriptions and steps for error cases.

Scenario titles and steps have been updated to match the new step definition format. These changes maintain test functionality while improving readability.

Also applies to: 143-143, 147-149, 157-163, 172-178

tests/behat/features/cookie.feature (1)

6-383:

✅ Verification successful

Consistency: Article usage in cookie steps
All modified lines uniformly insert explicit articles (“the”, “a”) in the Gherkin steps for cookie existence and non‑existence. This is a purely textual update that improves clarity. Please verify that the step annotations in src/CookieTrait.php have been updated to exactly match these new phrases; mismatches between feature files and their step definitions will lead to Undefined step errors.

Run the following to confirm alignment between feature steps and their definitions:


🏁 Script executed:

#!/bin/bash
# Verify that CookieTrait step annotations match the updated feature phrases
rg -n '@Then a cookie with the name' -n src/CookieTrait.php
rg -n '@Then a cookie with a name' -n src/CookieTrait.php
rg -n '@Then a cookie with the name and the value' -n src/CookieTrait.php
rg -n '@Then a cookie with the name and a value containing' -n src/CookieTrait.php

Length of output: 1259


Cookie step definitions verified to match updated feature phrases
All Gherkin steps in tests/behat/features/cookie.feature are covered by matching annotations in src/CookieTrait.php. No mismatches detected.

Key annotations found in src/CookieTrait.php:

  • Line 19: @Then a cookie with the name :name should exist
  • Line 28: @Then a cookie with the name :name and the value :value should exist
  • Line 37: @Then a cookie with the name :name and a value containing :partial_value should exist
  • Line 46: @Then a cookie with a name containing :partial_name should exist
  • Line 55: @Then a cookie with a name containing :partial_name and the value :value should exist
  • Line 64: @Then a cookie with a name containing :partial_name and a value containing :partial_value should exist
  • Line 82: @Then a cookie with the name :name and the value :value should not exist
  • Line 91: @Then a cookie with the name :name and a value containing :partial_value should not exist
  • Line 100: @Then a cookie with a name containing :partial_name should not exist
  • Line 109: @Then a cookie with a name containing :partial_name and the value :value should not exist
  • Line 118: @Then a cookie with a name containing :partial_name and a value containing :partial_value should not exist

All modified feature steps align with these definitions—ready to merge.

steps.md (2)

136-167: Approve: CookieTrait documentation updated
The documentation for CookieTrait steps now explicitly includes “the”/“a” to mirror the feature files. This enhances consistency across docs and tests. Ensure the examples in tests/behat/features/cookie.feature continue to align.


486-519: Approve: FileTrait documentation additions
New FileTrait entries (managed/unmanaged file creation and assertions) are clearly described and consistent in phrasing. Confirm that src/FileTrait.php implements step annotations matching these Gherkin strings (and that tests/behat/features/file.feature has corresponding scenarios).

@AlexSkrypnyk
Copy link
Member

@skipper-vp I think it now correctly fails on an old step name

Copy link
Member
@AlexSkrypnyk AlexSkrypnyk left a comment

Choose a reason for hiding this comment

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

Please update the old step name - see CI output

@AlexSkrypnyk AlexSkrypnyk added the PR: Requires more work Pull request was reviewed and reviver(s) asked to work further on the pull request label Apr 18, 2025
Copy link
codecov bot commented Apr 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.51%. Comparing base (a4207d9) to head (b6dc402).
Report is 1 commits behind head on 3.x.

Additional details and impacted files
@@           Coverage Diff           @@
##              3.x     #357   +/-   ##
=======================================
  Coverage   79.51%   79.51%           
=======================================
  Files          30       30           
  Lines        1484     1484           
=======================================
  Hits         1180     1180           
  Misses        304      304           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skipper-vp skipper-vp requested a review from AlexSkrypnyk April 19, 2025 03:35
@AlexSkrypnyk AlexSkrypnyk merged commit 01c99eb into 3.x Apr 21, 2025
4 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/287-update-FileTrait branch April 21, 2025 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Requires more work Pull request was reviewed and reviver(s) asked to work further on the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0