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
2 changes: 2 additions & 0 deletions .github/workflows/screenshots-capture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:

- name: Build the frontend
run: bun run build
env:
VITE_FEATURE_FLAG_COLLECTOR_PAGE: "true"

- name: Create screenshots directory
run: mkdir -p screenshots
Expand Down
38 changes: 35 additions & 3 deletions ecosystem-explorer/scripts/take-screenshots.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@ const SCREENSHOTS_DIR = path.resolve("screenshots");
const PORT = 4173;
const BASE_URL = `http://localhost:${PORT}`;

// Pick an instrumentation known to have telemetry and configuration data
const DETAIL_VERSION = "2.25.0";
// Resolve latest versions at runtime from the generated data files.
// This prevents the script from going stale when new versions are released.
function resolveLatestVersion(indexPath) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch :)

const index = JSON.parse(fs.readFileSync(indexPath, "utf-8"));
const latest = index.versions.find((v) => v.is_latest);
if (!latest) throw new Error(`No latest version found in ${indexPath}`);
return latest.version;
}

const DETAIL_VERSION = resolveLatestVersion(
path.resolve("public/data/javaagent/versions-index.json")
);
const DETAIL_NAME = "spring-webmvc-6.0";
const COLLECTOR_VERSION = resolveLatestVersion(
path.resolve("public/data/collector/versions-index.json")
);
const COLLECTOR_DETAIL_ID = "core-receiver-otlpreceiver";

// Viewport sizes captured for each page. Edit here to add, remove, or resize.
const VIEWPORTS = [
Expand Down Expand Up @@ -104,6 +118,16 @@ async function clickTab(page, name) {
}
}

async function assertNoError(page, url) {
const errorHeading = page.getByRole("heading", { name: /error/i });
const notFound = page.getByRole("heading", { name: /not found/i });
const hasError = await errorHeading.isVisible().catch(() => false);
const has404 = await notFound.isVisible().catch(() => false);
if (hasError || has404) {
throw new Error(`Screenshot aborted: error page detected at ${url}`);
}
}

async function takeScreenshots() {
const server = await startServer();
let browser;
Expand Down Expand Up @@ -150,6 +174,7 @@ async function takeScreenshots() {
// 1. Home page
await page.goto(BASE_URL, { waitUntil: "domcontentloaded", timeout: 10000 });
await page.waitForSelector("h1", { state: "visible", timeout: 5000 });
await assertNoError(page, BASE_URL);
await page.screenshot({ path: p("home") });

// 2. Java agent instrumentation list
Expand All @@ -158,20 +183,24 @@ async function takeScreenshots() {
timeout: 10000,
});
await settle(page);
await assertNoError(page, `${BASE_URL}/java-agent/instrumentation`);
await page.screenshot({ path: p("instrumentation-list") });

// 3. Java agent instrumentation detail - Details tab
const detailUrl = `${BASE_URL}/java-agent/instrumentation/${DETAIL_VERSION}/${DETAIL_NAME}`;
await page.goto(detailUrl, { waitUntil: "domcontentloaded", timeout: 10000 });
await settle(page);
await assertNoError(page, detailUrl);
await page.screenshot({ path: p("detail-details"), fullPage: true });

Comment on lines 191 to 195
// 4. Telemetry tab (skipped gracefully if tabs aren't present in this branch)
await clickTab(page, "Telemetry");
await assertNoError(page, detailUrl);
await page.screenshot({ path: p("detail-telemetry"), fullPage: true });

// 5. Configuration tab (skipped gracefully if tabs aren't present in this branch)
await clickTab(page, "Configuration");
await assertNoError(page, detailUrl);
await page.screenshot({ path: p("detail-configuration"), fullPage: true });

// 6. Collector list
Expand All @@ -180,14 +209,17 @@ async function takeScreenshots() {
timeout: 10000,
});
await settle(page);
await assertNoError(page, `${BASE_URL}/collector/components`);
await page.screenshot({ path: p("collector-list") });

// 7. Collector detail
await page.goto(`${BASE_URL}/collector/components/latest/receiver-otlp`, {
const collectorDetailUrl = `${BASE_URL}/collector/components/${COLLECTOR_VERSION}/${COLLECTOR_DETAIL_ID}`;
await page.goto(collectorDetailUrl, {
waitUntil: "domcontentloaded",
timeout: 10000,
});
await settle(page);
await assertNoError(page, collectorDetailUrl);
await page.screenshot({ path: p("collector-detail"), fullPage: true });

logTime(`${viewport.name} done`);
Expand Down
Loading