Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Http/ResolveActionAttempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static function get_action_attempt(
): ActionAttempt {
$res = Body::decode(
$client->request("GET", "/action_attempts/get", [
"json" => (object) ["action_attempt_id" => $action_attempt_id],
"query" => ["action_attempt_id" => $action_attempt_id],
]),
);

Expand Down
43 changes: 43 additions & 0 deletions tests/WaitForActionAttemptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Seam\Resources\ActionAttempt;
use Seam\Seam;
use Tests\Support\FakeSeamConnectTestCase;
use Tests\Support\RecordingClient;

final class WaitForActionAttemptTest extends FakeSeamConnectTestCase
{
Expand Down Expand Up @@ -360,6 +361,48 @@ public static function invalidWaitOptions(): array
* than the route client, so enabling the option on the route that reads
* action attempts cannot recurse.
*/
public function testPollSendsTheIdAsAQueryNotABody(): void
{
$recorder = new RecordingClient([
RecordingClient::json(200, [
"action_attempt" => [
"action_attempt_id" => "aa_1",
"status" => "pending",
],
]),
RecordingClient::json(200, [
"action_attempt" => [
"action_attempt_id" => "aa_1",
"status" => "success",
],
]),
]);

$seam = Seam::from_api_key(
"seam_apikey_token",
endpoint: "https://example.com",
guzzle_options: $recorder->guzzle_options(),
retries: 0,
);

$resolved = $seam->action_attempts->get("aa_1", [
"timeout" => 5.0,
"polling_interval" => 0.01,
]);

$this->assertSame("success", $resolved->status);

$poll = $recorder->request(1);

$this->assertSame("GET", $poll->getMethod());
$this->assertSame("/action_attempts/get", $poll->getUri()->getPath());
$this->assertSame(
"action_attempt_id=aa_1&_strict=true",
$poll->getUri()->getQuery(),
);
$this->assertSame("", (string) $poll->getBody());
}

public function testActionAttemptsGetDoesNotRecurse(): void
{
$seam = $this->seam(wait_for_action_attempt: false);
Expand Down
Loading