fix(card-editor): confirming an empty new card creates nothing
PLAN 5.4 says an unchanged confirmation writes nothing, but the shortcut applied only to existing cards, so OK on a blank new-card editor added an empty card. A new card with no title, content or tags is now not created.
This commit is contained in:
1 parent
4a88033695
commit
ce6d9d2f83
4 files changed
+52
-8
No files matched your search
@@ -225,6 +225,48 @@ public class BoardViewModelTests
|
||||
Assert.AreEqual(100, fixture.Repository.GetCard(card.Id)!.UpdatedAt);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConfirmingAnEmptyNewCardCreatesNothing()
|
||||
{
|
||||
using var fixture = new Fixture();
|
||||
ColumnModel column = fixture.Repository.AddColumn("A", "");
|
||||
var editor = CardEditorDialogViewModel.ForNewCard(fixture.Repository, fixture.Dialogs, column.Id, confirmDiscard: true);
|
||||
bool? closedWith = null;
|
||||
editor.CloseRequested += (_, result) => closedWith = result;
|
||||
editor.CardTitle = "draft";
|
||||
editor.CardTitle = "";
|
||||
|
||||
editor.ConfirmCommand.Execute(null);
|
||||
|
||||
Assert.IsTrue(closedWith);
|
||||
Assert.IsNull(editor.SavedCard);
|
||||
Assert.AreEqual(0, fixture.Repository.GetCards().Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task NewCardWithOnlyATagIsCreated()
|
||||
{
|
||||
using var fixture = new Fixture();
|
||||
ColumnModel column = fixture.Repository.AddColumn("A", "");
|
||||
TagModel bug = fixture.Repository.AddTag("bug", new RgbColor(255, 0, 0), "");
|
||||
var editor = CardEditorDialogViewModel.ForNewCard(fixture.Repository, fixture.Dialogs, column.Id, confirmDiscard: true);
|
||||
fixture.Dialogs.Script = dialog =>
|
||||
{
|
||||
if (dialog is TagPickerDialogViewModel picker)
|
||||
{
|
||||
picker.PickCommand.Execute(picker.FilteredTags.Single());
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await editor.AddTagCommand.ExecuteAsync(null);
|
||||
editor.ConfirmCommand.Execute(null);
|
||||
|
||||
CardModel card = fixture.Repository.GetCards().Single();
|
||||
Assert.AreEqual("", card.Title);
|
||||
Assert.AreEqual(bug.Id, card.Tags.Single().Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task DirtyCancelAsksAndStaysOpenWhenDeclined()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user