Skip to content

Conversation

@nsineok
Copy link
Contributor

@nsineok nsineok commented Apr 28, 2025

Checklist before requesting a review

  • Subject includes ticket number as [#123] Verb in past tense.
  • Ticket number #123 added to description
  • Added context in Changed section
  • Self-reviewed code and commented in commented complex areas.
  • Added tests for fix/feature.
  • Relevant tests run and passed locally.

https://trello.com/c/yY7vUMax/177-website-add-behat-test-for-contact-form
./vendor/bin/behat -v --tags=contact

Changed

  1. Created a behat feature for testing the Contact form

Screenshots

image

Summary by CodeRabbit

  • New Features
    • Added automated tests for the contact form, including scenarios for form access, successful submission, and validation error handling.
  • Tests
    • Introduced a step to disable browser validation on forms during testing, enabling more comprehensive validation checks.

@coderabbitai
Copy link

coderabbitai bot commented Apr 28, 2025

Walkthrough

A new Behat feature file for testing the contact form has been added, introducing scenarios for verifying the form's accessibility, successful submission, and validation error handling. The FeatureContext context class is updated to include a new method, disableFormBrowserValidation, which allows tests to programmatically disable browser-side form validation via a Behat step. This enables server-side validation testing within automated scenarios. The LinkTrait is also imported and used in the context class to support link-related step definitions.

Changes

File(s) Change Summary
tests/behat/bootstrap/FeatureContext.php Added LinkTrait usage; introduced public method disableFormBrowserValidation with a Behat step for disabling form validation.
tests/behat/features/contact.feature Added new feature file with scenarios for contact form accessibility, submission, and validation error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Tester as Behat Tester
    participant Browser as Browser Session
    participant FeatureContext as FeatureContext

    Tester->>FeatureContext: Given I disable browser validation for form ".selector"
    FeatureContext->>Browser: Execute JS to set 'novalidate' on form
    Browser-->>FeatureContext: JS Execution Result
    FeatureContext-->>Tester: Step complete
Loading
sequenceDiagram
    participant Tester as Behat Tester
    participant Browser as Browser Session

    Tester->>Browser: Visit homepage
    Tester->>Browser: Click "Contact" link
    Tester->>Browser: Fill contact form fields
    Tester->>Browser: Submit form
    Browser-->>Tester: Display success or error message
    Tester->>Browser: Take screenshot
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 468a8f3 and 9fc3861.

📒 Files selected for processing (1)
  • tests/behat/features/contact.feature (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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 sequence diagram to generate a sequence diagram of the changes in 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.

@nsineok nsineok force-pushed the feature/behat_contact branch 2 times, most recently from 6e7217e to ac4e776 Compare April 28, 2025 20:21
@nsineok nsineok force-pushed the feature/behat_contact branch from ac4e776 to e8167b3 Compare April 28, 2025 20:32
@AlexSkrypnyk AlexSkrypnyk temporarily deployed to PR-26 April 28, 2025 20:48 Inactive
@AlexSkrypnyk
Copy link
Member

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Apr 28, 2025

✅ Actions performed

Full review triggered.

@AlexSkrypnyk AlexSkrypnyk changed the title yY7vUMax/177: created a behat test for the Contact form. Added test for the Contact form. Apr 28, 2025
@AlexSkrypnyk
Copy link
Member

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Apr 28, 2025

✅ Actions performed

Full review triggered.

*
* @When I disable browser validation for the form with selector :selector
*/
public function disableFormBrowserValidation(string $selector): void {
Copy link
Member

Choose a reason for hiding this comment

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

@nsineok
this is great! we will rake this into behat-steps library

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.

@nsineok
Great work! Please see my small comments.


@api @javascript
Scenario: Anonymous user can use the Contact link and Contact form.
Given I am on "homepage"
Copy link
Member

Choose a reason for hiding this comment

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

this should start with a user type

Given I am an anonymous user
When I visit homepage <--- there is a step for a homepage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to change this step to When I go to homepage.

When I visit homepage returned 404 response because the /homepage path doesn't exist on the site.

Scenario: Anonymous user can use the Contact link and Contact form.
Given I am on "homepage"
Then I should see the link Contact
Then I click the link with title Contact
Copy link
Member

Choose a reason for hiding this comment

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

please use AND for the next steps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made some changes. I tried to use And, When, and Then to make scenarios sound like stories. As I understood, there is no technical difference between these steps.

@AlexSkrypnyk AlexSkrypnyk added the Requires more work Pull request was reviewed and reviver(s) asked to work further on the pull request label Apr 28, 2025
@AlexSkrypnyk
Copy link
Member

@nsineok nsineok requested a review from AlexSkrypnyk April 29, 2025 20:07
@AlexSkrypnyk AlexSkrypnyk merged commit c7c22b4 into develop Apr 29, 2025
7 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/behat_contact branch April 29, 2025 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants