-
Notifications
You must be signed in to change notification settings - Fork 1
Heedls 513 group delegates #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
43c47aa
HEEDLS-513 Add new group delegates page
AlexJacksonDS 8206e63
HEEDLS-513 Unit tests
AlexJacksonDS 603a869
HEEDLS-513 Formatting new link
AlexJacksonDS eb4a3bc
HEEDLS-513 Fix build error post merge
AlexJacksonDS 1933c91
HEEDLS-513 Add breadcrumbs to page
AlexJacksonDS 457d9a8
HEEDLS-513 Correct unit test names
AlexJacksonDS f0482b2
HEEDLS-513 Review markups
AlexJacksonDS ca001a8
HEEDLS-513 Refactoring unit Tests
AlexJacksonDS d617ec3
HEEDLS-513 Rename unit test and hopefully fix indentation
AlexJacksonDS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
47 changes: 47 additions & 0 deletions
47
...lLearningSolutions.Data.Tests/NBuilderHelpers/NBuilderAlphabeticalPropertyNamingHelper.cs
This file contains hidden or 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,47 @@ | ||
| namespace DigitalLearningSolutions.Data.Tests.NBuilderHelpers | ||
| { | ||
| using System; | ||
| using NUnit.Framework; | ||
|
|
||
| public static class NBuilderAlphabeticalPropertyNamingHelper | ||
| { | ||
| public static string IndexToAlphabeticalString(int index) | ||
| { | ||
| if (index < 0) | ||
| { | ||
| throw new ArgumentOutOfRangeException(nameof(index) , @"Index must be greater than or equal to zero"); | ||
| } | ||
|
|
||
| var remainder = index % 26; | ||
| var place = index / 26; | ||
|
|
||
| var s = new string('Z', place); | ||
| s += GetNthLetterOfAlphabet(remainder); | ||
|
|
||
| return s; | ||
| } | ||
|
|
||
| private static char GetNthLetterOfAlphabet(int n) | ||
| { | ||
| return (char)(n + 65); | ||
| } | ||
| } | ||
|
|
||
| public class NBuilderAlphabeticalPropertyNamingHelperTests | ||
| { | ||
| [Test] | ||
| [TestCase(0, ExpectedResult = "A")] | ||
| [TestCase(25, ExpectedResult = "Z")] | ||
| [TestCase(26, ExpectedResult = "ZA")] | ||
| [TestCase(51, ExpectedResult = "ZZ")] | ||
| [TestCase(52, ExpectedResult = "ZZA")] | ||
| [TestCase(77, ExpectedResult = "ZZZ")] | ||
| [TestCase(78, ExpectedResult = "ZZZA")] | ||
| [TestCase(103, ExpectedResult = "ZZZZ")] | ||
| public string IndexToAlphabeticalString_returns_expected_string(int inputIndex) | ||
| { | ||
| return NBuilderAlphabeticalPropertyNamingHelper.IndexToAlphabeticalString(inputIndex); | ||
| } | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
DigitalLearningSolutions.Data.Tests/TestHelpers/GroupTestHelper.cs
This file contains hidden or 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,29 @@ | ||
| namespace DigitalLearningSolutions.Data.Tests.TestHelpers | ||
| { | ||
| using DigitalLearningSolutions.Data.Models.DelegateGroups; | ||
|
|
||
| public static class GroupTestHelper | ||
| { | ||
| public static GroupDelegate GetDefaultGroupDelegate( | ||
| int groupDelegateId = 62, | ||
| int groupId = 5, | ||
| int delegateId = 245969, | ||
| string? firstName = "xxxxx", | ||
| string lastName = "xxxx", | ||
| string? emailAddress = "gslectik.m@vao", | ||
| string candidateNumber = "KT553" | ||
| ) | ||
| { | ||
| return new GroupDelegate | ||
| { | ||
| GroupDelegateId = groupDelegateId, | ||
| GroupId = groupId, | ||
| DelegateId = delegateId, | ||
| FirstName = firstName, | ||
| LastName = lastName, | ||
| EmailAddress = emailAddress, | ||
| CandidateNumber = candidateNumber | ||
| }; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
DigitalLearningSolutions.Data/Models/DelegateGroups/GroupDelegate.cs
This file contains hidden or 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,25 @@ | ||
| namespace DigitalLearningSolutions.Data.Models.DelegateGroups | ||
| { | ||
| public class GroupDelegate : BaseSearchableItem | ||
| { | ||
| public int GroupDelegateId { get; set; } | ||
|
|
||
| public int GroupId { get; set; } | ||
|
|
||
| public int DelegateId { get; set; } | ||
|
|
||
| public string? FirstName { get; set; } | ||
|
|
||
| public string LastName { get; set; } | ||
|
|
||
| public string? EmailAddress { get; set; } | ||
|
|
||
| public string CandidateNumber { get; set; } | ||
|
|
||
| public override string SearchableName | ||
| { | ||
| get => SearchableNameOverrideForFuzzySharp ?? $"{FirstName} {LastName}"; | ||
| set => SearchableNameOverrideForFuzzySharp = value; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
63 changes: 63 additions & 0 deletions
63
...b.Tests/ViewModels/TrackingSystem/Delegates/DelegateGroups/GroupDelegateViewModelTests.cs
This file contains hidden or 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,63 @@ | ||
| namespace DigitalLearningSolutions.Web.Tests.ViewModels.TrackingSystem.Delegates.DelegateGroups | ||
| { | ||
| using DigitalLearningSolutions.Data.Models.DelegateGroups; | ||
| using DigitalLearningSolutions.Data.Tests.TestHelpers; | ||
| using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.DelegateGroups; | ||
| using FizzWare.NBuilder; | ||
| using FluentAssertions; | ||
| using FluentAssertions.Execution; | ||
| using NUnit.Framework; | ||
|
|
||
| public class GroupDelegateViewModelTests | ||
| { | ||
| [Test] | ||
| public void GroupDelegateViewModel_populates_expected_values_with_both_names() | ||
| { | ||
| // Given | ||
| var groupDelegate = Builder<GroupDelegate>.CreateNew() | ||
| .With(gd => gd.GroupDelegateId = 62) | ||
| .With(gd => gd.FirstName = "Test") | ||
| .With(gd => gd.LastName = "Name") | ||
| .With(gd => gd.EmailAddress = "gslectik.m@vao") | ||
| .With(gd => gd.CandidateNumber = "KT553") | ||
| .Build(); | ||
|
|
||
| // When | ||
| var result = new GroupDelegateViewModel(groupDelegate); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| result.GroupDelegateId.Should().Be(62); | ||
| result.Name.Should().Be("Test Name"); | ||
| result.EmailAddress.Should().Be("gslectik.m@vao"); | ||
| result.CandidateNumber.Should().Be("KT553"); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void GroupDelegateViewModel_populates_expected_values_with_only_last_name() | ||
| { | ||
| // Given | ||
| var groupDelegate = Builder<GroupDelegate>.CreateNew() | ||
| .With(gd => gd.GroupDelegateId = 62) | ||
| .With(gd => gd.FirstName = null) | ||
| .With(gd => gd.LastName = "Name") | ||
| .With(gd => gd.EmailAddress = "gslectik.m@vao") | ||
| .With(gd => gd.CandidateNumber = "KT553") | ||
| .Build(); | ||
|
|
||
| // When | ||
| var result = new GroupDelegateViewModel(groupDelegate); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| result.GroupDelegateId.Should().Be(62); | ||
| result.Name.Should().Be("Name"); | ||
| result.EmailAddress.Should().Be("gslectik.m@vao"); | ||
| result.CandidateNumber.Should().Be("KT553"); | ||
| } | ||
| } | ||
| } | ||
| } |
73 changes: 73 additions & 0 deletions
73
....Tests/ViewModels/TrackingSystem/Delegates/DelegateGroups/GroupDelegatesViewModelTests.cs
This file contains hidden or 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,73 @@ | ||
| namespace DigitalLearningSolutions.Web.Tests.ViewModels.TrackingSystem.Delegates.DelegateGroups | ||
| { | ||
| using System.Linq; | ||
| using DigitalLearningSolutions.Data.Models.DelegateGroups; | ||
| using DigitalLearningSolutions.Data.Tests.NBuilderHelpers; | ||
| using DigitalLearningSolutions.Web.Models.Enums; | ||
| using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage; | ||
| using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.DelegateGroups; | ||
| using FizzWare.NBuilder; | ||
| using FluentAssertions; | ||
| using FluentAssertions.Execution; | ||
| using NUnit.Framework; | ||
|
|
||
| public class GroupDelegatesViewModelTests | ||
| { | ||
| private readonly DelegateGroupsSideNavViewModel expectedNavViewModel = | ||
| new DelegateGroupsSideNavViewModel("Group name", DelegateGroupPage.Delegates); | ||
|
|
||
| private GroupDelegate[] groupDelegates = null!; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| BuilderSetup.DisablePropertyNamingFor<GroupDelegate, string>(g => g.SearchableName); | ||
| groupDelegates = Builder<GroupDelegate>.CreateListOfSize(15) | ||
| .All() | ||
| .With(g => g.LastName = "Surname") | ||
| .With((g, i) => g.FirstName = NBuilderAlphabeticalPropertyNamingHelper.IndexToAlphabeticalString(i)) | ||
| .Build().ToArray(); | ||
| } | ||
|
|
||
| [Test] | ||
| public void GroupDelegatesViewModel_should_return_the_first_page_worth_of_delegates() | ||
| { | ||
| var model = new GroupDelegatesViewModel( | ||
| 1, | ||
| "Group name", | ||
| groupDelegates, | ||
| 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I don't properly understand this, but the test name claims it is defaulting to returning the first page, but this looks like an explicit request for the first page. |
||
| ); | ||
|
|
||
| using (new AssertionScope()) | ||
| { | ||
| model.GroupId.Should().Be(1); | ||
| model.NavViewModel.Should().BeEquivalentTo(expectedNavViewModel); | ||
| model.GroupDelegates.Count().Should().Be(BaseSearchablePageViewModel.DefaultItemsPerPage); | ||
| model.GroupDelegates.Any(groupDelegate => groupDelegate.Name == "K Surname").Should() | ||
| .BeFalse(); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void GroupDelegatesViewModel_should_correctly_return_the_second_page_of_delegates() | ||
| { | ||
| var model = new GroupDelegatesViewModel( | ||
| 1, | ||
| "Group name", | ||
| groupDelegates, | ||
| 2 | ||
| ); | ||
| var expectedFirstGroupDelegate = | ||
| groupDelegates.Skip(BaseSearchablePageViewModel.DefaultItemsPerPage).First(); | ||
|
|
||
| using (new AssertionScope()) | ||
| { | ||
| model.GroupId.Should().Be(1); | ||
| model.NavViewModel.Should().BeEquivalentTo(expectedNavViewModel); | ||
| model.GroupDelegates.Count().Should().Be(5); | ||
| model.GroupDelegates.First().Name.Should().BeEquivalentTo($"{expectedFirstGroupDelegate.FirstName} {expectedFirstGroupDelegate.LastName}"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
8 changes: 8 additions & 0 deletions
8
DigitalLearningSolutions.Web/Models/Enums/DelegateGroupPage.cs
This file contains hidden or 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,8 @@ | ||
| namespace DigitalLearningSolutions.Web.Models.Enums | ||
| { | ||
| public enum DelegateGroupPage | ||
SteveJacksonSoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| Delegates, | ||
| Courses | ||
| } | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
DigitalLearningSolutions.Web/Styles/trackingSystem/delegates/groupDelegates.scss
This file contains hidden or 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,2 @@ | ||
| @import 'delegateCommon'; | ||
| @import '../../shared/searchableElements/searchableElements'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.