Workflow-App/Workflow/scripts/_regex_test.py
sjcoetzeesj-coder 11d0178ab1 feat: commit Workflow app source; move CIPC credentials to env
Adds the full Next.js app (app/, components/, lib/, scripts/, assets/,
docs/, Dockerfile, compose, configs) to version control.

Security:
- CIPC BizPortal customer-code logins (Login 1 + Login 3) now read
  CIPC_LOGIN1_CODE / CIPC_LOGIN1_PASSWORD / CIPC_LOGIN3_CODE /
  CIPC_LOGIN3_PASSWORD from .env.local instead of source.
- BizPortal personal login in apply-bizportal route reads
  BIZPORTAL_ID_NO / BIZPORTAL_PASSWORD.
- Added .env.example as the committed template.

.gitignore excludes .env*, node_modules, .next, logs, sqlite, Playwright
storage_state.json (live CIPC cookies), scratch dirs, client PDFs and
debug screenshots.
2026-10-18 15:21:45 +02:00

44 lines
1.3 KiB
Python

import re
snap = '''- heading "Welcome" [level=1, ref=e3]
- textbox "Username" [required, ref=e9]
- link "Forgot Your Username?" [ref=e4]
- button "Next" [ref=e7]
- region "SARS AI Assistant Chat" [ref=e1]
- button "Open SARS AI Assistant Chat" [expanded=false, ref=e2]'''
def find_ref(snap, role, name=None):
if name is None:
pattern = rf"\b{re.escape(role)}\b[^\n]*?[,]?\s*ref=(e\d+)\]"
else:
pattern = (
rf"\b{re.escape(role)}\b[^\n]*?['\"]({re.escape(name)})['\"][^\n]*?"
rf"[,]?\s*ref=(e\d+)\]"
)
m = re.search(pattern, snap, re.MULTILINE)
if m:
return m.group(2) if m.lastindex and m.lastindex >= 2 else m.group(1)
return None
# Test all
cases = [
('textbox', 'Username', 'e9'),
('button', 'Next', 'e7'),
('link', 'Forgot Your Username?', 'e4'),
('heading', 'Welcome', 'e3'),
('region', 'SARS AI Assistant Chat', 'e1'),
('button', 'Open SARS AI Assistant Chat', 'e2'),
(None, 'e9'), # role-only
]
for c in cases:
if c[0] is None:
continue
role, name, want = c
got = find_ref(snap, role, name)
ok = 'OK' if got == want else 'FAIL'
print(f'{ok} find_ref({role!r}, {name!r}) = {got!r} (want {want!r})')
# Role-only
got = find_ref(snap, 'button', 'Next') # works
print('role+name:', got)