The first week of coding period flew by in almost no time and we are here, about to start the second week.
Implementing Search Feature
Coming to the work I did this week, I finished implementing the stories search feature. This provides our users the facility to search for stories by title and by the author name as well. To implement the search by title feature, I used the Title_contains filter provided by the Strapi GraphQL API. This filter basically takes an input string and returns all those stories whose title contains the input string as a sub-string. The resulting stories fetched are then updated on the frontend. To implement search by story author, I had to perform two steps: first, search the author by username as the user types in, by using a approach similar to the one mentioned earlier, and recommend them to the user. Second, once the user finds the author name, search for all the stories created by that particular author and return them. Again Strapi provides queries in its GraphQL API to perform these kinds of filtering. To implement the user suggestion on the front-end, I created a custom React component that makes API requests to the back-end to fetch the user info and displays them. I also used the axios.CancelToken to cancel the older, unfinished requests as the client makes newer ones, so as to reduce the load on server.
So here is the link to the PR: Implement Search
Setting up Github Actions to run Cypress tests
Apart from that I also worked on setting up Github Actions to run Cypress tests for the front-end. However, the challenging part in this was to seed the database to run the end-to-end tests. So for that, I worked on a script that automatically seeds the database with some sample data when strapi starts-up. Finally, we can create a Docker image of this strapi server and use it to run the end-to-end tests in Github Actions CI pipeline. Below are the links to the corresponding PRs.
- Added configuration to seed the database in test & development modes
- Updated github actions to run Cypress tests
I will get these reviewed by my mentors this week and work on getting these merged, so that we can start writing the tests. Also I will start working on the request templates feature this week. So that's all for this blog post.