From ce2a65d1c71a70f621d814c51e79b4d0a203a00f Mon Sep 17 00:00:00 2001 From: Imani Manyara Date: Mon, 12 Oct 2026 16:06:02 -0400 Subject: [PATCH] Make the production editor test independent of test order Setting the app environment to production turns off runningUnitTests(), so Laravel stops routing prompts through its fakeable fallback. The test only passed because an earlier test had already set the sticky fallback flag; run alone, or reordered as in the mutation job, select() rendered a real prompt with no TTY and threw NonInteractiveValidationException. --- CHANGELOG.md | 7 +++++++ tests/Feature/TuiTest.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a510156..e440ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- The `--force-production` editor test no longer depends on test order. Switching the app to + `production` turns off Laravel's fakeable prompt fallback, so run alone (as the mutation job + can) the editor rendered real prompts with no TTY and `select()` threw + `NonInteractiveValidationException: Required.` The test now enables the fallback itself. + ### Changed - `illuminate/bus` is now declared in `require` at `^13.0`. `src/` imports it, and it was only arriving transitively. diff --git a/tests/Feature/TuiTest.php b/tests/Feature/TuiTest.php index 4f2141b..633cd52 100644 --- a/tests/Feature/TuiTest.php +++ b/tests/Feature/TuiTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Laravel\Prompts\Prompt; use Simtabi\Laranail\EnvKit\Headless\Facades\EnvKit; use Simtabi\Laranail\EnvKit\Headless\Tests\TestCase; use Simtabi\Laranail\EnvKit\Headless\Contracts\EnvKitInterface; @@ -102,6 +103,15 @@ $this->app['env'] = 'production'; $this->app->forgetInstance(EnvKitInterface::class); + // Leaving the testing environment turns off runningUnitTests(), which is what + // makes Laravel route prompts through its fakeable fallback. Without it the + // command renders real prompts, which read STDIN and, with no TTY, fall back + // to the empty default: select() then throws NonInteractiveValidationException. + // The fallback flag is sticky (fallbackWhen ORs), so this only passed when an + // earlier test had already set it -- and failed when run alone or reordered, + // as the mutation job does. Set it here so the test stands on its own. + Prompt::fallbackWhen(true); + $this->artisan('laranail::env-kit.edit', ['--force-production' => true]) ->expectsQuestion('Choose a key or action', 'A') ->expectsQuestion('Edit [A]', 'Edit value')