Inspired by BulletProof React, I applied its codebase architecture concepts to the Umami codebase.
This article focuses only on the testing strategies used in Umami codebase.
Prerequisites
Testing in Umami codebase — Part 1.0
Testing in Umami codebase — Part 1.1
Testing in Umami codebase — Part 1.2
Testing in Umami codebase — Part 1.3
In part 1.1, we reviewed the website.cy.ts. It has the test cases for adding, editing and deleting a website. In this part 1.2, we reviewed the login.cy.ts test cases. In this part 1.3, we reviewed the api-website.cy.ts. In this part 1.4, we review the api-user.cy.ts.
I found the following test cases defined in api-user.cy.ts
Creates a user
Returns all users. Admin access is required.
Updates a user.
Gets a user by ID.
Deletes a user.
In the Part 1.3, we looked at what a fixture is. let’s choose one test case, #2 and review it.
Returns all users. Admin access is required.
You will find the following code at L30 in api-user.cy.ts:
it('Returns all users. Admin access is required.', () => {
cy.request({
method: 'GET',
url: '/api/admin/users',
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
},
}).then(response => {
expect(response.status).to.eq(200);
expect(response.body.data[0]).to.have.property('id');
expect(response.body.data[0]).to.have.property('username');
expect(response.body.data[0]).to.have.property('password');
expect(response.body.data[0]).to.have.property('role');
});
});
This is just a cy.request and validations are made using expect
About me:
Hey, my name is Ramu Narasinga. I study codebase architecture in large open-source projects.
Email: ramu.narasinga@gmail.com
I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects at thinkthroo.com

Top comments (0)