blob: a0e9c313d42b2a1959337744e38f08cadc4018d2 [file]
const { test, expect } = require('./artifact-test');
const releaseURL = 'https://github.com/apache/hugegraph/releases/tag/1.7.0';
const releaseLinks = [
releaseURL,
'https://github.com/apache/hugegraph/archive/refs/tags/1.7.0.tar.gz',
'https://github.com/apache/hugegraph/archive/refs/tags/1.7.0.zip',
'https://github.com/apache/hugegraph'
];
const configurationKey = 'gremlin.graph';
for (const language of ['en', 'cn']) {
const prefix = language === 'cn' ? '/cn' : '';
const releaseRoute = `${prefix}/docs/changelog/hugegraph-1.7.0-release-notes/`;
const configurationRoute = `${prefix}/docs/config/config-option/`;
const compatibilityTitle = language === 'cn'
? '升级与兼容性重点(Breaking Changes)' : 'Key Breaking Changes & Compatibility';
const compatibilityAnchor = language === 'cn'
? '升级与兼容性重点breaking-changes' : 'key-breaking-changes--compatibility';
const compatibilityTags = language === 'cn'
? ['Gremlin', '配置', '客户端'] : ['Gremlin', 'Configuration', 'Client'];
test(`${language} native release timeline and update keep readable content, public anchors and Markdown`, async ({ page, request }) => {
const route = `${prefix}/docs/changelog/hugegraph-1.8.0-release-notes/`;
await page.goto(route);
const timeline = page.locator('.td-content dl.timeline');
const heading = page.locator('h3.update');
await expect(timeline).toHaveCount(1);
await expect(timeline.locator('dt')).toHaveText(['1.7.0', '1.8.0']);
await expect(timeline.locator('dd')).toHaveCount(3);
await expect(timeline.locator('dd').nth(0)).toContainText('Java 11');
await expect(timeline.locator('dd').nth(1)).toContainText('Java 17');
await expect(timeline.locator('dd').nth(2)).toContainText('TinkerPop 3.8.1');
await expect(timeline.locator('dd').nth(2)).toContainText('Groovy 4.0.25');
await expect(heading).toHaveText(compatibilityTitle);
await expect(heading).toHaveAttribute('id', compatibilityAnchor);
expect(decodeURIComponent(await heading.locator('a').getAttribute('href'))).toBe(`#${compatibilityAnchor}`);
const metadata = heading.locator('xpath=following-sibling::*[1]');
await expect(metadata).toHaveClass('td-update-meta');
await expect(metadata.locator('.td-update-tag')).toHaveText(compatibilityTags);
// This release note is still WIP: presentation must not invent a date.
await expect(metadata.locator('time')).toHaveCount(0);
for (const width of [1440, 390]) {
await page.setViewportSize({ width, height: 1000 });
await timeline.scrollIntoViewIfNeeded();
await expect(timeline.locator('dd').last()).toBeVisible();
expect(await timeline.evaluate(node => node.scrollWidth <= node.clientWidth + 1)).toBe(true);
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);
}
const markdown = await request.get(`${route}index.md`);
expect(markdown.ok()).toBe(true);
const text = await markdown.text();
for (const term of ['Java 11', 'Java 17', 'TinkerPop 3.8.1', 'Groovy 4.0.25', '{.timeline}', ...compatibilityTags]) {
expect(text).toContain(term);
}
expect(text).toContain('{.update tags=');
});
test(`${language} native release card derives real release links and date in HTML and Markdown`, async ({ page, request }) => {
await page.goto(releaseRoute);
const card = page.locator('.td-release-card');
await expect(card).toHaveCount(1);
await expect(card.locator('.td-release-card__tag')).toHaveText('1.7.0');
await expect(card.locator('time')).toHaveAttribute('datetime', '2025-11-16');
await expect(card.locator('time')).toHaveText('2025-11-16');
expect(await card.locator('a').evaluateAll(links => links.map(link => link.getAttribute('href')))).toEqual(releaseLinks);
const markdown = await request.get(`${releaseRoute}index.md`);
expect(markdown.ok()).toBe(true);
const text = await markdown.text();
// Escape punctuation in the tag while preserving its literal Markdown text.
expect(text).toContain(String.raw`**1\.7\.0 · 2025-11-16**`);
for (const url of releaseLinks) expect(text).toContain(`](${url})`);
expect(text).not.toContain('{{< release-card');
});
for (const width of [1440, 390]) {
test(`${language} native configuration table reader preserves data, keyboard focus and Print at ${width}px`, async ({ page, request }) => {
await page.setViewportSize({ width, height: 1000 });
await page.goto(configurationRoute);
const frame = page.locator('[data-td-table-expand]').filter({ hasText: configurationKey });
const button = frame.locator('.td-table-expand');
const dialog = page.locator('[data-td-table-reader]');
const table = page.locator('table.expand').filter({ hasText: configurationKey });
await expect(frame).toHaveCount(1);
await expect(button).toBeVisible();
await expect(table).toHaveClass(/td-table--wide/);
const rows = await table.locator('tbody tr').count();
expect(rows).toBeGreaterThan(20);
await expect(table.locator('tbody tr > td:first-child').first()).toHaveText(configurationKey);
const sourceRows = await table.locator('tbody tr').allTextContents();
await button.scrollIntoViewIfNeeded();
await button.focus();
const scrollY = await page.evaluate(() => window.scrollY);
await button.press('Enter');
await expect(dialog).toBeVisible();
await expect(dialog.locator('table')).toHaveCount(1);
await expect(frame.locator('table')).toHaveCount(0);
await expect(dialog.locator('tbody tr')).toHaveCount(rows);
await expect(dialog.locator('tbody tr')).toHaveText(sourceRows);
await expect(dialog.locator('#td-table-reader-title')).toBeFocused();
await page.keyboard.press('Shift+Tab');
expect(await dialog.evaluate(node => node.contains(document.activeElement))).toBe(true);
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(button).toBeFocused();
await expect(frame.locator('tbody tr')).toHaveCount(rows);
await expect(frame.locator('tbody tr')).toHaveText(sourceRows);
expect(Math.abs(await page.evaluate(() => window.scrollY) - scrollY)).toBeLessThanOrEqual(1);
await button.press('Enter');
await expect(dialog).toBeVisible();
await page.evaluate(() => window.dispatchEvent(new Event('beforeprint')));
await expect(dialog).toBeHidden();
await expect(frame.locator('tbody tr')).toHaveCount(rows);
await page.emulateMedia({ media: 'print' });
await expect(button).toBeHidden();
await expect(table).toBeVisible();
await expect(table.locator('tbody tr')).toHaveText(sourceRows);
await page.emulateMedia({ media: 'screen' });
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);
const markdown = await request.get(`${configurationRoute}index.md`);
expect(markdown.ok()).toBe(true);
const text = await markdown.text();
expect(text).toContain(configurationKey);
expect(text).toContain('serializer.buffer_max_capacity');
expect(text).not.toContain('data-td-table-reader');
});
}
test(`${language} native Mermaid reader keeps zoom, exact source copy, SVG export and keyboard return usable`, async ({ page, context, request }) => {
test.setTimeout(45_000);
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
const route = `${prefix}/docs/quickstart/hugegraph/hugegraph-server/`;
await page.goto(route);
const diagram = page.locator('.td-diagram--mermaid').filter({ hasText: 'bin/start-hugegraph.sh -p true' });
await expect(diagram).toHaveCount(1);
await diagram.scrollIntoViewIfNeeded();
await expect(diagram).toHaveAttribute('data-td-diagram-state', 'rendered', { timeout: 20_000 });
const source = await diagram.locator('.td-mermaid-source code').textContent();
expect(source).toContain('flowchart TD');
expect(source).toContain('bin/init-store.sh');
const expand = diagram.locator('[data-td-diagram-expand]');
await expand.focus();
await expand.press('Enter');
const dialog = page.locator('[data-td-diagram-zoom-dialog]');
const viewport = dialog.locator('[data-td-diagram-zoom-viewport]');
const canvas = dialog.locator('[data-td-diagram-zoom-canvas]');
const zoomIn = dialog.locator('[data-td-diagram-zoom-in]');
const sourceToggle = dialog.locator('[data-td-diagram-source-toggle]');
const sourcePane = dialog.locator('[data-td-diagram-zoom-source]');
await expect(dialog).toBeVisible();
await expect(dialog.locator('[data-td-diagram-zoom-close]')).toBeFocused();
await expect(canvas.locator('img')).toBeVisible();
await expect(zoomIn).toBeEnabled();
const beforeZoom = await canvas.evaluate(node => node.style.transform);
await zoomIn.click();
await expect.poll(() => canvas.evaluate(node => node.style.transform)).not.toBe(beforeZoom);
const beforePan = await canvas.evaluate(node => node.style.transform);
await viewport.focus();
await viewport.press('ArrowRight');
await expect.poll(() => canvas.evaluate(node => node.style.transform)).not.toBe(beforePan);
await sourceToggle.click();
await expect(sourceToggle).toHaveAttribute('aria-pressed', 'true');
await expect(sourcePane).toBeVisible();
expect(await sourcePane.locator('code').textContent()).toBe(source);
await expect(zoomIn).toBeDisabled();
await dialog.locator('[data-td-diagram-copy]').click();
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(source);
await sourceToggle.click();
await expect(sourceToggle).toHaveAttribute('aria-pressed', 'false');
await expect(canvas.locator('img')).toBeVisible();
await expect(zoomIn).toBeEnabled();
const downloadPromise = page.waitForEvent('download');
await dialog.locator('[data-td-diagram-download]').click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe('mermaid-1.svg');
const stream = await download.createReadStream();
expect(stream).not.toBeNull();
const chunks = [];
for await (const chunk of stream) chunks.push(chunk);
const svg = Buffer.concat(chunks).toString('utf8');
expect(svg).toContain('<svg');
expect(svg).toContain('xmlns="http://www.w3.org/2000/svg"');
expect(svg).toContain('HugeGraph 1.7.0');
expect(svg).toContain('bin/start-hugegraph.sh -p true');
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(expand).toBeFocused();
const markdown = await request.get(`${route}index.md`);
expect(markdown.ok()).toBe(true);
const text = await markdown.text();
expect(text).toContain('flowchart TD');
expect(text).toContain('bin/init-store.sh');
expect(text).not.toContain('data-td-diagram');
});
test(`${language} aggregate Print keeps release links and the complete expanded table without modal controls`, async ({ page }) => {
await page.goto(`${prefix}/_print/docs/`);
const card = page.locator('.td-release-card-static').filter({ hasText: '1.7.0' });
await expect(card).toHaveCount(1);
await expect(card.locator('time')).toHaveAttribute('datetime', '2025-11-16');
expect(await card.locator('a').evaluateAll(links => links.map(link => link.getAttribute('href')))).toEqual(releaseLinks);
const timeline = page.locator('dl.timeline').filter({ hasText: 'TinkerPop 3.8.1' });
await expect(timeline).toHaveCount(1);
await expect(timeline.locator('dt')).toHaveText(['1.7.0', '1.8.0']);
await expect(timeline.locator('dd')).toHaveCount(3);
await expect(timeline).toContainText('Java 11');
await expect(timeline).toContainText('Java 17');
const update = page.locator('h3.update').filter({ hasText: compatibilityTitle });
await expect(update).toHaveCount(1);
expect(await update.getAttribute('id')).toMatch(new RegExp(`--${compatibilityAnchor}$`));
const metadata = update.locator('xpath=following-sibling::*[1]');
await expect(metadata).toHaveClass('td-update-meta');
await expect(metadata.locator('.td-update-tag')).toHaveText(compatibilityTags);
const table = page.locator('table').filter({ hasText: configurationKey });
await expect(table).toHaveCount(1);
expect(await table.locator('tbody tr').count()).toBeGreaterThan(20);
const field = page.locator('.td-field').filter({ has: page.locator('.td-field__name', { hasText: /^restserver\.connection_max_requests$/ }) });
await expect(field).toHaveCount(1);
await expect(field.locator('.td-field__meta-value')).toHaveText('256');
await expect(field.locator('.td-field__description')).not.toBeEmpty();
await expect(page.locator('[data-td-table-reader]')).toHaveCount(0);
await expect(page.locator('.td-table-expand')).toHaveCount(0);
const diagramSource = page.locator('pre.td-mermaid-source code').filter({ hasText: 'bin/start-hugegraph.sh -p true' });
await expect(diagramSource).toHaveCount(1);
await expect(diagramSource).toBeVisible();
await expect(diagramSource).toContainText('flowchart TD');
await expect(page.locator('[data-td-diagram-zoom-dialog]')).toHaveCount(0);
});
}