Portal: Mitarbeiter-Login gesperrt (Hinweis aufs Ticketsystem), alte Mitarbeiter-Sitzungen enden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-02 03:44:10 +00:00
1 parent d0ca3c41cd
commit 3a4fa581c0
13 files changed
+145 -559

No files matched your search

+25 -6
View File
@@ -31,8 +31,11 @@ const VIEW = 'a'.repeat(32)
const customer = { id: 'c1', code: '1001', name: 'Berta Berg', email: 'b@example.test' }
const ME = {
neu: { authenticated: true, role: 'admin', viewAs: true, viewId: VIEW, viewExpiresAt: Date.now() + 3600000, admin: { name: 'Andrej', email: 'andrej@webklar.com', isAdmin: false }, customer },
alt: { authenticated: true, role: 'admin', viewAs: true, admin: { name: 'Kenso', email: 'kenso@webklar.com', isAdmin: true }, customer },
// alte Mitarbeiter-Sitzung (Login im Portal oder Alt-Ansicht ohne Kennung): /me beendet sie, weiter ins Ticketsystem
staff: { authenticated: false, reason: 'staff', redirect: `${base}/zurueck-im-ticketsystem.html?von=staff` },
gast: { authenticated: false },
}
const STAFF_BLOCKED = { error: 'Mitarbeiter arbeiten im Ticketsystem.', ticketUrl: 'https://ticket.webklar.com' }
let scenario = 'neu'
let replaceAfterMe = false
@@ -50,6 +53,7 @@ async function mockApi(page) {
seen.ende += 1
return json({ redirect: `${base}/zurueck-im-ticketsystem.html` })
}
if (p === '/api/auth/login') return json(STAFF_BLOCKED, 403)
if (p === '/api/chat/read') seen.chatRead += 1
if (p === '/api/projects') return json({ projects: [{ id: 'p1', name: 'Bäckerei Berg', status: 'live' }] })
if (p === '/api/contact') return json({ name: 'WEBklar-Team', responseTime: 'Antwort meist < 1 Werktag' })
@@ -104,11 +108,26 @@ try {
await page.screenshot({ path: `${SHOTS}/${label}-ersetzt.png` })
replaceAfterMe = false
// 3) alte Ansicht aus dem Admin-Panel: altes Banner, keine Kennung
await open('alt')
const old = (await page.textContent('#viewas-banner')).replace(/\s+/g, ' ').trim()
check(`${label} altes_banner`, old.includes('Admin-Ansicht') && old.includes('Zurück zur Admin-Übersicht'), old)
check(`${label} alt_ohne_kennung`, seen.headers.every((h) => h === null), JSON.stringify(seen.headers))
// 3) alte Mitarbeiter-Sitzung: Dashboard leitet ins Ticketsystem weiter
scenario = 'staff'
await page.goto('about:blank')
await Promise.all([page.waitForURL(/zurueck-im-ticketsystem\.html\?von=staff/), page.goto(`${base}/dashboard.html`)])
check(`${label} staff_weiterleitung`, page.url().endsWith('/zurueck-im-ticketsystem.html?von=staff'), page.url())
// 4) Mitarbeiter meldet sich im Portal an: Hinweis und Link ins Ticketsystem
scenario = 'gast'
await page.goto(`${base}/login.html`)
await page.fill('#email', 'andrej@webklar.com')
await page.fill('#password', 'geheim-geheim')
await page.click('#login-btn')
await page.waitForSelector('#login-staff-link:not(.hidden)', { timeout: 15000 }).catch(() => null)
const hint = (await page.textContent('#login-error')).trim()
check(`${label} login_hinweis`, hint === 'Mitarbeiter arbeiten im Ticketsystem.', hint)
const link = await page.$eval('#login-staff-link', (a) => ({ text: a.textContent.trim(), href: a.getAttribute('href'), visible: a.offsetParent !== null }))
check(`${label} login_link_ticketsystem`, link.visible && link.text === 'Zum Ticketsystem' && link.href === 'https://ticket.webklar.com', JSON.stringify(link))
check(`${label} kein_mfa_formular`, (await page.$('#mfa-form')) === null)
await page.waitForTimeout(1200)
await page.screenshot({ path: `${SHOTS}/${label}-login-mitarbeiter.png` })
check(`${label} keine_js_fehler`, errors.length === 0, errors.join(' | '))
await ctx.close()