Skip to content

test: cover maintained Eventyay AJAX failure paths - #368

Open
YashAnand69 wants to merge 2 commits into
fossasia:mainfrom
YashAnand69:test/eventyay-handler-contracts-oct25
Open

YashAnand69 wants to merge 2 commits into
fossasia:mainfrom
YashAnand69:test/eventyay-handler-contracts-oct25

Conversation

@YashAnand69

@YashAnand69 YashAnand69 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

📌 Fixes

Related #70 — this covers the maintained AJAX entry point and failure paths. Successful synchronization and controller consolidation remain outside this patch, so the issue should stay open.

📝 Summary of Changes

#365 covers the two private error serializers. These tests dispatch fossasia_sync_eventyay through WordPress to protect the wiring and the checks before those serializers run.

  • Verify the action is registered on Wpfaevent_Admin and has no unauthenticated counterpart.
  • Verify an invalid nonce, unauthorized user, missing event or missing URL stops the request before HTTP.
  • Exercise upstream 401, malformed JSON and invalid JSON:API payloads through the actual HTTP client and response serializer.
  • Check that sessions requests retain an existing filter and add the expected includes, pagination, timeout and redirect limit.

The HTTP response is intercepted by pre_http_request; the action dispatcher, nonce/capability checks, controller and JSON serialization use the WordPress test framework. No production code changes.

📸 Screenshots / Demo (if UI-related)

Not applicable; this adds PHP regression coverage without changing the UI.

✅ Checklist

  • I’ve tested my changes locally
  • I’ve added tests (if applicable)
  • I’ve updated documentation (if applicable)
  • My code follows the project’s code style guidelines

Validation ran remotely on a fork-only Ubuntu runner with PHP 8.2, WordPress's test framework and a disposable MySQL database. No local PHP run is claimed. Validation run: composer test passes (247 tests, 1049 assertions), composer phpcs passes, and composer phpstan passes (89 files). Removing the maintained AJAX action registration causes all eight new cases to fail. The final test file byte-matches the validated artifact. No documentation change is needed.

👀 Reviewer Notes

The new tests should pass on current main. Removing the maintained action registration is a mutation check for the missing-hook regression described in #70, not a claim that main still has that defect. The tests use separate PHP processes so WordPress can emit HTTP headers.

Codex (GPT-6) assisted with inspecting the issue and existing implementation, writing the tests, and checking validation results. This is a tests-only follow-up to the maintainer's coverage request.

Summary by Sourcery

Expand regression coverage for the maintained Eventyay AJAX synchronization workflow and its failure paths.

Enhancements:

  • Add regression coverage for the maintained Eventyay AJAX synchronization entry point, including request guards, upstream failures, malformed responses, and API payload validation.
  • Verify Eventyay session requests preserve existing filters and apply the expected query and transport settings.

Tests:

  • Add WordPress AJAX integration tests covering hook registration, authentication and input validation, HTTP failure handling, and response serialization.

Summary by CodeRabbit

  • Tests
    • Added automated coverage for admin sync action registration and failure responses, including authorization checks, missing input, upstream errors, malformed responses, and invalid data.

@sourcery-ai

sourcery-ai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds tests-only WordPress AJAX regression coverage for the maintained Eventyay synchronization entry point, validating hook wiring, security and input guards, upstream error serialization, and HTTP request configuration without changing production code.

File-Level Changes

Change Details Files
Add end-to-end regression coverage for the maintained Eventyay AJAX action, including hook registration, request guards, transport behavior, and serialized failures.
  • Verify the action delegates through Wpfaevent_Admin and has no unauthenticated hook.
  • Exercise nonce, capability, event ID, and API URL validation before any HTTP request.
  • Cover upstream 401, malformed JSON, and invalid JSON:API payload responses through the real AJAX dispatcher and HTTP client.
  • Assert Eventyay sessions query parameters and HTTP timeout/redirect settings.
  • Run failure scenarios in separate processes and clean up filters, request globals, and generated files.
tests/unit/EventyayAjaxHandlerTest.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 953cce21-fab4-42f5-b796-66cd87d82e7b
Commits

Reviewing files that changed from the base of the PR and between af771bf and 623961c.

Files selected for processing: 1
  • tests/unit/EventyayAjaxHandlerTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Adds unit tests for the authenticated admin sync action and its failure responses. The tests cover nonce, authorization, input, upstream response, JSON, and payload failures.

Changes: AJAX handler tests

Layer / File(s) Summary
Sync action registration
tests/unit/EventyayAjaxHandlerTest.php
Checks that the authenticated admin sync action is registered to Wpfaevent_Admin::ajax_sync_eventyay and that no unauthenticated hook is registered.
AJAX failure scenarios
tests/unit/EventyayAjaxHandlerTest.php
Uses a data provider to test seven failure scenarios. Checks termination, response status and message, request count, selected request parameters, and upstream error details.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

Suggested reviewers: ubayed-bin-sufian, arpan7sarkar

Merge Risk: Minimal · up to 62396

No actionable merge blocker is identified; the test-only change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: adding tests for maintained Eventyay AJAX failure paths. It is concise and specific.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Ubayed-Bin-Sufian

This comment was marked as off-topic.

@Ubayed-Bin-Sufian Ubayed-Bin-Sufian left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM and thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants