Public Access
Merge branch 'claude/edit-screen-refresh-items-63a808'
This commit is contained in:
@@ -319,6 +319,95 @@ public sealed class VaultSharingTests : IAsyncLifetime
|
||||
shell.Vault.HasVaultChoice.ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// And it reaches a host editor that was already open, which is very nearly the only way a vault gets made:
|
||||
/// somebody starts adding a host, realises it belongs to the team rather than to them, and goes to make
|
||||
/// somewhere to put it. The editor's picker is its own — see <c>VaultViewModel.EditorVaultChoices</c> — and
|
||||
/// it was filled when the editor opened, so the vault they had just made for this host was the one place
|
||||
/// they could not file it without throwing the form away.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The second half is what stops the fix being worse than the bug: the refill adds the entry and leaves the
|
||||
/// selection alone, so a vault appearing cannot move a half-typed host into it.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task AVaultCreatedWithAHostEditorOpen_IsOfferedAsSomewhereToFileThatHost()
|
||||
{
|
||||
await UnlockedAsync();
|
||||
|
||||
var vault = shell.Vault!;
|
||||
|
||||
vault.NewHostCommand.Execute(null);
|
||||
vault.EditorLabel = "prod-db";
|
||||
vault.EditorHostname = "db.internal";
|
||||
|
||||
await CreateVaultAsync(shell.Vaults, "Platform secrets");
|
||||
|
||||
var vaultId = shell.Vaults.SelectedVault!.VaultId;
|
||||
|
||||
vault.IsEditing.ShouldBeTrue("making a vault must not close the host editor");
|
||||
vault.EditorLabel.ShouldBe("prod-db", "nor discard what has been typed into it");
|
||||
|
||||
vault.ShowsEditorVaultChoice.ShouldBeTrue(
|
||||
"a second writable vault is what makes the picker worth drawing at all");
|
||||
|
||||
vault.EditorVaultChoices.Select(choice => choice.VaultId).ShouldContain(vaultId);
|
||||
|
||||
vault.EditorSelectedVault.ShouldNotBeNull().IsPersonal
|
||||
.ShouldBeTrue("the refill must not move the host into the vault that has just appeared");
|
||||
|
||||
// Choosing it, on the other hand, files the host there — which is what the picker was for.
|
||||
vault.EditorSelectedVault = vault.EditorVaultChoices.Single(
|
||||
choice => choice.VaultId == vaultId);
|
||||
|
||||
await vault.SaveHostCommand.ExecuteAsync(null);
|
||||
|
||||
vault.Hosts.ShouldHaveSingleItem().VaultId.ShouldBe(vaultId, vault.Status);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// The snippet editor's picker is a copy of the same list — see
|
||||
/// <c>SnippetsViewModel.BuildEditorVaultChoices</c> — and went stale in exactly the same way. It watches the
|
||||
/// list rather than the reload, because this screen has always been a wrapper over the vault's collections
|
||||
/// and has no reload of its own to hang off.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task AVaultCreatedWithASnippetEditorOpen_IsOfferedAsSomewhereToFileThatSnippet()
|
||||
{
|
||||
await UnlockedAsync();
|
||||
|
||||
var vault = shell.Vault!;
|
||||
var snippets = SnippetsOver(vault);
|
||||
|
||||
snippets.NewCommand.Execute(null);
|
||||
snippets.EditorLabel = "restart the api";
|
||||
snippets.EditorCommand = "sudo systemctl restart dodossh-api";
|
||||
|
||||
await CreateVaultAsync(shell.Vaults, "Platform secrets");
|
||||
|
||||
var vaultId = shell.Vaults.SelectedVault!.VaultId;
|
||||
|
||||
snippets.IsEditing.ShouldBeTrue("making a vault must not close the snippet editor");
|
||||
snippets.EditorCommand.ShouldBe(
|
||||
"sudo systemctl restart dodossh-api",
|
||||
"nor discard what has been typed into it");
|
||||
|
||||
snippets.ShowsEditorVaultChoice.ShouldBeTrue("there are two vaults to choose between now");
|
||||
snippets.EditorVaultChoices.Select(choice => choice.VaultId).ShouldContain(vaultId);
|
||||
|
||||
snippets.EditorSelectedVault.ShouldNotBeNull().IsPersonal
|
||||
.ShouldBeTrue("the refill must not move the snippet into the vault that has just appeared");
|
||||
|
||||
snippets.EditorSelectedVault = snippets.EditorVaultChoices.Single(
|
||||
choice => choice.VaultId == vaultId);
|
||||
|
||||
await snippets.SaveCommand.ExecuteAsync(null);
|
||||
|
||||
Snippet(snippets, "restart the api").VaultId.ShouldBe(vaultId, snippets.Status);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Making a vault makes exactly one membership list, and this is the assertion that the two-step create
|
||||
/// has not started leaking them: the screen no longer offers to make one on its own, so a second one
|
||||
|
||||
Reference in New Issue
Block a user