Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+59
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { isAdminSurface, isAppOrAdminSurface, isAppSurface } from "./HostAwareSurface";
|
||||
|
||||
const routing = {
|
||||
appBaseDomain: "example.test",
|
||||
webAppHost: "app.example.test",
|
||||
adminAppHost: "admin.example.test",
|
||||
apiHost: "api.example.test",
|
||||
protocol: "https",
|
||||
} as const;
|
||||
|
||||
describe("HostAwareSurface", () => {
|
||||
test("classifies canonical app and admin hosts by request origin", () => {
|
||||
expect(
|
||||
isAppSurface(
|
||||
{
|
||||
serverUrl: "https://app.example.test",
|
||||
publicBaseUrl: "https://example.test",
|
||||
routing,
|
||||
},
|
||||
"/acme/dashboard"
|
||||
)
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
isAdminSurface(
|
||||
{
|
||||
serverUrl: "https://admin.example.test",
|
||||
publicBaseUrl: "https://example.test",
|
||||
routing,
|
||||
},
|
||||
"/dashboard"
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test("keeps public routes on the web app host out of app chrome", () => {
|
||||
const input = {
|
||||
serverUrl: "https://app.example.test",
|
||||
publicBaseUrl: "https://example.test",
|
||||
routing,
|
||||
};
|
||||
|
||||
expect(isAppSurface(input, "/docs/getting-started")).toBe(false);
|
||||
expect(isAppOrAdminSurface(input, "/docs/getting-started")).toBe(false);
|
||||
expect(isAppSurface(input, "/acme/dashboard")).toBe(true);
|
||||
});
|
||||
|
||||
test("keeps admin host settings classified as admin chrome", () => {
|
||||
const input = {
|
||||
serverUrl: "https://admin.example.test",
|
||||
publicBaseUrl: "https://example.test",
|
||||
routing,
|
||||
};
|
||||
|
||||
expect(isAdminSurface(input, "/settings/profile")).toBe(true);
|
||||
expect(isAppOrAdminSurface(input, "/settings/profile")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user