Skip to content

Commit 4eb58b3

Browse files
committed
minor #3235 Add E2E tests for LiveComponent (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- Add E2E tests for LiveComponent | Q | A | -------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Documentation? | no <!-- required for new features, or documentation updates --> | Issues | Fix #3021 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT This PR adds the following examples & associated tests. To resume, there are basic examples with LiveProp and LiveAction, advanced examples (form auto-validation & examples filtering), and advanced use-cases with the hydration/dehydration/serialization (to double-prevent some BCs from the past 🙈 ) <img width="1231" height="954" alt="image" src="https://github.com/user-attachments/assets/a6f2480d-3606-42de-938c-a29649efee73" /> Commits ------- 55e2ab2 Add E2E tests for LiveComponent
2 parents 4523fce + 55e2ab2 commit 4eb58b3

File tree

72 files changed

+1625
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1625
-134
lines changed

apps/e2e/.symfony.local.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
http:
22
port: 9876
3+
no_tls: true
Lines changed: 1 addition & 0 deletions
Loading

apps/e2e/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"symfony/http-client": "6.4.*|7.3.*",
3939
"symfony/intl": "6.4.*|7.3.*",
4040
"symfony/monolog-bundle": "^3.10",
41+
"symfony/property-access": "6.4.*|7.3.*",
42+
"symfony/property-info": "6.4.*|7.3.*",
4143
"symfony/runtime": "6.4.*|7.3.*",
44+
"symfony/serializer": "6.4.*|7.3.*",
4245
"symfony/stimulus-bundle": "^2.29.1",
4346
"symfony/twig-bundle": "6.4.*|7.3.*",
4447
"symfony/ux-autocomplete": "^2.29.1",

apps/e2e/src/Controller/AutocompleteController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
use Symfony\Component\HttpFoundation\Response;
99
use Symfony\Component\Routing\Attribute\Route;
1010

11-
#[Route('/ux-autocomplete')]
11+
#[Route('/ux-autocomplete', name: 'app_ux_autocomplete_')]
1212
final class AutocompleteController extends AbstractController
1313
{
14-
#[Route('/without-ajax')]
14+
#[Route('/without-ajax', name: 'without_ajax')]
1515
public function withoutAjax(): Response
1616
{
1717
$formBuilder = $this->createFormBuilder();
@@ -47,7 +47,7 @@ public function withoutAjax(): Response
4747
]);
4848
}
4949

50-
#[Route('/with-ajax')]
50+
#[Route('/with-ajax', name: 'with_ajax')]
5151
public function withAjax(): Response
5252
{
5353
$formBuilder = $this->createFormBuilder();
@@ -60,7 +60,7 @@ public function withAjax(): Response
6060
]);
6161
}
6262

63-
#[Route('/custom-controller')]
63+
#[Route('/custom-controller', name: 'custom_controller')]
6464
public function customController(): Response
6565
{
6666
return $this->render('ux_autocomplete/custom_controller.html.twig');

apps/e2e/src/Controller/ChartjsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
99
use Symfony\UX\Chartjs\Model\Chart;
1010

11-
#[Route('/ux-chartjs')]
11+
#[Route('/ux-chartjs', name: 'app_ux_chartjs_')]
1212
final class ChartjsController extends AbstractController
1313
{
14-
#[Route('/without-options')]
14+
#[Route('/without-options', name: 'without_options')]
1515
public function withoutOptions(ChartBuilderInterface $chartBuilder): Response
1616
{
1717
$chart = $chartBuilder->createChart(Chart::TYPE_LINE);
@@ -33,7 +33,7 @@ public function withoutOptions(ChartBuilderInterface $chartBuilder): Response
3333
]);
3434
}
3535

36-
#[Route('/with-options')]
36+
#[Route('/with-options', name: 'with_options')]
3737
public function withOptions(ChartBuilderInterface $chartBuilder): Response
3838
{
3939
$chart = $chartBuilder->createChart(Chart::TYPE_LINE);

apps/e2e/src/Controller/CropperjsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use Symfony\Component\HttpFoundation\Response;
77
use Symfony\Component\Routing\Attribute\Route;
88

9-
#[Route('/ux-cropperjs')]
9+
#[Route('/ux-cropperjs', name: 'app_ux_cropperjs_')]
1010
final class CropperjsController extends AbstractController
1111
{
12-
#[Route('/')]
12+
#[Route('/', name: 'index')]
1313
public function index(): Response
1414
{
1515
return $this->render('ux_cropperjs/index.html.twig', [

apps/e2e/src/Controller/DropzoneController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use Symfony\Component\HttpFoundation\Response;
77
use Symfony\Component\Routing\Attribute\Route;
88

9-
#[Route('/ux-dropzone')]
9+
#[Route('/ux-dropzone', name: 'app_ux_dropzone_')]
1010
final class DropzoneController extends AbstractController
1111
{
12-
#[Route('/')]
12+
#[Route('/', name: 'index')]
1313
public function index(): Response
1414
{
1515
return $this->render('ux_dropzone/index.html.twig', [

apps/e2e/src/Controller/HomeController.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22

33
namespace App\Controller;
44

5-
use App\Repository\ExampleRepository;
65
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
76
use Symfony\Component\HttpFoundation\Response;
87
use Symfony\Component\Routing\Attribute\Route;
98

109
final class HomeController extends AbstractController
1110
{
1211
#[Route('/', name: 'app_home')]
13-
public function index(ExampleRepository $exampleRepository): Response
12+
public function index(): Response
1413
{
15-
return $this->render('home.html.twig', [
16-
'examples_by_package' => $exampleRepository->findAllByPackage(),
17-
]);
14+
return $this->render('home.html.twig');
1815
}
1916
}

apps/e2e/src/Controller/IconsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use Symfony\Component\HttpFoundation\Response;
77
use Symfony\Component\Routing\Attribute\Route;
88

9-
#[Route('/ux-icons')]
9+
#[Route('/ux-icons', name: 'app_ux_icons_')]
1010
final class IconsController extends AbstractController
1111
{
12-
#[Route('/')]
12+
#[Route('/', name: 'index')]
1313
public function index(): Response
1414
{
1515
return $this->render('ux_icons/index.html.twig', [

apps/e2e/src/Controller/LiveComponentController.php

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,68 @@
66
use Symfony\Component\HttpFoundation\Response;
77
use Symfony\Component\Routing\Attribute\Route;
88

9-
#[Route('/ux-live-component')]
9+
#[Route('/ux-live-component', name: 'app_ux_live_component_')]
1010
final class LiveComponentController extends AbstractController
1111
{
12-
#[Route('/')]
13-
public function index(): Response
12+
#[Route('/counter', name: 'counter')]
13+
public function counter(): Response
1414
{
15-
return $this->render('ux_live_component/index.html.twig', [
16-
'controller_name' => 'LiveComponentController',
15+
return $this->render('ux_live_component/counter.html.twig');
16+
}
17+
18+
#[Route('/registration-form', name: 'registration_form')]
19+
public function registrationForm(): Response
20+
{
21+
return $this->render('ux_live_component/registration_form.html.twig');
22+
}
23+
24+
#[Route('/fruits/{page?1}', name: 'fruits')]
25+
public function fruits(int $page): Response
26+
{
27+
return $this->render('ux_live_component/fruits.html.twig', [
28+
'page' => $page,
1729
]);
1830
}
31+
32+
#[Route('/with-dto', name: 'with_dto')]
33+
public function withDto(): Response
34+
{
35+
return $this->render('ux_live_component/with_dto.html.twig');
36+
}
37+
38+
#[Route('/with-dto-collection', name: 'with_dto_collection')]
39+
public function withDtoCollection(): Response
40+
{
41+
return $this->render('ux_live_component/with_dto_collection.html.twig');
42+
}
43+
44+
#[Route('/with-dto-and-serializer', name: 'with_dto_and_serializer')]
45+
public function withDtoAndSerializer(): Response
46+
{
47+
return $this->render('ux_live_component/with_dto_and_serializer.html.twig');
48+
}
49+
50+
#[Route('/with-dto-and-custom-hydration-methods', name: 'with_dto_and_custom_hydration_methods')]
51+
public function withDtoAndCustomHydrationMethods(): Response
52+
{
53+
return $this->render('ux_live_component/with_dto_and_custom_hydration_methods.html.twig');
54+
}
55+
56+
#[Route('/with-dto-and-hydration-extension', name: 'with_dto_and_hydration_extension')]
57+
public function withDtoAndHydrationExtension(): Response
58+
{
59+
return $this->render('ux_live_component/with_dto_and_hydration_extension.html.twig');
60+
}
61+
62+
#[Route('/item-list', name: 'item_list')]
63+
public function itemList(): Response
64+
{
65+
return $this->render('ux_live_component/item_list.html.twig');
66+
}
67+
68+
#[Route('/with-aliased-live-props', name: 'with_aliased_live_props')]
69+
public function withAliasedLiveProps(): Response
70+
{
71+
return $this->render('ux_live_component/with_aliased_live_props.html.twig');
72+
}
1973
}

0 commit comments

Comments
 (0)