api-platform / demo

Demo app for the API Platform framework
https://demo.api-platform.com
MIT License
295 stars 197 forks source link

Refactor admin app to prepare v5 migration #425

Closed fzaninotto closed 1 month ago

fzaninotto commented 1 month ago

The admin code was hard to dive in for a regular react-admin developer. I applied the conventions we use in react-admin to make it more maintaineable.

This will facilitate the react-admin v5 migration.

Q A
Branch? main
Tickets no ticket
License MIT
Doc PR
fzaninotto commented 1 month ago

I don't understand the linter failure. It tries to validate a file that was moved elsewhere...

vincentchalamon commented 1 month ago

Hi @fzaninotto,

Thanks for this refactor, it needed it! As a backend developer, I tried my best to have an admin almost correct, so don't hesitate if you find some other fixes to do in the pwa.

I fixed the CI on main, can you rebase from it to fix it in your PR please?

vincentchalamon commented 1 month ago

Thanks @fzaninotto

fzaninotto commented 1 month ago

Thanks for merging! However, I see that some e2e tests aren't passing. I don't know how to launch them locally, so I'd appreciate a hand to fix these tests.

vincentchalamon commented 1 month ago

Thanks for merging! However, I see that some e2e tests aren't passing. I don't know how to launch them locally, so I'd appreciate a hand to fix these tests.

E2E tests may suffer false-errors due to GitHub Runners performances.

To run the E2E tests locally, I first set a .env file at the root path of the project with the following contents:

AUTH_SECRET=3xVEsEb/fD0k5EyVbERzQcIWvgNnko5DVPpHbZdyXlk=
CADDY_MERCURE_JWT_SECRET=!ChangeThisMercureHubJWTSecretKey!
PHP_DOCKER_IMAGE=api-platform-demo/php
PWA_DOCKER_IMAGE=api-platform-demo/pwa
KEYCLOAK_DOCKER_IMAGE=api-platform-demo/keycloak
APP_SECRET=427dff72d1aebf47de03ec08f012d369f4bde2d2
POSTGRES_PASSWORD=!ChangeMe!
KEYCLOAK_POSTGRES_PASSWORD=!ChangeMe!
KEYCLOAK_ADMIN_PASSWORD=!ChangeMe!
COMPOSE_FILE=compose.yaml:compose.prod.yaml:compose.e2e.yaml

Note: most of those environment variables are only required in compose.prod.yaml, but E2E tests run on iso-prod environment (cf. COMPOSE_FILE environment variable).

Then I build the images iso-prod:

docker compose build

And start the project:

docker compose up --wait

Must load the fixtures before any call:

docker compose exec php bin/console doctrine:fixtures:load --no-interaction

Finally, the E2E tests can be ran:

cd pwa
pnpm install
pnpm exec playwright test --ui
vincentchalamon commented 1 month ago

Currently, the rating filter on admin/reviews list has disappeared: https://github.com/api-platform/demo/actions/runs/9904379649/job/27362430448

And my too little knownledge on TS and React-Admin doesn't help me to fix it :smile: