AI processed classifier

This commit is contained in:
Yury Semikhatsky 2024-10-10 15:09:48 -07:00
parent 8fd3d32925
commit 6fbd199f56

View file

@ -151,41 +151,26 @@ export const TestResultView: React.FC<{
}; };
function classifyErrors(testErrors: string[], diffs: ImageDiff[]) { function classifyErrors(testErrors: string[], diffs: ImageDiff[]) {
const errors = []; return testErrors.map(error => {
for (const error of testErrors) {
let screenshotError;
if (error.includes('Screenshot comparison failed:')) { if (error.includes('Screenshot comparison failed:')) {
for (const diff of diffs) { const matchingDiff = diffs.find(diff => {
if (!diff.actual?.attachment.name) const attachmentName = diff.actual?.attachment.name;
continue; return attachmentName && error.includes(attachmentName);
if (!error.includes(diff.actual!.attachment.name)) });
continue;
if (matchingDiff) {
const lines = error.split('\n'); const lines = error.split('\n');
const index = lines.findIndex(line => line.match(/Expected:|Previous:|Received:/)); const index = lines.findIndex(line => /Expected:|Previous:|Received:/.test(line));
let errorPrefix; const errorPrefix = index !== -1 ? lines.slice(0, index).join('\n') : lines[0];
if (index !== -1)
errorPrefix = lines.slice(0, index).join('\n');
else
errorPrefix = lines[0];
let errorSuffix; const diffIndex = lines.findIndex(line => / +Diff:/.test(line));
const diffIndex = lines.findIndex(line => line.match(/ +Diff:/)); const errorSuffix = diffIndex !== -1 ? lines.slice(diffIndex + 2).join('\n') : lines.slice(1).join('\n');
// Skip one empty line after the diff too.
if (diffIndex !== -1)
errorSuffix = lines.slice(diffIndex + 2).join('\n');
else
errorSuffix = lines.slice(1).join('\n');
screenshotError = { type: 'screenshot', diff, errorPrefix, errorSuffix }; return { type: 'screenshot', diff: matchingDiff, errorPrefix, errorSuffix };
} }
} }
if (screenshotError) return { type: 'regular', error };
errors.push(screenshotError); });
else
errors.push({ type: 'regular', error });
}
return errors;
} }
const StepTreeItem: React.FC<{ const StepTreeItem: React.FC<{