feat(test): add HTTP test client for integration testing#2099
Merged
feat(test): add HTTP test client for integration testing#2099
Conversation
Adds a fluent HTTP test client inspired by Laravel's test helpers. TestClient provides chainable request methods (get/post/put/patch/delete) and assertion methods (assertStatus/assertSee/assertJson/etc.) for writing concise integration tests. WheelsTest gains visit() and $testClient() helpers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix cookie parsing bug: values containing '=' were truncated (ListToArray split on every '='; now uses Find/Mid for first '=' only) - Make $makeRequest and $assertionError private (standalone CFC, not mixin) - Remove redundant exact-match check in assertRedirect() - Change assertJsonPath to 1-based array indexing (CFML convention) - Rename 'client' variable to 'tc' in spec (CFML reserves 'client' scope) - Remove silent-skip patterns: tests now assert preconditions or fail - Add tests for put(), patch(), delete() methods - Add tests for POST with body (form fields + JSON) - Remove framework reload side effect from assertOk() test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests that called /wheels/core/tests from within the test runner caused a thread pool deadlock on CI (single-threaded Lucee). Replaced with $fakeClient() helper that sets internal response state directly, allowing assertion logic to be tested without live HTTP calls to the test endpoint. Live HTTP tests still use "/" which is safe. Also adds $setFakeResponse() to TestClient for test isolation, and improves assertSeeInOrder/assertJsonPath/assertRedirect coverage using deterministic fake data instead of parsing live HTML responses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lucee 7 cannot resolve statusCode() as a method call when the enclosing function has a parameter named statusCode — the parameter shadows the method name. Renamed parameter to expectedStatus. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root path (/) returns 500 during test runs because the framework is mid-request. Use $fakeClient() for assertOk() and chaining tests that depend on specific status codes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestClient.cfc— a fluent HTTP test client with chainable request methods (get,post,put,patch,delete,visit) and assertion methods (assertStatus,assertOk,assertSee,assertDontSee,assertJson,assertJsonPath,assertRedirect,assertHeader,assertCookie)visit()and$testClient()convenience methods toWheelsTest.cfcso test specs can writevisit("/users").assertOk().assertSee("John")testClientSpec.cfcCloses a gap vs Laravel's HTTP testing and Rails' integration tests identified in
docs/wheels-vs-frameworks.md.Test plan
bash tools/test-local.sh— all existing tests pass (zero regressions)vendor/wheels/tests/specs/internal/testClientSpec.cfcpass🤖 Generated with Claude Code