@@ -14,9 +14,11 @@ extension BaseSuite {
1414 redirectURL: URL ( string: " http://localhost:1234/callback " ) ,
1515 token: " deadbeef "
1616 )
17+ $0. continuousClock = TestClock ( )
1718 }
1819 )
1920 @MainActor struct InstallTests {
21+ @Dependency ( \. continuousClock, as: TestClock< Duration> . self ) var clock
2022 @Dependency ( \. fileSystem, as: InMemoryFileSystem . self) var fileSystem
2123
2224 @Test func noToolSpecified( ) async throws {
@@ -36,21 +38,25 @@ extension BaseSuite {
3638 }
3739
3840 @Test (
39- . dependencies {
41+ . dependencies { dependencies in
4042 try save ( token: " expired-deadbeef " )
41- $0. pointFreeServer = try InMemoryPointFreeServer (
42- result: . success(
43- [
44- URL ( filePath: " /skills/ComposableArchitecture/SKILL.md " ) : Data (
45- """
46- # Composable Architecture
47- """ . utf8
48- )
49- ] . toData
50- )
43+ dependencies. pointFreeServer = InMemoryPointFreeServer . init (
44+ results: [
45+ . failure( . notLoggedIn( " Token expired " ) ) ,
46+ . success(
47+ try [
48+ URL ( filePath: " /skills/ComposableArchitecture/SKILL.md " ) : Data (
49+ """
50+ # Composable Architecture
51+ """ . utf8
52+ )
53+ ] . toData
54+ ) ,
55+ ]
5156 )
5257 }
53- ) func expiredToken( ) async throws {
58+ )
59+ func expiredToken( ) async throws {
5460 assertInlineSnapshot ( of: fileSystem, as: . description) {
5561 """
5662 Users/
@@ -60,11 +66,23 @@ extension BaseSuite {
6066 tmp/
6167 """
6268 }
63- try await assertCommand ( [ " install " , " --tool " , " codex " ] ) {
64- """
65- Installed skills for codex into /Users/blob/.codex/skills/the-point-free-way
66- """
69+ let task = Task {
70+ try await assertCommand ( [ " install " , " --tool " , " codex " ] ) {
71+ """
72+ Authentication failed. Starting login flow...
73+ Open this URL to log in and approve access:
74+ http://localhost:8080/account/the-way/login?whoami=blob&machine=00000000-0000-0000-0000-000000000001&redirect=http://localhost:1234/callback
75+
76+ Waiting for browser redirect...
77+ Saved token to /Users/blob/.pfw/token.
78+ Login complete. Retrying install...
79+ Installed skills for codex into /Users/blob/.codex/skills/the-point-free-way
80+ """
81+ }
6782 }
83+ try await Task . sleep ( for: . seconds( 0.5 ) )
84+ await clock. run ( )
85+ try await task. value
6886 assertInlineSnapshot ( of: fileSystem, as: . description) {
6987 """
7088 Users/
@@ -76,10 +94,10 @@ extension BaseSuite {
7694 ComposableArchitecture/
7795 SKILL.md " # Composable Architecture "
7896 .pfw/
79- machine " 00000000-0000-0000-0000-000000000000 "
80- token " expired- deadbeef"
97+ machine " 00000000-0000-0000-0000-000000000002 "
98+ token " deadbeef "
8199 tmp/
82- 00000000-0000-0000-0000-000000000001 (94 bytes)
100+ 00000000-0000-0000-0000-000000000003 (94 bytes)
83101 """
84102 }
85103 }
@@ -88,9 +106,9 @@ extension BaseSuite {
88106 . dependencies {
89107 var command = try #require( try PFW . parseAsRoot ( [ " login " ] ) as? AsyncParsableCommand )
90108 try await command. run ( )
91- $0. pointFreeServer = try InMemoryPointFreeServer (
109+ $0. pointFreeServer = InMemoryPointFreeServer (
92110 result: . success(
93- [
111+ try [
94112 URL ( filePath: " /skills/ComposableArchitecture/SKILL.md " ) : Data (
95113 """
96114 # Composable Architecture
@@ -173,26 +191,26 @@ extension BaseSuite {
173191 }
174192
175193 // NB: This test shows a problem with using the '--path' option that we need to fix.
176- // @Test(
177- // .dependencies {
178- // try $0.fileSystem.createDirectory(
179- // at: URL(filePath: "/Users/blob/.copilot/skills"),
180- // withIntermediateDirectories: true
181- // )
182- // try $0.fileSystem.write(
183- // Data("Hello".utf8),
184- // to: URL(filePath: "/Users/blob/.copilot/skills/dont-delete.md")
185- // )
186- // }
187- // )
188- // func customPath() async throws {
189- // try await assertCommand(["install", "--path", "/Users/blob/.copilot/skills"]) {
190- // """
191- // Installed skills into /Users/blob/.copilot/skills
192- // """
193- // }
194- // assertInlineSnapshot(of: fileSystem, as: .description)
195- // }
194+ // @Test(
195+ // .dependencies {
196+ // try $0.fileSystem.createDirectory(
197+ // at: URL(filePath: "/Users/blob/.copilot/skills"),
198+ // withIntermediateDirectories: true
199+ // )
200+ // try $0.fileSystem.write(
201+ // Data("Hello".utf8),
202+ // to: URL(filePath: "/Users/blob/.copilot/skills/dont-delete.md")
203+ // )
204+ // }
205+ // )
206+ // func customPath() async throws {
207+ // try await assertCommand(["install", "--path", "/Users/blob/.copilot/skills"]) {
208+ // """
209+ // Installed skills into /Users/blob/.copilot/skills
210+ // """
211+ // }
212+ // assertInlineSnapshot(of: fileSystem, as: .description)
213+ // }
196214 }
197215 }
198216}
0 commit comments