MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

graph-ui/tools/pr-2068-errors-e2e.mjs:130–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128}
129
130async function main() {
131 await mkdir(OUT, { recursive: true });
132 await fixturePrepare();
133 report.indexWithCoverage = await index(PROJECT);
134 assert.equal(report.indexWithCoverage.status, 'done', 'Initial readable fixture must establish a real partial index');
135 report.indexStatus = await rpc('index_status', { project: PROJECT });
136 report.coverage = await rpc('check_index_coverage', { project: PROJECT, scopes: ['.'], paths: ['unreadable.c', 'partial.c', 'excluded.c'] });
137 report.checks.coverageContainsPartial = JSON.stringify(report.coverage).includes('parse_partial');
138 report.checks.coverageContainsExclusion = JSON.stringify(report.coverage).includes('cbmignore');
139 assert.ok(report.checks.coverageContainsPartial, 'Malformed fixture must produce actual parse_partial coverage');
140 assert.ok(report.checks.coverageContainsExclusion, '.cbmignore fixture must produce actual exclusion evidence');
141 await chmod(join(FIXTURE, 'unreadable.c'), 0);
142 await assert.rejects(readFile(join(FIXTURE, 'unreadable.c')), { code: 'EACCES' });
143 report.actions.push({ action: 'Set unreadable.c chmod 000; real EACCES verified; next reindex must fail', path: FIXTURE });
144 browser = await chromium.launch({ headless: true, args: ['--disable-background-networking', '--disable-component-update', '--disable-sync', '--no-first-run', '--use-angle=swiftshader'] });
145 const context = await browser.newContext({ viewport: { width: 1560, height: 1100 }, reducedMotion: 'reduce' });
146 await context.route('**/*', async (route) => {
147 const req = route.request(); const url = req.url();
148 report.browserRequests.push({ at: new Date().toISOString(), method: req.method(), url, ...(url === `${ORIGIN}/rpc` ? { tool: req.postDataJSON()?.params?.name } : {}) });
149 if (url.startsWith(ORIGIN + '/') || url.startsWith('data:') || url.startsWith('blob:')) return route.continue();
150 report.blockedExternalRequests.push(url); return route.abort();
151 });
152 const page = await context.newPage();
153 page.on('pageerror', (error) => { (report.browserErrors ??= []).push(error.message); });
154 await page.goto(`${ORIGIN}/?project=${PROJECT}`, { waitUntil: 'domcontentloaded' });
155 await page.locator('[data-testid="daemon-alerts"]').waitFor({ timeout: 60000 });
156 if (await page.locator('.cbm-welcome-backdrop').isVisible()) {
157 await page.locator('.cbm-welcome .cbm-primary').click();
158 report.actions.push({ action: 'Closed first-visit welcome via its normal start button' });
159 }
160 await failedJobWhileWatching(page, 'system', PROJECT);
161 await failedJobWhileWatching(page, 'galaxy', PROJECT);
162 report.coverageAfterFailedRefresh = await rpc('check_index_coverage', { project: PROJECT, scopes: ['.'], paths: ['unreadable.c', 'partial.c', 'excluded.c'] });
163 const beforeDiagnosis = report.browserRequests.length;
164 await page.getByRole('button', { name: 'Inspect index coverage', exact: true }).click();
165 const panel = page.getByRole('dialog', { name: 'Index coverage diagnosis', exact: true });
166 await panel.waitFor();
167 assert.equal(await panel.locator('textarea').count(), 0, 'Opening diagnosis must not generate a report');
168 report.checks.beforeExplicitDiagnosis = { reportAbsent: true, requests: report.browserRequests.slice(beforeDiagnosis) };
169 const diagnosisStart = report.browserRequests.length;
170 await panel.getByRole('button', { name: 'Run local diagnosis', exact: true }).click();
171 await panel.getByRole('textbox', { name: 'Editable local diagnostic report' }).waitFor({ timeout: 30000 });
172 report.localReport = await panel.getByRole('textbox', { name: 'Editable local diagnostic report' }).inputValue();
173 assert.ok(report.localReport.includes('Source lines: 2-2'), 'Actual parser source range must survive the shared coverage join and local report');
174 report.checks.localReportPreservesParserSourceRanges = true;
175 report.checks.localDiagnosis = { text: await panel.innerText(), requests: report.browserRequests.slice(diagnosisStart) };
176 await capture(page, 'errors-local-diagnosis.png');
177 await panel.getByRole('textbox', { name: 'Editable local diagnostic report' }).scrollIntoViewIfNeeded();
178 await capture(page, 'errors-local-report.png');
179 const draft = 'EXPLICIT TEST FIXTURE: locally reviewed and redacted draft. No publication requested.';
180 await panel.getByRole('textbox', { name: 'Editable local diagnostic report' }).fill(draft);
181 const downloadPromise = page.waitForEvent('download');
182 await panel.getByRole('button', { name: 'Download edited report', exact: true }).click();
183 const download = await downloadPromise;
184 const draftPath = join(OUT, `${proofPrefix}errors-reviewed-local-report.txt`); await download.saveAs(draftPath);
185 assert.equal(await readFile(draftPath, 'utf8'), draft);
186 report.checks.downloadContainsOnlyEditedText = true;
187 report.checks.onlySameDaemonOrigin = report.browserRequests.filter((entry) => !entry.url.startsWith('blob:') && !entry.url.startsWith('data:')).every((entry) => new URL(entry.url).origin === ORIGIN);

Callers 1

Calls 8

fixturePrepareFunction · 0.85
indexFunction · 0.85
failedJobWhileWatchingFunction · 0.85
countMethod · 0.80
rpcFunction · 0.70
captureFunction · 0.70
pushMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected