base = r'D:\Dev\Projects\pdf-umbenenner-parent'

files_to_fix = [
    rf'{base}\pdf-umbenenner-application\src\test\java\de\gecheckt\pdf\umbenenner\application\usecase\BatchRunProgressObservationTest.java',
    rf'{base}\pdf-umbenenner-adapter-in-gui\src\test\java\de\gecheckt\pdf\umbenenner\adapter\in\gui\batchrun\GuiBatchRunCoordinatorTest.java',
    rf'{base}\pdf-umbenenner-adapter-in-gui\src\test\java\de\gecheckt\pdf\umbenenner\adapter\in\gui\batchrun\GuiBatchRunTabSmokeTest.java',
    rf'{base}\pdf-umbenenner-adapter-in-gui\src\test\java\de\gecheckt\pdf\umbenenner\adapter\in\gui\batchrun\GuiBatchRunTabSelectionSmokeTest.java',
]

for path in files_to_fix:
    with open(path, 'rb') as f:
        content = f.read()
    normalized = content.replace(b'\r\n', b'\n')

    # Replace SKIPPED that is NOT already followed by _ALREADY or _FINAL
    import re
    new_content = re.sub(
        b'DocumentCompletionStatus\\.SKIPPED(?!_)',
        b'DocumentCompletionStatus.SKIPPED_ALREADY_PROCESSED',
        normalized
    )
    # Also fix the string "row:SKIPPED:" in coordinator test
    new_content = new_content.replace(b'"row:SKIPPED:', b'"row:SKIPPED_ALREADY_PROCESSED:')

    if new_content != normalized:
        result = new_content.replace(b'\n', b'\r\n')
        with open(path, 'wb') as f:
            f.write(result)
        print(f'FIXED: {path.split(chr(92))[-1]}')
    else:
        print(f'NO CHANGE: {path.split(chr(92))[-1]}')
