44use App \Pipelines \Steps \CheckForUpdates ;
55use Illuminate \Http \Client \ConnectionException ;
66use Illuminate \Support \Facades \Http ;
7- use Laravel \Prompts \Prompt ;
87
98function makeUpdateContext (): SessionContext
109{
@@ -24,7 +23,6 @@ function makeUpdateContext(): SessionContext
2423 ]),
2524 ]);
2625
27- Prompt::fake ();
2826
2927 $ step = app (CheckForUpdates::class);
3028 $ context = makeUpdateContext ();
@@ -38,20 +36,18 @@ function makeUpdateContext(): SessionContext
3836
3937 expect ($ next_called )->toBeTrue ();
4038 expect ($ result )->toBe ($ context );
41-
42- Prompt::assertStrippedOutputDoesntContain ('new version of Clave is available ' );
39+ expect ($ context ->upgrade_version_available )->toBeNull ();
4340
4441 Http::assertSentCount (1 );
4542});
4643
47- test ('shows update notice when newer version is available ' , function () {
44+ test ('stores upgrade version when newer version is available ' , function () {
4845 Http::fake ([
4946 'api.github.com/repos/glhd/clave/releases/latest ' => Http::response ([
5047 'tag_name ' => 'v99.99.99 ' ,
5148 ]),
5249 ]);
5350
54- Prompt::fake ();
5551
5652 $ step = app (CheckForUpdates::class);
5753 $ context = makeUpdateContext ();
@@ -65,18 +61,14 @@ function makeUpdateContext(): SessionContext
6561
6662 expect ($ next_called )->toBeTrue ();
6763 expect ($ result )->toBe ($ context );
68-
69- Prompt::assertStrippedOutputContains ('new version of Clave is available ' );
70- Prompt::assertStrippedOutputContains ('v99.99.99 ' );
64+ expect ($ context ->upgrade_version_available )->toBe ('99.99.99 ' );
7165
7266 Http::assertSentCount (1 );
7367});
7468
7569test ('passes through silently when the HTTP request fails ' , function () {
7670 Http::fake (fn () => throw new ConnectionException ('Connection timed out ' ));
7771
78- Prompt::fake ();
79-
8072 $ step = app (CheckForUpdates::class);
8173 $ context = makeUpdateContext ();
8274
@@ -89,8 +81,7 @@ function makeUpdateContext(): SessionContext
8981
9082 expect ($ next_called )->toBeTrue ();
9183 expect ($ result )->toBe ($ context );
92-
93- Prompt::assertStrippedOutputDoesntContain ('new version of Clave is available ' );
84+ expect ($ context ->upgrade_version_available )->toBeNull ();
9485});
9586
9687test ('passes through silently when response is missing tag_name ' , function () {
@@ -100,7 +91,6 @@ function makeUpdateContext(): SessionContext
10091 ]),
10192 ]);
10293
103- Prompt::fake ();
10494
10595 $ step = app (CheckForUpdates::class);
10696 $ context = makeUpdateContext ();
@@ -114,8 +104,7 @@ function makeUpdateContext(): SessionContext
114104
115105 expect ($ next_called )->toBeTrue ();
116106 expect ($ result )->toBe ($ context );
117-
118- Prompt::assertStrippedOutputDoesntContain ('new version of Clave is available ' );
107+ expect ($ context ->upgrade_version_available )->toBeNull ();
119108
120109 Http::assertSentCount (1 );
121110});
0 commit comments