also looking at this
fix(ios): settle a Siri shortcut removal whose completion never comes
#227
7 files
+503
-94
| @@ -173,6 +173,29 @@ describe('Craft iOS builder', () => { | ||
| 173 | 173 | expect(swift).not.toContain("addEventListener('craftOTAStatus'") |
| 174 | 174 | }) |
| 175 | 175 | |
| 176 | it('settles a Siri shortcut removal whose completion never comes', async () => { | |
| 177 | // #211: the deletion completion comes from a system daemon, and on a | |
| 178 | // fresh simulator it sometimes never does. The Swift arm only runs in | |
| 179 | // apps without the Zig runtime, so no simulator suite reaches it. | |
| 180 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-siri-removal-')) | |
| 181 | await init({ runtimeDir: null, name: 'WildLoop', bundleId: 'org.wildloop.app', output }) | |
| 182 | ||
| 183 | const swift = readFileSync(join(output, 'Sources', 'WildLoopApp.swift'), 'utf8') | |
| 184 | const start = swift.indexOf('private func removeSiriShortcut(') | |
| 185 | const removal = swift.slice(start, swift.indexOf('// MARK: - Watch Connectivity', start)) | |
| 186 | ||
| 187 | expect(start).toBeGreaterThan(-1) | |
| 188 | expect(removal).toContain('DispatchQueue.main.asyncAfter(deadline: .now() + Coordinator.siriRemovalDeadline, execute: deadline)') | |
| 189 | expect(removal).toContain('code: "TIMEOUT"') | |
| 190 | // Exactly one answer: both halves take the same entry, and only the one | |
| 191 | // that finds it replies. | |
| 192 | expect(removal.split('self.pendingSiriRemovals.removeValue(forKey: token)')).toHaveLength(3) | |
| 193 | expect(removal).toContain('pending.cancel()') | |
| 194 | // The deadline never claims the shortcut is gone. | |
| 195 | const deadline = removal.slice(removal.indexOf('let deadline'), removal.indexOf('pendingSiriRemovals[token] = deadline')) | |
| 196 | expect(deadline).not.toContain('"removed": true') | |
| 197 | }) | |
| 198 | ||
| 176 | 199 | it('returns completed video recordings as the documented base64 string', async () => { |
| 177 | 200 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-video-recording-')) |
| 178 | 201 | await init({ |