Files
client/scripts/smoke-information-offscreen.mjs
T

67 lines
4.0 KiB
JavaScript

// Real hidden Electron navigation: packaged changelog/license lists, license detail and focus restoration.
// Disposable profile; no server, device, native dialog or external navigation.
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const option = name => args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : undefined;
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-information-qa-'));
const out = path.resolve(option('out') ?? 'smoke-out/information');
mkdirSync(out, { recursive: true });
const result = { checks: [], errors: [], scope: 'Actual packaged local documents and UI navigation; disposable offscreen profile, no server or physical capture.' };
let app;
try {
app = await launchApp({ exe: option('exe'), profile });
const page = await app.firstWindow();
page.on('pageerror', error => result.errors.push(error.message));
await page.waitForSelector('#view-onboarding', { state: 'visible' });
await page.fill('#onboarding-nick', 'Information QA');
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible' });
await page.click('#btn-settings');
await page.click('[data-panel="about"]');
const changelog = await page.evaluate(() => window.teamspeach.getChangelog());
assert.equal(changelog.ok, true);
const released = changelog.entries.find(entry => !entry.unreleased);
assert.ok(released, 'installation contains a released changelog entry');
await page.locator('.ts-changelog-show-more').click();
await waitForAsync(page, version => [...document.querySelectorAll('.ts-about-changelog-list .ts-widget-section-header')].some(node => node.textContent.includes(version)), released.version);
const entryText = await page.locator('.ts-about-changelog-list').innerText();
assert.equal(entryText.includes('[object HTML'), false);
assert.ok(entryText.includes(released.changes[0].replace(/`([^`]+)`/g, '$1')));
await page.screenshot({ path: path.join(out, 'changelog.png') });
result.checks.push('Show More renders released headings and change text as real DOM content, not stringified elements');
await page.locator('.settings-subpage-back').click();
assert.equal(await page.evaluate(() => document.activeElement?.classList.contains('ts-changelog-show-more')), true);
await page.locator('.ts-about-oss-license-entrypoint').click();
await page.locator('.ts-about-oss-list:not([aria-busy])').waitFor();
const noto = page.locator('.ts-about-oss-license').filter({ hasText: 'Noto' }).first();
await noto.locator('button').click();
await page.locator('.ts-about-oss-detail pre:not([aria-busy])').waitFor();
assert.match(await page.locator('.ts-about-oss-detail pre').innerText(), /SIL OPEN FONT LICENSE/);
await page.screenshot({ path: path.join(out, 'license-detail.png') });
await page.locator('.settings-subpage-back').click();
await waitForAsync(page, () => document.activeElement?.classList.contains('ts-about-oss-license-open'));
assert.ok((await page.evaluate(() => document.activeElement.closest('[data-license-id]').textContent)).includes('Noto'));
result.checks.push('License list opens the bundled OFL text and Back restores the selected license-row focus');
assert.deepEqual(result.errors, []);
result.ok = true;
} catch (error) {
result.ok = false;
result.error = error.stack;
process.exitCode = 1;
if (app) {
const page = await app.firstWindow();
result.visibleText = await page.locator('#about-information').innerText().catch(() => '');
await page.screenshot({ path: path.join(out, 'failure.png') }).catch(() => {});
}
} finally {
if (app) await app.close();
rmSync(profile, { recursive: true, force: true });
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
}