Keep the chosen language across sign-in and forced sign-out

A language picked on a signed-out page is now stored on the account when
the user signs in (StoreLocaleChosenBeforeLogin), so the app does not
switch back to the account default. EnsureAccountIsUsable keeps the user's
language for the login page when it ends a disabled account's session.

ChangePreferredLocale runs in a transaction like the other use cases, the
language names come from layout.languages instead of the Locale enum, and
the translation test also compares fi.json with en.json and rejects
English files without a Finnish counterpart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-25 07:09:22 +02:00
co-authored by Claude Opus 5.5
parent 4f926c238b
commit 45dbb04344
14 changed files with 170 additions and 36 deletions
@@ -2,17 +2,15 @@
use App\Modules\Users\Application\UseCases\ChangePreferredLocale;
use App\Modules\Users\Domain\Enums\Locale;
use Tests\Fakes\FakeTransactionManager;
use Tests\Fakes\InMemoryUserAccountRepository;
it('stores the chosen language on the account', function () {
it('stores the chosen language on the account in a transaction', function () {
$users = new InMemoryUserAccountRepository;
$transactions = new FakeTransactionManager;
(new ChangePreferredLocale($users))->execute(7, Locale::English);
(new ChangePreferredLocale($users, $transactions))->execute(7, Locale::English);
expect($users->locales)->toBe([7 => Locale::English]);
});
it('names each language in the language itself', function () {
expect(Locale::Finnish->nativeName())->toBe('Suomi')
->and(Locale::English->nativeName())->toBe('English');
expect($users->locales)->toBe([7 => Locale::English])
->and($transactions->transactionCount)->toBe(1);
});