Files
sam-hotfix/e2e/runner/eval_chunk_3.js

1 line
12 KiB
JavaScript
Raw Normal View History

window.__C += 'filter(\n (col) => !headers.some((h) => h?.includes(col))\n );\n if (missing.length > 0) return warn(`Missing columns: ${missing.join(\', \')}`);\n }\n\n return pass(`Table: ${headers.length} cols, ${rows.length} rows`);\n },\n\n async verify_table_structure(action, ctx) {\n return ActionHandlers.verify_table(action, ctx);\n },\n\n async verify_data(action, ctx) {\n const searchText = action.search || action.value || \'\';\n const v = action.expected || action.verification || {};\n const pageText = document.body.innerText;\n const found = pageText.includes(searchText);\n\n if (v.row_exists === false) {\n return found\n ? fail(`Data should be absent: "${searchText}"`)\n : pass(`Data correctly absent: "${searchText}"`);\n }\n if (v.row_exists === true || v.row_exists === undefined) {\n if (!found) return fail(`Data not found: "${searchText}"`);\n if (v.contains) {\n const missing = v.contains.filter((t) => !pageText.includes(t));\n if (missing.length > 0) return warn(`Missing: ${missing.join(\', \')}`);\n }\n return pass(`Data found: "${searchText}"`);\n }\n return pass(\'verify_data\');\n },\n\n async verify_detail(action, ctx) {\n const checks = action.checks || [];\n const pageText = document.body.innerText;\n let matched = 0;\n for (const check of checks) {\n // Parse "label: value" format\n const parts = check.split(\':\').map((s) => s.trim());\n const searchText = parts[parts.length - 1]; // just check value part\n if (pageText.includes(searchText)) matched++;\n }\n return matched > 0\n ? pass(`Detail checks: ${matched}/${checks.length}`)\n : warn(`Detail checks: 0/${checks.length} matched`);\n },\n\n async verify_not_mockup(action, ctx) {\n const inputs = document.querySelectorAll(\n \'input:not([type="hidden"]), textarea, select\'\n );\n const buttons = document.querySelectorAll(\'button, [role="button"]\');\n const tables = document.querySelectorAll(\'table\');\n\n let mockupScore = 0;\n if (inputs.length === 0) mockupScore++;\n if (buttons.length <= 1) mockupScore++;\n if (tables.length === 0 && inputs.length === 0) mockupScore++;\n\n return mockupScore >= 2\n ? warn(`Possible mockup page (score: ${mockupScore})`)\n : pass(`Real page: ${inputs.length} inputs, ${buttons.length} buttons`);\n },\n\n async verify_dialog(action, ctx) {\n const v = action.verification || {};\n const dialog =\n document.querySelector(\'[role="alertdialog"]\') ||\n document.querySelector(\'[role="dialog"]\');\n if (!dialog) return warn(\'No dialog found\');\n const text = dialog.innerText || \'\';\n if (v.content_contains && !text.includes(v.content_contains)) {\n return warn(`Dialog missing text: ${v.content_contains}`);\n }\n return pass(\'Dialog verified\');\n },\n\n async verify_input_value(action, ctx) {\n const el = findEl(action.target, { selectors: ctx.selectors });\n if (!el) return fail(`Input not found: ${action.target}`);\n const v = action.verification || {};\n if (v.value && el.value !== v.value) {\n return fail(`Value mismatch: expected "${v.value}", got "${el.value}"`);\n }\n return pass(`Input value: "${el.value?.substring(0, 30)}"`);\n },\n\n async verify_page(action, ctx) {\n const v = action.verification || {};\n const pageText = document.body.innerText;\n if (v.title && !pageText.includes(v.title)) {\n return fail(`Page title missing: ${v.title}`);\n }\n if (v.content_contains && !pageText.includes(v.content_contains)) {\n return fail(`Page content missing: ${v.content_contains}`);\n }\n return pass(\'Page verified\');\n },\n\n async verify_console(action, ctx) {\n // Can\'t access real console from page context; return pas