Skip to content

Commit

Permalink
[LiveComponent] Fix tests now that a live id is always added
Browse files Browse the repository at this point in the history
Embedded components can also be live now, so they also need a live-id.

The TestLiveComponent trait was added after the live-id change had been introduced in the embbeded live components branch, so it now needed to be synced with those changes.
  • Loading branch information
sneakyvv committed Aug 20, 2023
1 parent 71aebf1 commit b49ca61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/LiveComponent/src/Test/TestLiveComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function __construct(
) {
$this->client->catchExceptions(false);

$data['attributes']['data-live-id'] ??= 'in-a-real-scenario-it-would-already-have-one---provide-one-yourself-if-needed';

$mounted = $this->factory->create($this->metadata->getName(), $data);
$props = $this->hydrator->dehydrate(
$mounted->getComponent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function testItUseBlocksFromEmbeddedContextUsingMultipleComponents(): voi
})
->post('/_components/component2/increase', [
'headers' => ['X-CSRF-TOKEN' => $token],
'body' => json_encode(['props' => $dehydrated->getProps()]),
'body' => ['data' => json_encode(['props' => $dehydrated->getProps()])],
])
->assertSuccessful()
->assertHeaderContains('Content-Type', 'html')
Expand Down

0 comments on commit b49ca61

Please sign in to comment.