Skip to content

Commit ecceeff

Browse files
test(desktop): retain certificate rejection diagnostics
1 parent f8f4083 commit ecceeff

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎apps/desktop/test/windows-pit-browser.mjs‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ try {
2323
({ type, on }) => chrome.runtime.sendMessage({ type, on }), { type, on });
2424
// Certificate rejection can commit chrome-error:// after goto rejects. Keep
2525
// that late navigation out of the tab used for subsequent routing checks.
26-
const rejectUntrusted = async (url, screenshotPath) => {
26+
const rejectUntrusted = async (url, { screenshotPath, timeout = 45000 } = {}) => {
2727
const invalid = await context.newPage();
2828
try {
2929
await assert.rejects(invalid.goto(url, {
30-
waitUntil: 'domcontentloaded', timeout: 45000,
30+
waitUntil: 'domcontentloaded', timeout,
3131
}), /ERR_CERT_AUTHORITY_INVALID/);
32-
if (screenshotPath) await invalid.screenshot({ path: screenshotPath });
32+
if (screenshotPath) {
33+
await invalid.waitForFunction(() => Boolean(document.body?.innerText.trim()), null, { timeout: 5000 });
34+
await invalid.screenshot({ path: screenshotPath });
35+
}
36+
} catch (error) {
37+
await invalid.screenshot({ path: path.join(evidence, `${phase}-invalid-tls-failure.png`) }).catch(() => {});
38+
throw error;
3339
} finally {
34-
await invalid.close();
40+
await invalid.close().catch(() => {});
3541
}
3642
};
3743

@@ -64,7 +70,7 @@ try {
6470
check('HTTP Moshpit name resolves through the browser');
6571

6672
if (phase === 'before-trust' || phase === 'after-removal') {
67-
await rejectUntrusted('https://profullstack.agent/', path.join(evidence, `${phase}.png`));
73+
await rejectUntrusted('https://profullstack.agent/', { screenshotPath: path.join(evidence, `${phase}.png`) });
6874
check('registry HTTPS is rejected without root trust');
6975
} else {
7076
const response = await page.goto('https://profullstack.agent/', {
@@ -80,7 +86,7 @@ try {
8086
check('registry HTTPS succeeds with normal browser certificate verification');
8187
}
8288

83-
await rejectUntrusted(invalidTlsUrl);
89+
await rejectUntrusted(invalidTlsUrl, { timeout: 15000 });
8490
check('unrelated self-signed HTTPS remains rejected');
8591

8692
assert.equal((await message('pit-set', false)).enabled, false);

0 commit comments

Comments
 (0)