gothinkster / realworld

"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
https://www.realworld.how/
MIT License
80.46k stars 7.32k forks source link

[Bug]: expectation order of the tags in the tests is incorrect. #839

Open KostyaTretyak opened 2 years ago

KostyaTretyak commented 2 years ago

Relevant scope

Backend specs

Description

In post article body we have in the first place tag training:

https://github.com/gothinkster/realworld/blob/a3855ae3a346e7bcb809dcddcc057bd13edc0c19/api/Conduit.postman_collection.json#L683

But in tests we expected tag dragons in the first place:

https://github.com/gothinkster/realworld/blob/a3855ae3a346e7bcb809dcddcc057bd13edc0c19/api/Conduit.postman_collection.json#L1204-L1205

But why? If there is logic in this, it should be described somewhere in the docs. It seems to me that this is a bug.

cirosantilli commented 2 years ago

I think tag list is just not specified in the spec as it should be.

I assume they are just sorting alphabetically which is a reasonable choice if the tag name is the primary key on the database.

However, I would prefer even better if tags were sorted by descending creation timestamp instead (or maybe updated time, and we can update updated time whenever the tag is applied to an article), as this will create a better user experience for people testing an implementation interactively. You create an article with a new tag, then go back to index, and then easily find your tag without Ctrl + F.

If we go with the timestamp route, I propose that the test should just sort the tags, as results won't be very deterministic when multiple tags are created more or less at the same time with the same post.

Another option would be to sort by most applied tags. This would also be helpful for autocomplete: https://github.com/gothinkster/realworld/discussions/784

geromegrignon commented 2 years ago

Indeed, we need to add rules about sorting in specs. Meanwhile and to avoid breaking existing implementations, I'll create a PR to test tags regardless of their order. I'm waiting for a review on #490 before (as there is a format change on the JSON file).