Skip to content

Commit

Permalink
minor #1064 [LiveComponent] Fix tests now that a live id is always ad…
Browse files Browse the repository at this point in the history
…ded, even for embedded components (sneakyvv)

This PR was merged into the 2.x branch.

Discussion
----------

[LiveComponent] Fix tests now that a live id is always added, even for embedded components

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Tickets       |
| License       | MIT

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 embedded live components branch, so it now needed to be synced with those changes.

The conflicting change: https://github.com/symfony/ux/pull/913/files#diff-c1c2695c57da687bdba39e2b9e5285f30e9b87f50886bf645a048545575f6659

Commits
-------

b49ca61 [LiveComponent] Fix tests now that a live id is always added
  • Loading branch information
weaverryan committed Aug 21, 2023
2 parents 71aebf1 + b49ca61 commit 39a938d
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 39a938d

Please sign in to comment.