Skip to content

Commit

Permalink
Api som returnerer versionId og server startup time (#385)
Browse files Browse the repository at this point in the history
Planlagt brukt for bedre cache-håndtering i appene
  • Loading branch information
anders-nom authored Jul 9, 2024
1 parent 48e2b85 commit 8d30cc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/client/src/views/chatbot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "./chatbot";
import { BoostClient } from "./chatbot";
import cls from "./chatbot.module.css";

const COOKIE_NAME = "nav-chatbot:conversation";

describe("chatbot", () => {
const old = document.body.appendChild;
let loadedSrc = "";
Expand All @@ -32,7 +34,7 @@ describe("chatbot", () => {

afterEach(() => {
loadedSrc = "";
Cookies.remove("nav-chatbot%3Aconversation");
Cookies.remove(COOKIE_NAME);
});

it("reacts to paramsupdated", async () => {
Expand Down Expand Up @@ -63,7 +65,7 @@ describe("chatbot", () => {
});

it("doesnt remove visible when cookie is set", async () => {
Cookies.set("nav-chatbot%3Aconversation", "value");
Cookies.set(COOKIE_NAME, "value");
updateDecoratorParams({ chatbotVisible: false });
const el = await fixture("<d-chatbot></d-chatbot>");
const child = el.childNodes[0] as HTMLElement;
Expand Down Expand Up @@ -118,7 +120,7 @@ describe("chatbot", () => {
});

it("initializes boost with correct config", async () => {
Cookies.set("nav-chatbot%3Aconversation", "value");
Cookies.set(COOKIE_NAME, "value");
const el = await fixture("<d-chatbot></d-chatbot>");
(el.childNodes[0] as HTMLButtonElement).click();
await boostInitialized();
Expand Down Expand Up @@ -172,21 +174,21 @@ describe("chatbot", () => {
detail: { conversationId: "newId" },
}),
);
expect(Cookies.get("nav-chatbot%3Aconversation")).toBe("newId");
expect(Cookies.get(COOKIE_NAME)).toBe("newId");
chatPanel.dispatchEvent(
new CustomEvent("conversationIdChanged", {
detail: { conversationId: "" },
}),
);
expect(Cookies.get("nav-chatbot%3Aconversation")).toBe(undefined);
expect(Cookies.get(COOKIE_NAME)).toBe(undefined);
});

it("removes cookie on close", async () => {
Cookies.set("nav-chatbot%3Aconversation", "value");
Cookies.set(COOKIE_NAME, "value");
const el = await fixture("<d-chatbot></d-chatbot>");
(el.childNodes[0] as HTMLButtonElement).click();
chatPanel.dispatchEvent(new CustomEvent("chatPanelClosed"));
expect(Cookies.get("nav-chatbot%3Aconversation")).toBe(undefined);
expect(Cookies.get(COOKIE_NAME)).toBe(undefined);
});

it("sets filter value and triggers next actions", async () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { validParams } from "./validateParams";
import { csrAssets } from "./views";
import { MainMenu } from "./views/header/main-menu";

const startupTime = Date.now();

const app = new Hono({
strict: false,
});
Expand All @@ -47,6 +49,9 @@ app.get("/public/assets/*", serveStatic({}));

app.get("/api/isAlive", ({ text }) => text("OK"));
app.get("/api/isReady", ({ text }) => text("OK"));
app.get("/api/version", ({ json }) =>
json({ versionId: env.VERSION_ID, started: startupTime }),
);
app.get("/api/ta", async ({ json }) => {
const result = await getTaskAnalyticsConfig();
if (result.ok) {
Expand Down

0 comments on commit 8d30cc3

Please sign in to comment.