Skip to content

Commit 06217d0

Browse files
committed
Fix build
1 parent 1a7bc1b commit 06217d0

10 files changed

Lines changed: 423 additions & 119 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</licenses>
5858

5959
<modules>
60-
<module>zookeeper-docs</module>
60+
<module>zookeeper-website</module>
6161
<module>zookeeper-jute</module>
6262
<module>zookeeper-server</module>
6363
<module>zookeeper-metrics-providers</module>

zookeeper-website/README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,17 @@ Generated files are located under the `build/` directory.
386386

387387
### Maven Integration
388388

389-
The website is integrated with the Apache ZooKeeper Maven build system using the `frontend-maven-plugin`. The website is configured to build **only during site generation** (`mvn site`) and will not build during regular Maven lifecycle phases like `mvn clean install`.
389+
The website is integrated into the Apache ZooKeeper Maven build through two POMs:
390+
391+
- The repository root `pom.xml` includes `zookeeper-website` as a Maven module.
392+
- `zookeeper-website/pom.xml` owns the website-specific build and configures `frontend-maven-plugin`.
393+
394+
The frontend plugin is intentionally bound only to the Maven `site` lifecycle:
395+
396+
- `pre-site` installs Node.js/npm and runs `npm install`
397+
- `site` runs the website CI command
398+
399+
Because of that, the website is built **only during site generation** (`mvn site`) and is skipped during regular Maven lifecycle phases such as `mvn clean install`.
390400

391401
#### When the Website Builds
392402

@@ -404,7 +414,7 @@ The website will **NOT** build during regular commands like:
404414

405415
This keeps regular ZooKeeper builds fast while still allowing the website to be generated when needed.
406416

407-
#### What Gets Executed During `mvn site`
417+
#### What the Website POM Does During `mvn site`
408418

409419
When you run `mvn site`, the website module automatically:
410420

@@ -452,7 +462,7 @@ mvn clean install
452462
**Build the Website:**
453463

454464
```bash
455-
# From ZooKeeper root or zookeeper-website directory
465+
# From ZooKeeper root directory
456466
mvn site
457467
```
458468

@@ -470,18 +480,21 @@ This runs `npm run ci-skip-tests` for the website module.
470480
**Build Website Only:**
471481

472482
```bash
473-
# From zookeeper-website directory
483+
# From ZooKeeper root directory
484+
mvn -pl zookeeper-website site
485+
486+
# Or from the website module directory
474487
cd zookeeper-website
475-
mvn clean install
488+
mvn site
476489
```
477490

478491
**Skip Website Build:**
479492

480-
If you want to build ZooKeeper but skip the website:
493+
If you are running the Maven `site` lifecycle but want to disable the website frontend build:
481494

482495
```bash
483-
# From ZooKeeper root directory
484-
mvn clean install -DskipSite
496+
# From ZooKeeper root or zookeeper-website directory
497+
mvn site -DskipSite
485498
```
486499

487500
### Deployment

zookeeper-website/app/components/docs/older-docs-picker.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ import {
2626
CommandItem,
2727
CommandList
2828
} from "@/ui/command";
29-
import { RELEASED_DOC_VERSIONS } from "@/lib/released-docs-versions";
29+
import { getReleasedDocVersions } from "@/lib/released-docs-versions";
30+
31+
interface OlderDocsVersionsProps {
32+
versions?: string[];
33+
}
3034

3135
/** Shared Command palette (search + list), used in both the
3236
* sidebar popover and the navbar sub-menu. */
33-
export function OlderDocsVersionList() {
37+
export function OlderDocsVersionList({
38+
versions = getReleasedDocVersions()
39+
}: OlderDocsVersionsProps) {
3440
return (
3541
<Command filter={(value, search) => (value.includes(search) ? 1 : 0)}>
3642
<CommandInput placeholder="Search version..." />
3743
<CommandList>
3844
<CommandEmpty>No versions found</CommandEmpty>
3945
<CommandGroup>
40-
{RELEASED_DOC_VERSIONS.map((version) => (
46+
{versions.map((version) => (
4147
<CommandItem key={version} value={version} asChild>
4248
<a href={`/released-docs/r${version}/index.html`}>{version}</a>
4349
</CommandItem>
@@ -49,7 +55,7 @@ export function OlderDocsVersionList() {
4955
}
5056

5157
/** Sidebar variant — Popover that opens to the right of the trigger button. */
52-
export function OlderDocsPicker() {
58+
export function OlderDocsPicker({ versions }: OlderDocsVersionsProps) {
5359
return (
5460
<Popover>
5561
<PopoverTrigger asChild>
@@ -66,7 +72,7 @@ export function OlderDocsPicker() {
6672
className="w-56 p-0"
6773
aria-label="Older documentation versions"
6874
>
69-
<OlderDocsVersionList />
75+
<OlderDocsVersionList versions={versions} />
7076
</PopoverContent>
7177
</Popover>
7278
);

zookeeper-website/app/lib/released-docs-versions.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,26 @@ import { RAW_RELEASED_DOC_VERSIONS } from "virtual:released-docs-versions";
6767
export const RELEASED_DOC_VERSIONS: string[] = sortVersionsDesc(
6868
RAW_RELEASED_DOC_VERSIONS
6969
);
70+
71+
export function getReleasedDocVersions(): string[] {
72+
if (typeof window !== "undefined") {
73+
const override = window.localStorage.getItem(
74+
"__released_doc_versions_override__"
75+
);
76+
if (override) {
77+
try {
78+
const parsed = JSON.parse(override);
79+
if (
80+
Array.isArray(parsed) &&
81+
parsed.every((value) => typeof value === "string")
82+
) {
83+
return sortVersionsDesc(parsed);
84+
}
85+
} catch {
86+
// Ignore invalid test overrides and fall back to build-time data.
87+
}
88+
}
89+
}
90+
91+
return RELEASED_DOC_VERSIONS;
92+
}

zookeeper-website/e2e-tests/older-docs-picker.spec.ts

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@
1818

1919
import { test, expect } from "@playwright/test";
2020

21+
const MOCK_RELEASED_DOC_VERSIONS = ["3.10.0", "3.9.4", "3.9.0-beta"];
22+
const RELEASED_DOC_VERSIONS_OVERRIDE_KEY = "__released_doc_versions_override__";
23+
2124
test.describe("Older Docs Picker – sidebar", () => {
2225
test.beforeEach(async ({ page }) => {
26+
await page.addInitScript(
27+
({ key, versions }) => {
28+
window.localStorage.setItem(key, JSON.stringify(versions));
29+
},
30+
{
31+
key: RELEASED_DOC_VERSIONS_OVERRIDE_KEY,
32+
versions: MOCK_RELEASED_DOC_VERSIONS
33+
}
34+
);
2335
await page.goto("/docs");
2436
await page.waitForLoadState("networkidle");
2537
});
@@ -48,25 +60,19 @@ test.describe("Older Docs Picker – sidebar", () => {
4860

4961
const options = list.getByRole("option");
5062
await expect(options.first()).toBeVisible();
51-
const count = await options.count();
52-
expect(count).toBeGreaterThan(0);
63+
await expect(options).toHaveCount(MOCK_RELEASED_DOC_VERSIONS.length);
5364
});
5465

5566
test("versions are displayed in descending order", async ({ page }) => {
5667
await page.getByRole("button", { name: /older docs/i }).click();
5768

5869
const options = page.getByRole("option");
5970
await expect(options.first()).toBeVisible();
60-
const count = await options.count();
61-
expect(count).toBeGreaterThan(1);
62-
63-
const firstText = (await options.first().textContent()) ?? "";
64-
const lastText = (await options.last().textContent()) ?? "";
6571

66-
// Simple sanity check: the first item should sort higher than the last
67-
expect(firstText.trim()).not.toBe("");
68-
expect(lastText.trim()).not.toBe("");
69-
expect(firstText.trim() > lastText.trim()).toBe(true);
72+
const texts = await options.allTextContents();
73+
expect(texts.map((text) => text.trim())).toEqual(
74+
MOCK_RELEASED_DOC_VERSIONS
75+
);
7076
});
7177

7278
test("each version item is a link to /released-docs/r{version}/index.html", async ({
@@ -75,13 +81,12 @@ test.describe("Older Docs Picker – sidebar", () => {
7581
await page.getByRole("button", { name: /older docs/i }).click();
7682

7783
const options = page.getByRole("option");
78-
await expect(options.first()).toBeVisible();
79-
80-
// With asChild, the <a> IS the option element — check href directly
81-
const count = Math.min(await options.count(), 5);
82-
for (let i = 0; i < count; i++) {
84+
await expect(options).toHaveCount(MOCK_RELEASED_DOC_VERSIONS.length);
85+
for (let i = 0; i < MOCK_RELEASED_DOC_VERSIONS.length; i++) {
8386
const href = await options.nth(i).getAttribute("href");
84-
expect(href).toMatch(/^\/released-docs\/r[\d.].+\/index\.html$/);
87+
expect(href).toBe(
88+
`/released-docs/r${MOCK_RELEASED_DOC_VERSIONS[i]}/index.html`
89+
);
8590
}
8691
});
8792

@@ -103,8 +108,8 @@ test.describe("Older Docs Picker – sidebar", () => {
103108
const filtered = page.getByRole("option");
104109
const totalAfter = await filtered.count();
105110

106-
// The list should be smaller after filtering
107-
expect(totalAfter).toBeLessThan(totalBefore);
111+
expect(totalBefore).toBe(MOCK_RELEASED_DOC_VERSIONS.length);
112+
expect(totalAfter).toBe(2);
108113

109114
// Every remaining option must contain the search term
110115
for (let i = 0; i < totalAfter; i++) {
@@ -145,6 +150,15 @@ test.describe("Older Docs Picker – sidebar", () => {
145150

146151
test.describe("Older Docs Picker – navbar Documentation menu", () => {
147152
test.beforeEach(async ({ page }) => {
153+
await page.addInitScript(
154+
({ key, versions }) => {
155+
window.localStorage.setItem(key, JSON.stringify(versions));
156+
},
157+
{
158+
key: RELEASED_DOC_VERSIONS_OVERRIDE_KEY,
159+
versions: MOCK_RELEASED_DOC_VERSIONS
160+
}
161+
);
148162
await page.goto("/");
149163
await page.waitForLoadState("networkidle");
150164
});
@@ -180,8 +194,9 @@ test.describe("Older Docs Picker – navbar Documentation menu", () => {
180194
await expect(page.getByRole("menu")).toHaveCount(2, { timeout: 10000 });
181195
const subMenu = page.getByRole("menu").last();
182196

183-
const options = subMenu.getByRole("option");
184-
await expect(options.first()).toBeVisible();
197+
const versionLinks = subMenu.locator('a[href^="/released-docs/r"]');
198+
await expect(versionLinks.first()).toBeVisible();
199+
await expect(versionLinks).toHaveCount(MOCK_RELEASED_DOC_VERSIONS.length);
185200
});
186201

187202
test("navbar older-docs links point to /released-docs/", async ({ page }) => {
@@ -192,15 +207,18 @@ test.describe("Older Docs Picker – navbar Documentation menu", () => {
192207

193208
const olderDocs = page.getByRole("menuitem", { name: /older docs/i });
194209
await olderDocs.hover();
210+
await olderDocs.press("ArrowRight");
195211

196212
const subMenu = page.getByRole("menu").last();
197213
await expect(subMenu).toBeVisible();
198214

199-
const links = subMenu.getByRole("link");
200-
const count = Math.min(await links.count(), 3);
201-
for (let i = 0; i < count; i++) {
215+
const links = subMenu.locator('a[href^="/released-docs/r"]');
216+
await expect(links).toHaveCount(MOCK_RELEASED_DOC_VERSIONS.length);
217+
for (let i = 0; i < MOCK_RELEASED_DOC_VERSIONS.length; i++) {
202218
const href = await links.nth(i).getAttribute("href");
203-
expect(href).toMatch(/^\/released-docs\/r[\d.].+\/index\.html$/);
219+
expect(href).toBe(
220+
`/released-docs/r${MOCK_RELEASED_DOC_VERSIONS[i]}/index.html`
221+
);
204222
}
205223
});
206224
});

0 commit comments

Comments
 (0)