chore: probe Playwright jetable retirée (e2e/_probe_edit.js)
This commit is contained in:
@@ -1,57 +0,0 @@
|
|||||||
// Où atterrit right_actions sur /pages/{id} ? (parsé ou texte ?)
|
|
||||||
const { chromium } = require('playwright-core');
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
function findChromium() {
|
|
||||||
const root = path.join(process.env.LOCALAPPDATA, 'ms-playwright');
|
|
||||||
const dirs = fs.readdirSync(root).filter((d) => d.startsWith('chromium-') && !d.includes('headless'));
|
|
||||||
dirs.sort();
|
|
||||||
return path.join(root, dirs[dirs.length - 1], 'chrome-win64', 'chrome.exe');
|
|
||||||
}
|
|
||||||
const BASE = 'http://localhost:8080';
|
|
||||||
const CSP_JS = path.join(__dirname, 'fixtures', 'alpine.csp.js');
|
|
||||||
(async () => {
|
|
||||||
const browser = await chromium.launch({ headless: true, executablePath: findChromium() });
|
|
||||||
const ctx = await browser.newContext({ serviceWorkers: 'block' });
|
|
||||||
const page = await ctx.newPage();
|
|
||||||
const errs = [];
|
|
||||||
page.on('pageerror', (e) => errs.push(e.message.slice(0, 110)));
|
|
||||||
await page.goto(`${BASE}/auth/login?provider=local`, { waitUntil: 'domcontentloaded' });
|
|
||||||
if (await page.locator('#email').count()) {
|
|
||||||
await page.fill('#email', process.env.FD_USER || '[email protected]');
|
|
||||||
await page.fill('#password', process.env.FD_PASS || 'e2e-secret-123');
|
|
||||||
await page.click('.btn-primary');
|
|
||||||
await page.waitForURL('**/workspaces', { timeout: 15000 }).catch(() => {});
|
|
||||||
}
|
|
||||||
await page.route('**/static/js/alpine.min.js', (r) =>
|
|
||||||
r.fulfill({ path: CSP_JS, contentType: 'application/javascript' })
|
|
||||||
);
|
|
||||||
const coll = await page.evaluate(async () => {
|
|
||||||
const csrf = (document.cookie.match(/csrf_token=([^;]+)/) || [])[1] || '';
|
|
||||||
const r = await fetch('/db/api', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf },
|
|
||||||
body: JSON.stringify({ name: 'e2e-probe-editor' }),
|
|
||||||
});
|
|
||||||
return r.json();
|
|
||||||
});
|
|
||||||
await page.goto(`${BASE}/pages/${coll.id}`, { waitUntil: 'domcontentloaded' });
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
const info = await page.evaluate(() => {
|
|
||||||
const star = document.querySelector('.star-btn');
|
|
||||||
const anyText = document.body.innerHTML.includes('edCall(');
|
|
||||||
const parsed = document.querySelector('button.star-btn') ? 'parse' : 'pas-de-bouton';
|
|
||||||
const parent = star ? star.parentElement.className : null;
|
|
||||||
const txt = document.body.innerHTML.indexOf('toggleActivityOpen');
|
|
||||||
const ctx = txt >= 0 ? document.body.innerHTML.slice(Math.max(0, txt - 160), txt + 60) : null;
|
|
||||||
return { parsed: parsed, starParent: parent, edCallInHTML: anyText, ctx: ctx };
|
|
||||||
});
|
|
||||||
console.log(JSON.stringify(info, null, 1));
|
|
||||||
console.log('erreurs:', errs.length ? errs : 'aucune');
|
|
||||||
// cleanup
|
|
||||||
await page.evaluate(async (id) => {
|
|
||||||
const csrf = (document.cookie.match(/csrf_token=([^;]+)/) || [])[1] || '';
|
|
||||||
await fetch(`/db/api/${id}`, { method: 'DELETE', headers: { 'X-CSRF-Token': csrf } });
|
|
||||||
}, coll.id);
|
|
||||||
await browser.close();
|
|
||||||
})();
|
|
||||||
Reference in New Issue
Block a user