api-components-bundle icon indicating copy to clipboard operation
api-components-bundle copied to clipboard

New Feature Tests

Open silverbackdan opened this issue 5 years ago • 9 comments

During development, some features may have been added which tests have not been written for in the interest of development speed. Some tests should be written in future for these features.

  • [x] Filtering and ordering of layout resource
  • [ ] Filtering and ordering of page resource
  • [ ] Page data normalization inc. throwing errors if page data not found and skipping if admin user and returning components anyway for page template admin.
  • [ ] OpenApi Factory decorator
  • [ ] UserDataProvider and the /me endpoint is using the username instead of id for lookup

silverbackdan avatar Nov 11 '20 11:11 silverbackdan

Hi @silverbackdan I'd like to try to give this issue a shot.

Can you maybe give me some information for the dev setup? I saw there was a docker-compose file in the v1 branch, is there something similar for the main branch as well?

bofalke avatar Oct 10 '22 17:10 bofalke

Hi @bofalke - that's great thank you. Sorry there's no docker compose in this one. It's dependent on PHP >=8.1 And I think for such a long time now, I've simply been running this as tests to make sure things work. It's installed as a bundle in the template repository in the /api directory. https://github.com/components-web-app/components-web-app

Although you could do this, I want to make your life a lot easier, so I will look to get a docker-compose setup in place tomorrow for you.

The test application is run from tests/Functional/app/ so I'll create some configurations to make this spin up and run nicely so it can be viewed and manually tested easily too.

silverbackdan avatar Oct 10 '22 21:10 silverbackdan

That sounds great, thank you for the support!

I already ran the phpunit test suite locally, that worked fine 👍

I will try and figure out a way to setup a test for the filtering and ordering tasks mentioned in the issue description first

bofalke avatar Oct 11 '22 07:10 bofalke

Thanks. You can see the front-end interacting with the API at https://demo.cwa.rocks The filtering and ordering is done when you login at https://demo.cwa.rocks/login (username and password are both admin) Then in the top bar you can navigate to view layouts and pages etc. https://demo.cwa.rocks/_cwa/layouts?order%5BcreatedAt%5D=desc&page=1

As you search and reorder, you'll see the query-string update. This will be the same querystring to be appended to the request for the API too.

The API is live here: https://api.cwa.rocks/

You could create Behat scenarios to test this functionality. We run Behat for functional tests and PHPUnit for unit tests on the project.

silverbackdan avatar Oct 11 '22 07:10 silverbackdan

You can also run Behat features with ./vendor/bin/behat And see how these tests are run in the Github actions too. I'm sorry I'm being snowed under today but will do my best to have a docker setup going ASAP. might be late this evening or tomorrow.

silverbackdan avatar Oct 11 '22 08:10 silverbackdan

Yeah no worries,

I think the behat tests will run even without a local dev setup so i can start already. I was so focused on the phpunit stuff that i did not see the behat configuration yesterday. Will be my first time actually working with behat but i'll figure it out 👍

Btw I saw your demo of the project at the api platform conference, thats why i wanted to see if i could help out somehow

bofalke avatar Oct 11 '22 09:10 bofalke

Oh amazing, thanks for jumping on board! This is super helpful. Yes I usually just create tests for this project which is why I don't have a docker setup in place right now. :)

silverbackdan avatar Oct 11 '22 09:10 silverbackdan

Shout if you want any help or advice

silverbackdan avatar Oct 11 '22 09:10 silverbackdan

Layouts done: https://github.com/components-web-app/api-components-bundle/pull/150

silverbackdan avatar Oct 26 '22 14:10 silverbackdan