Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

updated ProjectUsage test to test for value rendering

TzeYiing8bc315542556
diff --git a/studio/tests/components/Home/ProjectUsage.test.js b/studio/tests/components/Home/ProjectUsage.test.js
index b141493aff8..e87eb1142fd 100644
--- a/studio/tests/components/Home/ProjectUsage.test.js
+++ b/studio/tests/components/Home/ProjectUsage.test.js
@@ -14,14 +14,36 @@ beforeEach(() => {
})
test('mounts correctly', async () => {
- get.mockResolvedValueOnce({
- data: { data: [{ auth: 123, realtime: 223, storage: 323 }] },
- total: 123 + 223 + 323,
- totalAverage: 123 + 223 + 323,
- totalGrouped: { auth: 123, realtime: 223, storage: 323 },
+ get.mockImplementation((url) => {
+ if (url.includes('usage')) return {}
+ return {
+ data: {
+ data: [
+ {
+ total_auth_requests: 123,
+ total_realtime_requests: 223,
+ total_storage_requests: 323,
+ total_rest_requests: 333,
+ timestamp: new Date().getTime() / 1000,
+ },
+ ],
+ total: 123 + 223 + 323,
+ totalAverage: 123 + 223 + 323,
+ totalGrouped: {
+ total_auth_requests: 123,
+ total_realtime_requests: 223,
+ total_storage_requests: 323,
+ total_rest_requests: 333,
+ },
+ },
+ }
})
render(<ProjectUsage project="12345" />)
await waitFor(() => screen.getByText('Statistics for past 24 hours'))
+ await waitFor(() => screen.getByText(/123/))
+ await waitFor(() => screen.getByText(/223/))
+ await waitFor(() => screen.getByText(/323/))
+ await waitFor(() => screen.getByText(/333/))
})
test.todo('dropdown options changes chart query')