Files
supabase/e2e/studio/utils/db/client.ts
Ali Waseem c7f653f33f chore: move api solution to storage and parallelize tests (#42565)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

- Move storage tests to run in parallel
- Updated utils to use env

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Improved test reliability by shifting storage bucket setup and cleanup
from UI-based to API-backed operations.
* Enhanced test isolation with streamlined prerequisite navigation
steps.

* **Chores**
* Updated environment configuration to support dynamic API URL and
service role key settings.
* Refactored internal storage management utilities for improved
maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-06 10:50:41 -07:00

31 lines
976 B
TypeScript

import { env } from "../../env.config.js"
/**
* Execute a SQL query against the local Supabase database via pg-meta.
*
* Uses the local Supabase API gateway to route to pg-meta, which executes
* the query against PostgreSQL using the default local connection.
*
* @param sql - The SQL query to execute
* @param params - Optional array of parameters for parameterized queries
* @returns Array of result rows
* @throws Error if the query fails
*/
export async function query<T>(sql: string, params?: Array<unknown>): Promise<Array<T>> {
const response = await fetch(`${env.API_URL}/pg/query`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
apikey: env.SERVICE_ROLE_KEY,
},
body: JSON.stringify({ query: sql, parameters: params }),
})
if (!response.ok) {
const error = await response.json()
throw new Error(`Database query failed: ${error.message || JSON.stringify(error)}`)
}
return response.json()
}