Skip to content

Commit e395b53

Browse files
Merge pull request #16 from webexpress-framework/copilot/expand-backlog-tab-readonly
Add multi-template tab creation with template metadata (icon/name/description)
2 parents c5eeaf8 + 9fbe8b2 commit e395b53

11 files changed

Lines changed: 472 additions & 125 deletions

src/WebExpress.WebApp.Test/WebControl/UnitTestControlRestScrumBacklog.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,30 @@ public void RenderAttributes()
6868
// validation
6969
AssertExtensions.EqualWithPlaceholders(@"<div id=""scrum"" class=""wx-webapp-scrum-backlog"" data-rest-uri=""https://example.com/api/scrum/backlog"" data-title=""Backlog"" data-selectable=""false"" data-icon-active=""active-icon"" data-icon-planned=""planned-icon"" data-icon-backlog=""backlog-icon"" data-icon-move-to-backlog=""move-backlog-icon"" data-icon-move-to-sprint=""move-sprint-icon"" data-icon-start-sprint=""start-icon"" data-icon-complete-sprint=""complete-icon"" data-icon-edit-sprint=""edit-icon"" data-icon-delete-sprint=""delete-icon""></div>", html);
7070
}
71+
72+
/// <summary>
73+
/// Tests the readonly property emits a data-readonly attribute only when true.
74+
/// </summary>
75+
[Theory]
76+
[InlineData(false, @"<div id=""*"" class=""wx-webapp-scrum-backlog""></div>")]
77+
[InlineData(true, @"<div id=""*"" class=""wx-webapp-scrum-backlog"" data-readonly=""true""></div>")]
78+
public void Readonly(bool readOnly, string expected)
79+
{
80+
// arrange
81+
var componentHub = UnitTestControlFixture.CreateAndRegisterComponentHubMock();
82+
var application = componentHub.ApplicationManager.GetApplications(typeof(TestApplication)).FirstOrDefault();
83+
var context = UnitTestControlFixture.CreateRenderContextMock(application);
84+
var visualTree = new VisualTreeControl(componentHub, context.PageContext);
85+
var control = new ControlRestScrumBacklog()
86+
{
87+
Readonly = _ => readOnly
88+
};
89+
90+
// act
91+
var html = control.Render(context, visualTree);
92+
93+
// validation
94+
AssertExtensions.EqualWithPlaceholders(expected, html);
95+
}
7196
}
7297
}

src/WebExpress.WebApp.Test/WebControl/UnitTestControlRestTab.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,30 @@ public void RestUri(string uriString, string expected)
5959
// validation
6060
AssertExtensions.EqualWithPlaceholders(expected, html);
6161
}
62+
63+
/// <summary>
64+
/// Tests the readonly property emits a data-readonly attribute only when true.
65+
/// </summary>
66+
[Theory]
67+
[InlineData(false, @"<div id=""*"" class=""wx-webapp-tab""></div>")]
68+
[InlineData(true, @"<div id=""*"" class=""wx-webapp-tab"" data-readonly=""true""></div>")]
69+
public void Readonly(bool readOnly, string expected)
70+
{
71+
// arrange
72+
var componentHub = UnitTestControlFixture.CreateAndRegisterComponentHubMock();
73+
var application = componentHub.ApplicationManager.GetApplications(typeof(TestApplication)).FirstOrDefault();
74+
var context = UnitTestControlFixture.CreateRenderContextMock(application);
75+
var visualTree = new VisualTreeControl(componentHub, context.PageContext);
76+
var control = new ControlRestTab()
77+
{
78+
Readonly = _ => readOnly
79+
};
80+
81+
// act
82+
var html = control.Render(context, visualTree);
83+
84+
// validation
85+
AssertExtensions.EqualWithPlaceholders(expected, html);
86+
}
6287
}
63-
}
88+
}

src/WebExpress.WebApp.Test/WebControl/UnitTestControlRestTabTemplate.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,30 @@ public void Id(string id, string expected)
3333
// validation
3434
AssertExtensions.EqualWithPlaceholders(expected, html);
3535
}
36+
37+
/// <summary>
38+
/// Tests that template metadata attributes are rendered.
39+
/// </summary>
40+
[Fact]
41+
public void Metadata()
42+
{
43+
// arrange
44+
var componentHub = UnitTestControlFixture.CreateAndRegisterComponentHubMock();
45+
var application = componentHub.ApplicationManager.GetApplications(typeof(TestApplication)).FirstOrDefault();
46+
var context = UnitTestControlFixture.CreateRenderContextMock(application);
47+
var visualTree = new VisualTreeControl(componentHub, context.PageContext);
48+
var control = new ControlRestTabTemplate("template")
49+
{
50+
Icon = "fas fa-user",
51+
Name = "User Template",
52+
Description = "Template description"
53+
};
54+
55+
// act
56+
var html = control.Render(context, visualTree);
57+
58+
// validation
59+
AssertExtensions.EqualWithPlaceholders(@"<div id=""template"" class=""wx-template"" data-icon=""fas fa-user"" data-name=""User Template"" data-description=""Template description""></div>", html);
60+
}
3661
}
37-
}
62+
}

0 commit comments

Comments
 (0)