Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions WebUI/src/main/ts/api/publishing/runtimeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface RuntimeEditionStatus {
name?: string;
siteId?: string;
comment?: string;
pubServerId?: string;
runningJobId?: number;
jobStatus?: string;
}
Expand All @@ -48,10 +49,14 @@ function runtimeRoot(): string {

export async function listRuntimeEditions(
siteId: string | number,
pubServerId?: string | number,
): Promise<RuntimeEditionStatus[]> {
const data = await get<unknown>(
`${runtimeRoot()}/editions?siteId=${encodeURIComponent(String(siteId))}`,
);
const params = new URLSearchParams();
params.set("siteId", String(siteId));
if (pubServerId != null && String(pubServerId).trim() !== "") {
params.set("pubServerId", String(pubServerId).trim());
}
const data = await get<unknown>(`${runtimeRoot()}/editions?${params.toString()}`);
return normalizeArray(data);
}

Expand Down
55 changes: 51 additions & 4 deletions WebUI/src/main/ts/publishing/sections/RuntimeSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import React, { useCallback, useEffect, useState } from "react";
import { fetchSites } from "../../api/home/homeApi";
import { listServers } from "../../api/publishing/serversApi";
import type { PublishServer } from "../../api/publishing/types";
import {
clearSiteItems,
demandPublish,
Expand Down Expand Up @@ -59,6 +61,8 @@ export function parseContentIds(raw: string): string[] {
export function RuntimeSection(): React.ReactElement {
const [sites, setSites] = useState<Array<{ name: string; id: string }>>([]);
const [siteId, setSiteId] = useState("");
const [servers, setServers] = useState<PublishServer[]>([]);
const [pubServerId, setPubServerId] = useState("");
const [editions, setEditions] = useState<RuntimeEditionStatus[]>([]);
const [selectedEdition, setSelectedEdition] = useState("");
const [demandIds, setDemandIds] = useState("");
Expand Down Expand Up @@ -89,7 +93,7 @@ export function RuntimeSection(): React.ReactElement {
}
setLoading(true);
setError(null);
listRuntimeEditions(siteId)
listRuntimeEditions(siteId, pubServerId || undefined)
.then((list) => {
setEditions(list);
if (list.length > 0 && !selectedEdition) {
Expand All @@ -98,12 +102,31 @@ export function RuntimeSection(): React.ReactElement {
})
.catch(() => setError(message(MSG.PUBLISH_ERROR)))
.finally(() => setLoading(false));
}, [siteId, selectedEdition]);
}, [siteId, pubServerId, selectedEdition]);

useEffect(() => {
reload();
if (!siteId) {
setServers([]);
setPubServerId("");
return;
}
listServers(siteId)
.then((list) => {
setServers(list);
if (list.length > 0) {
const firstId = String(list[0].serverId ?? list[0].id ?? "");
setPubServerId((prev) => prev || firstId);
} else {
setPubServerId("");
}
})
.catch(() => setServers([]));
}, [siteId]);

useEffect(() => {
reload();
}, [siteId, pubServerId]);

async function onStart(editionId: string): Promise<void> {
setBusy(true);
setError(null);
Expand Down Expand Up @@ -210,6 +233,24 @@ export function RuntimeSection(): React.ReactElement {
))}
</select>
</label>
<label>
Publish server{" "}
<select
data-testid="runtime-pub-server"
value={pubServerId}
onChange={(e) => setPubServerId(e.target.value)}
aria-label="Runtime publish server"
>
{servers.map((s) => {
const id = String(s.serverId ?? s.id ?? "");
return (
<option key={id} value={id}>
{s.serverName ?? s.name ?? id}
</option>
);
})}
</select>
</label>
<button type="button" style={buttonStyle} onClick={reload} disabled={busy}>
Refresh
</button>
Expand Down Expand Up @@ -251,6 +292,7 @@ export function RuntimeSection(): React.ReactElement {
<button
type="button"
style={primaryButtonStyle}
data-testid={`runtime-start-${id}`}
disabled={busy || !id}
onClick={() => void onStart(id)}
>
Expand All @@ -260,6 +302,7 @@ export function RuntimeSection(): React.ReactElement {
<button
type="button"
style={buttonStyle}
data-testid={`runtime-stop-${id}`}
disabled={busy}
onClick={() => void onStop(ed.runningJobId!)}
>
Expand Down Expand Up @@ -328,7 +371,11 @@ export function RuntimeSection(): React.ReactElement {
</div>

{lastResult && (
<p style={{ marginTop: 16 }} role="status">
<p
style={{ marginTop: 16 }}
role="status"
data-testid="runtime-job-status"
>
Last result: {lastResult.status}
{lastResult.jobId != null ? ` · job ${lastResult.jobId}` : ""}
{lastResult.requestId != null
Expand Down
48 changes: 44 additions & 4 deletions WebUI/src/test/ts/publishing/runtimeEditions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { render, screen } from "@testing-library/react";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import {
canStopEdition,
Expand All @@ -27,18 +27,26 @@ vi.mock("@/api/home/homeApi", () => ({
fetchSites: vi.fn().mockResolvedValue([{ name: "SiteA", siteId: "1" }]),
}));

vi.mock("@/api/publishing/serversApi", () => ({
listServers: vi.fn().mockResolvedValue([
{ serverId: "7", serverName: "LocalFS" },
]),
}));

vi.mock("@/api/publishing/runtimeApi", () => ({
listRuntimeEditions: vi.fn().mockResolvedValue([
{ editionId: "10", name: "Full", runningJobId: 0 },
{ editionId: "10", name: "Full", runningJobId: 0, pubServerId: "7" },
{ editionId: "11", name: "Demand", runningJobId: 99, jobStatus: "Running" },
]),
startEditionJob: vi.fn(),
stopRuntimeJob: vi.fn(),
startEditionJob: vi.fn().mockResolvedValue({ jobId: 88, status: "started" }),
stopRuntimeJob: vi.fn().mockResolvedValue({ jobId: 99, status: "cancelled" }),
demandPublish: vi.fn(),
clearSiteItems: vi.fn(),
purgeRuntimeJobLog: vi.fn(),
}));

const runtimeApi = await import("@/api/publishing/runtimeApi");

describe("runtime edition helpers", () => {
it("canStopEdition when job running", () => {
expect(canStopEdition({ runningJobId: 5 })).toBe(true);
Expand All @@ -56,4 +64,36 @@ describe("RuntimeSection", () => {
render(<RuntimeSection />);
expect(screen.getByTestId("publish-section-runtime")).toBeTruthy();
});

it("starts selected edition and shows status", async () => {
render(<RuntimeSection />);
await waitFor(() => {
expect(screen.getByTestId("runtime-start-10")).toBeTruthy();
});
fireEvent.click(screen.getByTestId("runtime-start-10"));
await waitFor(() => {
expect(runtimeApi.startEditionJob).toHaveBeenCalledWith("10");
});
await waitFor(() => {
expect(screen.getByTestId("runtime-job-status").textContent).toMatch(
/started/i,
);
});
});

it("stops a running edition job and shows status", async () => {
render(<RuntimeSection />);
await waitFor(() => {
expect(screen.getByTestId("runtime-stop-11")).toBeTruthy();
});
fireEvent.click(screen.getByTestId("runtime-stop-11"));
await waitFor(() => {
expect(runtimeApi.stopRuntimeJob).toHaveBeenCalledWith(99);
});
await waitFor(() => {
expect(screen.getByTestId("runtime-job-status").textContent).toMatch(
/cancelled/i,
);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,23 +1,160 @@
/*
* Copyright (c) 2026 Intersoft Data Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* PublishingShell Runtime — start/stop selected pub-server edition (#4648 / parent #4531).
*
* Surface filter (H2 QA / agent path):
* cd modules/perc-qa-automation/frontend
* npm run test:surface -- --path tests/publishing/runtimeEditions.spec.js
*/

const { test, expect } = require("@playwright/test");
const { loginAsAdmin, BASE_URL } = require("../helpers/auth");

test.describe("Unified Publishing UI - Runtime Editions (US5)", () => {
test.describe("PublishingShell Runtime start/stop", () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page);
});

test("verify runtime section options", async ({ page }) => {
await page.goto(`${BASE_URL}/cm/app/index.jsp?view=publish`);
test("opens Runtime with pub-server selector and start control", async ({
page,
}) => {
const jsErrors = [];
page.on("pageerror", (err) => jsErrors.push(String(err)));
page.on("console", (msg) => {
if (msg.type() === "error") {
jsErrors.push(msg.text());
}
});

// Click Runtime tab
const runtimeTab = page.locator("a:has-text('Runtime')");
await expect(runtimeTab).toBeVisible();
await runtimeTab.click();
await page.goto(
`${BASE_URL}/Rhythmyx/cm/app/spa.jsp?entry=publish&section=runtime`,
);
await expect(page.getByTestId("publishing-shell")).toBeVisible({
timeout: 30000,
});
await expect(page.getByTestId("publish-section-runtime")).toBeVisible();
await expect(page.getByTestId("runtime-pub-server")).toBeVisible();
expect(jsErrors, `console/page errors: ${jsErrors.join("\n")}`).toEqual([]);
});

// Verify Runtime edition views/tables
const runtimeContainer = page.locator(
".perc-publishing-runtime-container, .perc-coming-soon",
test("start then stop shows status feedback", async ({ page }) => {
const jsErrors = [];
page.on("pageerror", (err) => jsErrors.push(String(err)));
page.on("console", (msg) => {
if (msg.type() === "error") {
jsErrors.push(msg.text());
}
});

await page.route(
"**/services/sitemanage/publishingdesign/runtime/editions?**",
async (route) => {
if (route.request().method() !== "GET") {
return route.continue();
}
return route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify([
{
editionId: "10",
name: "H2Full",
runningJobId: 0,
pubServerId: "7",
},
]),
});
},
);
await page.route("**/services/publishmanagement/servers/**", async (route) => {
if (route.request().method() !== "GET") {
return route.continue();
}
return route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify([{ serverId: "7", serverName: "LocalFS" }]),
});
});
await page.route(
"**/services/sitemanage/publishingdesign/runtime/editions/10/start",
async (route) => {
return route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({ jobId: 88, editionId: "10", status: "started" }),
});
},
);
await page.route(
"**/services/sitemanage/publishingdesign/runtime/jobs/88/stop",
async (route) => {
return route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({ jobId: 88, status: "cancelled" }),
});
},
);

await page.goto(
`${BASE_URL}/Rhythmyx/cm/app/spa.jsp?entry=publish&section=runtime`,
);
await expect(page.getByTestId("publish-section-runtime")).toBeVisible({
timeout: 30000,
});
await expect(page.getByTestId("runtime-start-10")).toBeVisible({
timeout: 20000,
});
await page.getByTestId("runtime-start-10").click();
await expect(page.getByTestId("runtime-job-status")).toContainText(
/started/i,
);

await page.route(
"**/services/sitemanage/publishingdesign/runtime/editions?**",
async (route) => {
if (route.request().method() !== "GET") {
return route.continue();
}
return route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify([
{
editionId: "10",
name: "H2Full",
runningJobId: 88,
jobStatus: "Running",
pubServerId: "7",
},
]),
});
},
);
await page.getByRole("button", { name: "Refresh" }).click();
await expect(page.getByTestId("runtime-stop-10")).toBeVisible({
timeout: 20000,
});
await page.getByTestId("runtime-stop-10").click();
await expect(page.getByTestId("runtime-job-status")).toContainText(
/cancelled/i,
);
await expect(runtimeContainer).toBeVisible();
expect(jsErrors, `console/page errors: ${jsErrors.join("\n")}`).toEqual([]);
});
});
Loading
Loading