( value: string, options: NormalizeStructuredEnvelopeOptions, key?: string, path: string[] = [], )
| 28 | } |
| 29 | |
| 30 | function normalizeString( |
| 31 | value: string, |
| 32 | options: NormalizeStructuredEnvelopeOptions, |
| 33 | key?: string, |
| 34 | path: string[] = [], |
| 35 | ): string { |
| 36 | const parentKey = path.at(-2); |
| 37 | const isVerboseRuntimeCaptureRef = |
| 38 | path.includes('capture') && (path.includes('elements') || path.includes('actions')); |
| 39 | let result = normalizeBaseString(value, options); |
| 40 | |
| 41 | if (parentKey === 'stderr') { |
| 42 | result = result.replace(/^\[\d+\/\d+\] /, '[<STEP>] '); |
| 43 | } |
| 44 | |
| 45 | if (key === 'rawResponseJsonPath') { |
| 46 | return '<RAW_RESPONSE_JSON_PATH>'; |
| 47 | } |
| 48 | |
| 49 | if (key === 'screenHash') { |
| 50 | return '<SCREEN_HASH>'; |
| 51 | } |
| 52 | |
| 53 | if ( |
| 54 | key !== undefined && |
| 55 | ELEMENT_REF_KEYS.has(key) && |
| 56 | isElementRef(result) && |
| 57 | !isVerboseRuntimeCaptureRef |
| 58 | ) { |
| 59 | return '<ELEMENT_REF>'; |
| 60 | } |
| 61 | |
| 62 | if (key === 'AXFrame') { |
| 63 | // Round embedded floats to 1 decimal place for rounding-stable comparison with |
| 64 | // the sibling `frame` object. e.g. 82.666664123535156 -> 82.7, 250.5 stays 250.5. |
| 65 | result = result.replace(/(\d+)\.(\d{2,})/g, (_full, intPart: string, fracPart: string) => { |
| 66 | const value = parseFloat(`${intPart}.${fracPart}`); |
| 67 | return (Math.round(value * 10) / 10).toString(); |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | // Simulator state (e.g. 'Booted' | 'Shutdown') is inherently volatile across |
| 72 | // test runs — any previous test may have booted or shut down a simulator. |
| 73 | // Replace with a stable placeholder. |
| 74 | if (key === 'state' && path.includes('simulators')) { |
| 75 | return '<SIM_STATE>'; |
| 76 | } |
| 77 | |
| 78 | if (key === 'state' && isDeviceListPath(path)) { |
| 79 | return '<DEVICE_STATE>'; |
| 80 | } |
| 81 | |
| 82 | if (key === 'osVersion' && path.includes('devices')) { |
| 83 | return '<OS_VERSION>'; |
| 84 | } |
| 85 | |
| 86 | if (key === 'runtime' && isIosRuntimeLabel(result)) { |
| 87 | return 'iOS <VERSION>'; |
no test coverage detected