Add account based multiplayer hosting and bug report retention
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { randomUUID, randomBytes } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import { chromium, expect } from "@playwright/test";
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
@@ -9,7 +10,8 @@ const db = createClient(
|
||||
process.env.SUPABASE_SECRET_KEY,
|
||||
{ auth: { persistSession: false, autoRefreshToken: false } },
|
||||
);
|
||||
const rooms = [];
|
||||
const rooms = [],
|
||||
accounts = [];
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ["--use-angle=swiftshader", "--enable-unsafe-swiftshader"],
|
||||
@@ -34,6 +36,21 @@ try {
|
||||
});
|
||||
const host = await desktop.newPage(),
|
||||
friend = await mobile.newPage();
|
||||
const email = `multiplayer-browser-${randomUUID()}@example.com`,
|
||||
password = randomBytes(24).toString("base64url");
|
||||
const fixture = await db.auth.admin.createUser({
|
||||
email,
|
||||
password,
|
||||
email_confirm: true,
|
||||
user_metadata: { display_name: "Browser Host" },
|
||||
});
|
||||
if (fixture.error) throw fixture.error;
|
||||
accounts.push(fixture.data.user.id);
|
||||
const loggedIn = await desktop.request.post(`${origin}/api/v1/auth`, {
|
||||
headers: { origin },
|
||||
data: { action: "login", email, password },
|
||||
});
|
||||
assert.equal(loggedIn.status(), 200);
|
||||
const pageErrors = [];
|
||||
for (const page of [host, friend])
|
||||
page.on("pageerror", (error) => pageErrors.push(error.message));
|
||||
@@ -42,7 +59,10 @@ try {
|
||||
timeout: 60000,
|
||||
});
|
||||
await host.getByRole("button", { name: "Multiplayer", exact: true }).click();
|
||||
await host.getByLabel("Your player name").fill("Browser Host");
|
||||
await expect(host.locator(".multiplayer-settings")).toContainText(
|
||||
"Browser Host",
|
||||
);
|
||||
await expect(host.getByLabel("Your player name")).toHaveCount(0);
|
||||
await host.getByLabel("Player limit (including you)").selectOption("2");
|
||||
await host
|
||||
.getByRole("button", { name: "Create multiplayer room", exact: true })
|
||||
@@ -248,4 +268,10 @@ try {
|
||||
if (error)
|
||||
throw new Error(`Browser test-room cleanup failed: ${error.message}`);
|
||||
}
|
||||
for (const id of accounts) {
|
||||
const profile = await db.from("profiles").delete().eq("id", id);
|
||||
if (profile.error) throw profile.error;
|
||||
const account = await db.auth.admin.deleteUser(id);
|
||||
if (account.error) throw account.error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user