Adding list notification test

This commit is contained in:
rockstardev 2020-06-15 00:53:12 -05:00
parent 2c44c25b25
commit 261931c8ef
3 changed files with 33 additions and 4 deletions

View File

@ -1195,6 +1195,35 @@ namespace BTCPayServer.Tests
}
}
[Fact(Timeout = TestTimeout)]
[Trait("Integration", "Integration")]
public async Task CanListNotifications()
{
using (var tester = ServerTester.Create())
{
await tester.StartAsync();
var acc = tester.NewAccount();
acc.GrantAccess(true);
acc.RegisterDerivationScheme("BTC");
const string newVersion = "1.0.4.4";
var ctrl = acc.GetController<NotificationsController>();
var resp = await ctrl.Generate(newVersion);
var vm = Assert.IsType<Models.NotificationViewModels.IndexViewModel>(
Assert.IsType<ViewResult>(ctrl.Index().Result).Model);
Assert.True(vm.Skip == 0);
Assert.True(vm.Count == 50);
Assert.True(vm.Total == 1);
Assert.True(vm.Items.Count == 1);
var fn = vm.Items.First();
Assert.Equal($"New version {newVersion} released!", fn.Body);
Assert.Equal($"https://github.com/btcpayserver/btcpayserver/releases/tag/v{newVersion}", fn.ActionLink);
}
}
[Fact]
[Trait("Integration", "Integration")]
public async Task CanGetRates()

View File

@ -55,11 +55,11 @@ namespace BTCPayServer.Controllers
}
[HttpGet]
public async Task<IActionResult> Generate()
public async Task<IActionResult> Generate(string version)
{
await _notificationSender.NoticeNewVersionAsync("1.0.4.4");
await _notificationSender.NoticeNewVersionAsync(version);
// waiting for event handler to catch up
await Task.Delay(1000);
await Task.Delay(500);
return RedirectToAction(nameof(Index));
}

View File

@ -32,7 +32,7 @@
<button type="submit" class="dropdown-item" name="command" value="delete"><i class="fa fa-trash-o"></i> Delete</button>
</div>
</span>
<a class="btn btn-primary" role="button" asp-action="Generate" id="Generate"><span class="fa fa-plus"></span> Generate Test Notification</a>
<a class="btn btn-primary" role="button" asp-action="Generate" asp-route-version="1.0.4.4" id="Generate"><span class="fa fa-plus"></span> Generate Test Notification</a>
</div>
</div>
<div class="row">