-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from mule/pr-56-collapsible-session-groups
Pr 56 collapsible session groups
- Loading branch information
Showing
20 changed files
with
541 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@using FluentAssertions | ||
@using BlazorComponentBus | ||
@using Abotti.BlazorComponents | ||
@using Abotti.BlazorComponents.Contracts | ||
@inherits TestContext | ||
|
||
@code { | ||
|
||
[Fact] | ||
public void ChatSessionListRow_should_render_successfully() | ||
{ | ||
// Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
// Act | ||
var action = () => Render(@<ChatSessionListRow/>); | ||
|
||
// Assert | ||
action.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionListRow_should_show_chat_topic() | ||
{ | ||
// Arrange | ||
var testTopic = "Test topic"; | ||
Services.AddScoped<ComponentBus>(); | ||
|
||
// Act | ||
var cut = Render(@<ChatSessionListRow Topic="@testTopic"/>); | ||
|
||
// Assert | ||
cut.Markup.Should().Contain(testTopic); | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionListRow_should_show_chat_session_id() | ||
{ | ||
// Arrange | ||
var testSessionId = Guid.NewGuid(); | ||
Services.AddScoped<ComponentBus>(); | ||
|
||
// Act | ||
var cut = Render(@<ChatSessionListRow SessionId="@testSessionId"/>); | ||
|
||
// Assert | ||
cut.Markup.Should().Contain(testSessionId.ToString()); | ||
} | ||
|
||
|
||
[Fact] | ||
public void ChatSessionListRow_should_publish_delete_event() | ||
{ | ||
// Arrange | ||
var testSessionId = Guid.NewGuid(); | ||
var eventFired = false; | ||
Services.AddScoped<ComponentBus>(); | ||
|
||
var bus = Services.GetService(typeof(ComponentBus)) as ComponentBus; | ||
|
||
bus.Subscribe<ChatSessionDeleteRequest>(async (args, ct) => | ||
{ | ||
eventFired = true; | ||
var msg = args.GetMessage<ChatSessionDeleteRequest>(); | ||
msg.SessionId.Should().Be(testSessionId); | ||
}); | ||
|
||
// Act | ||
var cut = Render(@<ChatSessionListRow SessionId="@testSessionId"/>); | ||
|
||
var deleteButton = cut.Find("button"); | ||
deleteButton.Click(); | ||
eventFired.Should().BeTrue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@using FluentAssertions | ||
@using AutoFixture | ||
@using BlazorComponentBus | ||
@using Abotti.BlazorComponents | ||
@using Abotti.Core.QueryResults | ||
@inherits TestContext | ||
|
||
@code { | ||
|
||
[Fact] | ||
public void ChatSessionsGroup_should_render_succesfully() | ||
{ | ||
//Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
|
||
//Act | ||
var act = () => Render(@<ChatSessionsGroup GroupName="Test group"/>); | ||
|
||
//Assert | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionsGroup_should_render_group_name() | ||
{ | ||
//Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
|
||
//Act | ||
var cut = Render(@<ChatSessionsGroup GroupName="Test group"/>); | ||
|
||
//Assert | ||
cut.Markup.Should().Contain("Test group"); | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionsGroup_should_render_given_topics() | ||
{ | ||
//Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
var fixture = new Fixture(); | ||
var testTopics = fixture.CreateMany<TopicQueryResult>().ToArray(); | ||
|
||
//Act | ||
var cut = Render(@<ChatSessionsGroup GroupName="Test group" SessionTopics="@testTopics" IsCollapsed="false"/>); | ||
|
||
//Assert | ||
foreach (var testTopic in testTopics) | ||
{ | ||
//Markup should contain all topics | ||
cut.Markup.Should().Contain(testTopic.Topic); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@using FluentAssertions | ||
@using BlazorComponentBus | ||
@using Abotti.BlazorComponents | ||
@using Abotti.BlazorComponents.ViewModels | ||
@using Abotti.BlazorComponentTests.TestData | ||
@inherits TestContext | ||
|
||
|
||
@code { | ||
|
||
private bool _commonSetupExecuted; | ||
|
||
public void SetUp() | ||
{ | ||
if (!_commonSetupExecuted) | ||
{ | ||
Services.AddLocalization(); | ||
|
||
_commonSetupExecuted = true; | ||
} | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionsList_should_render_successfully() | ||
{ | ||
//Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
SetUp(); | ||
|
||
|
||
//Act | ||
var act = () => Render(@<ChatSessionsList/>); | ||
|
||
//Assert | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void ChatSessionsList_should_render_groups_correctly() | ||
{ | ||
//Arrange | ||
Services.AddScoped<ComponentBus>(); | ||
SetUp(); | ||
var vm = new ChatSessionsListVm(ChatSessionsListData.Topics); | ||
|
||
|
||
//Act | ||
var cut = Render(@<ChatSessionsList ChatSessionsListVm="@vm" ReferenceDate="@ChatSessionsListData.ReferenceDate"/>); | ||
|
||
//Assert | ||
//find all groups | ||
var groups = cut.FindAll(".chat-sessions-group"); | ||
groups.Should().HaveCount(5); | ||
} | ||
|
||
} |
Oops, something went wrong.