Skip to content

Commit 0f8bb5b

Browse files
gunndabadCopilot
andauthored
Add tag helper model binding integration tests (#439)
* Add tag helper model binding integration tests for text input * Add password input tests to TagHelperModelBindingTests (#440) * Initial plan * Add password input tests to TagHelperModelBindingTests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Remove PauseAsync debug statement Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add date input tests to TagHelperModelBindingTests (#441) * Initial plan * Add date input tests to TagHelperModelBindingTests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add separate test for overriden item names and IDs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> Co-authored-by: James Gunn <james@gunn.io> * Add textarea model binding integration tests (#442) * Initial plan * Add textarea tests to TagHelperModelBindingTests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add character count model binding integration tests (#443) * Initial plan * Add character count model binding integration tests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add file upload model binding integration tests (#444) * Initial plan * Add file upload model binding integration tests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add select tag helper model binding integration tests (#445) * Initial plan * Add select model binding integration tests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add checkbox model binding integration tests (#446) * Initial plan * Add checkbox model binding integration test Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> * Add test for overridden attributes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> Co-authored-by: James Gunn <james@gunn.io> * Add radios model binding integration tests (#447) * Initial plan * Add radios model binding integration tests Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
1 parent 419668c commit 0f8bb5b

32 files changed

+829
-9
lines changed

src/GovUk.Frontend.AspNetCore/TagHelpers/CheckboxesContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public override void SetErrorMessage(
149149
TemplateString? html,
150150
string tagName)
151151
{
152-
if (Fieldset is not null)
152+
if (Fieldset is not null && !_fieldsetIsOpen)
153153
{
154154
throw new InvalidOperationException($"<{tagName}> must be inside <{FieldsetTagName}>.");
155155
}

src/GovUk.Frontend.AspNetCore/TagHelpers/CheckboxesErrorMessageTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private protected override void SetErrorMessage(TagHelperContent? content, TagHe
3333
var attributes = new AttributeCollection(output.Attributes);
3434

3535
checkboxesContext.SetErrorMessage(
36-
VisuallyHiddenText,
36+
VisuallyHiddenText is not null ? new TemplateString(VisuallyHiddenText) : null,
3737
attributes,
3838
content?.ToTemplateString(),
3939
output.TagName);

src/GovUk.Frontend.AspNetCore/TagHelpers/CheckboxesTagHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ internal CheckboxesTagHelper(IComponentGenerator componentGenerator, IModelHelpe
107107
/// <inheritdoc/>
108108
public override void Init(TagHelperContext context)
109109
{
110-
context.SetContextItem(new CheckboxesContext(Name, For));
110+
var checkboxesContext = new CheckboxesContext(Name, For);
111+
context.SetContextItem(checkboxesContext);
112+
context.SetContextItem<FormGroupContext3>(checkboxesContext);
111113
}
112114

113115
/// <inheritdoc/>

src/GovUk.Frontend.AspNetCore/TagHelpers/DateInputContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public override void SetLabel(bool? isPageHeading, AttributeCollection attribute
128128

129129
public override void SetHint(AttributeCollection attributes, TemplateString? html, string tagName)
130130
{
131-
if (Fieldset is not null)
131+
if (Fieldset is not null && !_fieldsetIsOpen)
132132
{
133133
throw new InvalidOperationException($"<{tagName}> must be inside <{FieldsetTagName}>.");
134134
}
@@ -159,7 +159,7 @@ public void SetErrorMessage(
159159
TemplateString? html,
160160
string tagName)
161161
{
162-
if (Fieldset is not null)
162+
if (Fieldset is not null && !_fieldsetIsOpen)
163163
{
164164
throw new InvalidOperationException($"<{tagName}> must be inside <{FieldsetTagName}>.");
165165
}

src/GovUk.Frontend.AspNetCore/TagHelpers/DateInputErrorMessageTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private protected override void SetErrorMessage(TagHelperContent? content, TagHe
4646

4747
dateInputContext.SetErrorMessage(
4848
ErrorItems,
49-
VisuallyHiddenText,
49+
VisuallyHiddenText is not null ? new TemplateString(VisuallyHiddenText) : null,
5050
attributes,
5151
content?.ToTemplateString(),
5252
output.TagName);

src/GovUk.Frontend.AspNetCore/TagHelpers/FormGroupErrorMessageTagHelperBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private protected virtual void SetErrorMessage(TagHelperContent? content, TagHel
5252
var formGroupContext3 = context.GetContextItem<FormGroupContext3>();
5353

5454
formGroupContext3.SetErrorMessage(
55-
VisuallyHiddenText,
55+
VisuallyHiddenText is not null ? new TemplateString(VisuallyHiddenText) : null,
5656
new AttributeCollection(output.Attributes),
5757
content?.ToTemplateString(),
5858
output.TagName);

src/GovUk.Frontend.AspNetCore/TagHelpers/RadiosContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public override void SetErrorMessage(
149149
TemplateString? html,
150150
string tagName)
151151
{
152-
if (Fieldset is not null)
152+
if (Fieldset is not null && !_fieldsetIsOpen)
153153
{
154154
throw new InvalidOperationException($"<{tagName}> must be inside <{FieldsetTagName}>.");
155155
}

src/GovUk.Frontend.AspNetCore/TagHelpers/RadiosErrorMessageTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private protected override void SetErrorMessage(TagHelperContent? content, TagHe
3131
var attributes = new AttributeCollection(output.Attributes);
3232

3333
radiosContext.SetErrorMessage(
34-
VisuallyHiddenText,
34+
VisuallyHiddenText is not null ? new TemplateString(VisuallyHiddenText) : null,
3535
attributes,
3636
content?.ToTemplateString(),
3737
output.TagName);

tests/GovUk.Frontend.AspNetCore.IntegrationTests/GovUk.Frontend.AspNetCore.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
1414
<PackageReference Include="Microsoft.Playwright" Version="1.21.0" />
15+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.23" />
1516
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1617
<PrivateAssets>all</PrivateAssets>
1718
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@model GovUk.Frontend.AspNetCore.IntegrationTests.TagHelperModelBindingTests.CharacterCountTestsModel
2+
3+
<govuk-character-count for="Text" max-length="200" />

0 commit comments

Comments
 (0)