Fix stale app UI (supabase) & overall E2E test infra improvements (#337)

Fixes #269
This commit is contained in:
Will Chen
2025-06-04 23:07:59 -07:00
committed by GitHub
parent 7f410ce830
commit 16bf0828f5
21 changed files with 203 additions and 96 deletions

View File

@@ -3,10 +3,15 @@ import { db } from "../../db";
import { eq } from "drizzle-orm";
import { apps } from "../../db/schema";
import { getSupabaseClient } from "../../supabase_admin/supabase_management_client";
import { createLoggedHandler } from "./safe_handle";
import {
createLoggedHandler,
createTestOnlyLoggedHandler,
} from "./safe_handle";
import { handleSupabaseOAuthReturn } from "../../supabase_admin/supabase_return_handler";
const logger = log.scope("supabase_handlers");
const handle = createLoggedHandler(logger);
const testOnlyHandle = createTestOnlyLoggedHandler(logger);
export function registerSupabaseHandlers() {
handle("supabase:list-projects", async () => {
@@ -36,4 +41,42 @@ export function registerSupabaseHandlers() {
logger.info(`Removed Supabase project association for app ${app}`);
});
testOnlyHandle(
"supabase:fake-connect-and-set-project",
async (
event,
{ appId, fakeProjectId }: { appId: number; fakeProjectId: string },
) => {
// Call handleSupabaseOAuthReturn with fake data
handleSupabaseOAuthReturn({
token: "fake-access-token",
refreshToken: "fake-refresh-token",
expiresIn: 3600, // 1 hour
});
logger.info(
`Called handleSupabaseOAuthReturn with fake data for app ${appId} during testing.`,
);
// Set the supabase project for the currently selected app
await db
.update(apps)
.set({
supabaseProjectId: fakeProjectId,
})
.where(eq(apps.id, appId));
logger.info(
`Set fake Supabase project ${fakeProjectId} for app ${appId} during testing.`,
);
// Simulate the deep link event
event.sender.send("deep-link-received", {
type: "supabase-oauth-return",
url: "https://supabase-oauth.dyad.sh/api/connect-supabase/login",
});
logger.info(
`Sent fake deep-link-received event for app ${appId} during testing.`,
);
},
);
}