fix layout SSR translations and remediation follow-ups

This commit is contained in:
2026-08-09 18:49:16 +05:30
parent 51286d0fa3
commit 7d87200e31
10 changed files with 160 additions and 89 deletions
@@ -1,7 +1,6 @@
import { afterEach, expect, test } from "bun:test";
import { implement } from "../../../../../packages/rpc/src/index.ts";
import { handleRpcRequest } from "../../../../../packages/dev-server/src/rpc-dispatch.ts";
import { catalogService } from "../../../packages/shared/src/index.ts";
import catalogServiceImplementation from "../../admin/app/services/catalog.ts";
import { GET } from "../app/api/product.ts";
const secret = process.env.WRNEXUS_RPC_SECRET;
@@ -16,23 +15,17 @@ afterEach(() => {
else process.env.WRNEXUS_INTERNAL_ORIGINS = origins;
});
function startAdmin(allowed: boolean) {
const service = implement(
catalogService,
{ getProduct: ({ sku }) => ({ sku, name: "WRNexus Starter", priceCents: 4900 }) },
{
selfApp: "admin",
checkPermission: (permission, subject) =>
allowed && permission === "catalog:read" && subject?.subjectId === "demo-user",
},
);
function startAdmin() {
return Bun.serve({
port: 0,
hostname: "127.0.0.1",
async fetch(request) {
return (
(await handleRpcRequest(request, new URL(request.url), new Map([["catalog", service]]))) ??
new Response("Not found", { status: 404 })
(await handleRpcRequest(
request,
new URL(request.url),
new Map([["catalog", catalogServiceImplementation]]),
)) ?? new Response("Not found", { status: 404 })
);
},
});
@@ -41,7 +34,7 @@ function startAdmin(allowed: boolean) {
test("web calls admin through private RPC when permitted", async () => {
process.env.WRNEXUS_RPC_SECRET = "test-rpc-secret-at-least-32-chars-long";
process.env.WRNEXUS_APP_NAME = "web";
const server = startAdmin(true);
const server = startAdmin();
process.env.WRNEXUS_INTERNAL_ORIGINS = JSON.stringify({
admin: `http://127.0.0.1:${server.port}`,
});
@@ -62,7 +55,7 @@ test("web calls admin through private RPC when permitted", async () => {
test("web returns 403 when admin denies catalog:read", async () => {
process.env.WRNEXUS_RPC_SECRET = "test-rpc-secret-at-least-32-chars-long";
process.env.WRNEXUS_APP_NAME = "web";
const server = startAdmin(false);
const server = startAdmin();
process.env.WRNEXUS_INTERNAL_ORIGINS = JSON.stringify({
admin: `http://127.0.0.1:${server.port}`,
});