mufidu / booku

0 stars 1 forks source link

Sweep: Create unit test for JSON structure in books by author endpoint #87

Closed mufidu closed 5 months ago

mufidu commented 5 months ago

Details

File: booksByAuthor.test.js. Endpoint: /author/:authorName. Create a new test tto test whether the response is in valid JSON. There is already an example in bookCategory.test.js.

Checklist - [X] Modify `test/booksByAuthor.test.js` ✓ https://github.com/mufidu/booku/commit/df29068ebdab6523b25ff2af569de709d6d122c0 [Edit](https://github.com/mufidu/booku/edit/sweep/create_unit_test_for_json_structure_in_b/test/booksByAuthor.test.js) - [X] Running GitHub Actions for `test/booksByAuthor.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/create_unit_test_for_json_structure_in_b/test/booksByAuthor.test.js)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #89

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 3c0d63da68)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/mufidu/booku/blob/0001e73ae4db9531783546177f8d5f0484e959ac/test/bookCategory.test.js#L62-L77 https://github.com/mufidu/booku/blob/0001e73ae4db9531783546177f8d5f0484e959ac/test/booksByAuthor.test.js#L1-L45

Step 2: ⌨️ Coding

--- 
+++ 
@@ -27,6 +27,17 @@
       expect(book.author).to.equal(authorName);
     });

+  it('should return books with the correct structure for a valid author name', async () => {
+    const authorName = 'Valid Author';
+    const res = await chai.request(server).get(`/books/author/${authorName}`).set('Authorization', `Bearer ${token}`);
+    expect(res).to.have.status(200);
+    expect(res.body).to.be.an('array');
+    res.body.forEach(book => {
+      expect(book).to.include.keys('title', 'author', 'year', 'category');
+      expect(book).to.not.have.any.keys('id', '_v');
+    });
+  });
+
   });

   it('should handle invalid author names gracefully', async () => {

Ran GitHub Actions for df29068ebdab6523b25ff2af569de709d6d122c0:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/create_unit_test_for_json_structure_in_b.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.