Skip to content

Conversation

@livzorn
Copy link
Contributor

@livzorn livzorn commented Sep 24, 2021

JIRA link

HEEDLS-443

Description

Added a new page at TrackingSystem/CourseSetup/{customisationId}/Manage/LearningPathwayDefaults with a form to edit the learning pathway defaults of a course. The controller contains some custom validations and error messages, checking whether the inputs for CompleteWithinMonths and ValidityMonths are numbers and within the range of 0 to 48 inclusive. If the input is null those values are saved as 0 (those columns are non-nullable) so that the user can leave them blank if they do not want to configure values.

Screenshots

localhost_5001_TrackingSystem_CourseSetup_24286_Manage_LearningPathwayDefaults
localhost_5001_TrackingSystem_CourseSetup_24286_Manage_LearningPathwayDefaults (1)
localhost_5001_TrackingSystem_CourseSetup_24286_Manage_LearningPathwayDefaults (2)


Developer checks

I have:

  • Run the formatter and made sure there are no IDE errors.
  • Written tests for the changes (controller, data services, services, view models etc) and manually tested my work with and without JavaScript. Full manual testing guidelines can be found here: https://softwiretech.atlassian.net/wiki/spaces/HEE/pages/6703648740/Testing
  • Updated my Jira ticket with information about other parts of the system that were touched as part of the MR and have to be sanity tested to ensure nothing’s broken.
  • Scanned over my own MR to ensure everything is as expected.

Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few points, mostly minor.

css-class="nhsuk-input nhsuk-input--width-10" />
</div>

<div class="nhsuk-checkboxes nhsuk-u-margin-bottom-3">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a checkboxes view component that takes in a list of view models that could be used in here unless there's a good reason I am missing. See the EditAdminFields in the Tracking System for an example.

Looking at the screenshots, we could also do with a little more space between the checkboxes and the text input above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that component has a non nullable label for the group of checkboxes so it's meant more for checkboxes that are specifically related to each other, whereas I feel like these are independent.

I've added more space between them, how does this look?
localhost_5001_TrackingSystem_CourseSetup_24286_Manage_LearningPathwayDefaults (3)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the spacing looks good here.

I see what you mean about the checkboxes view component as well. For reference, I don't believe that view components can have nullable/optional parameters, but you can put an empty string in (though in this case it would still create some HTML without any content). David is implementing a single-checkbox view component in 512, so if that ends up getting merged before this, it might be worth including it, but for now its probably fine as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, of course you could just leave the label blank :) I will use David's checkbox component once it's merged!

@livzorn livzorn force-pushed the HEEDLS-443-edit-learning-pathway-defaults branch from 5522020 to 87294f4 Compare October 4, 2021 11:25
Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things, mostly looks like a namespace got messed up.

Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

private readonly int lowerBound;
private readonly int upperBound;

public WholeNumberWithinRangeAttribute(int lowerBound, int upperBound, string errorMessage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make clear that these bounds are inclusive (i.e. 35 is within the range 4-35).

I think adding inclusive into either the attribute name or the parameter names is the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, renamed to WholeNumberWithinInclusiveRangeAttribute

public class WholeNumberWithinRangeAttributeTests
{
[Test]
public void Accepts_number_within_range()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could reduce these to a single test using [TestCaseSource] like in LinkedFieldHelperTests.cs.

It's nice to have the names of the tests to tell us what each case is for. You could keep that by passing a failure message in with the test data and giving it to NUnit for when the test fails. I believe FluentAssertions lets you do that quite easily. This article should send you in the right direction, though may not have everything you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used [TestCaseSource] to refactor the tests and I'm passing in a custom test name with each one :)

@livzorn livzorn force-pushed the HEEDLS-443-edit-learning-pathway-defaults branch from b637c81 to 825e884 Compare October 14, 2021 13:02
Copy link
Contributor

@AlexJacksonDS AlexJacksonDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things that need tidying up, mainly around the new view components.

@livzorn livzorn force-pushed the HEEDLS-443-edit-learning-pathway-defaults branch from d7e1a12 to 5faf077 Compare October 19, 2021 09:27
@livzorn livzorn merged commit b8d37bf into master Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants