diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca2a3f3a..83592b362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix Privacy page having incorrect width - Update name of cookie consent cookie to be consistent with application name and what is displayed in the Cookie UI - Switched to using the MIS tables to the MIS_MSTR tables +- Updated the design of the source and updates panel ## [Release-18][release-18] (production-2024-12-19.4567) diff --git a/DfE.FindInformationAcademiesTrusts/Extensions/StringExtensions.cs b/DfE.FindInformationAcademiesTrusts/Extensions/StringExtensions.cs index 6b05dc8b0..9e291bfe1 100644 --- a/DfE.FindInformationAcademiesTrusts/Extensions/StringExtensions.cs +++ b/DfE.FindInformationAcademiesTrusts/Extensions/StringExtensions.cs @@ -14,12 +14,16 @@ public static partial class StringExtensions [GeneratedRegex("-+", RegexOptions.Compiled)] private static partial Regex DashesRegex(); + [GeneratedRegex(@"[^-\w]|_+", RegexOptions.Compiled)] + private static partial Regex NonDashPunctuationRegex(); + public static string Kebabify(this string text) { var transformedText = text.Trim(); transformedText = BracketedDigitsRegex().Replace(transformedText, "-"); transformedText = SpacesRegex().Replace(transformedText, "-"); + transformedText = NonDashPunctuationRegex().Replace(transformedText, ""); transformedText = DashesRegex().Replace(transformedText, "-"); transformedText = transformedText.Trim('-'); @@ -31,7 +35,7 @@ public static string Kebabify(this string text) public static string ToTitleCase(this string text) { var textInfo = CultureInfo.CurrentCulture.TextInfo; - + if (string.IsNullOrWhiteSpace(text)) return string.Empty; return textInfo.ToTitleCase(textInfo.ToLower(text)); diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/AcademiesPageModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/AcademiesPageModel.cs index 3bbf956de..75d0d0a9e 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/AcademiesPageModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/AcademiesPageModel.cs @@ -1,4 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; +using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -14,10 +15,35 @@ public abstract class AcademiesPageModel( IDateTimeProvider dateTimeProvider ) : TrustsAreaModel(dataSourceService, trustService, logger) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Academies" }; + public override TrustPageMetadata TrustPageMetadata => + base.TrustPageMetadata with { PageName = ViewConstants.AcademiesPageName }; + protected IExportService ExportService { get; } = exportService; public IDateTimeProvider DateTimeProvider { get; } = dateTimeProvider; + public override async Task OnGetAsync() + { + var pageResult = await base.OnGetAsync(); + if (pageResult is NotFoundResult) return pageResult; + + var giasDataSource = await DataSourceService.GetAsync(Source.Gias); + var eesDataSource = await DataSourceService.GetAsync(Source.ExploreEducationStatistics); + + DataSourcesPerPage.AddRange([ + new DataSourcePageListEntry(ViewConstants.AcademiesDetailsPageName, + [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.AcademiesPupilNumbersPageName, + [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.AcademiesFreeSchoolMealsPageName, [ + new DataSourceListEntry(giasDataSource, "Pupils eligible for free school meals"), + new DataSourceListEntry(eesDataSource, "Local authority average 2023/24"), + new DataSourceListEntry(eesDataSource, "National average 2023/24") + ]) + ]); + + return pageResult; + } + public virtual async Task OnGetExportAsync(string uid) { var trustSummary = await TrustService.GetTrustSummaryAsync(uid); diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/Details.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/Details.cshtml.cs index 1b9ed0c49..b04373b14 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/Details.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/Details.cshtml.cs @@ -1,5 +1,4 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Services.Academy; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; @@ -19,20 +18,19 @@ public class AcademiesDetailsModel( : AcademiesPageModel(dataSourceService, trustService, exportService, logger, dateTimeProvider) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { TabName = "Details" }; + public override TrustPageMetadata TrustPageMetadata => + base.TrustPageMetadata with { TabName = ViewConstants.AcademiesDetailsPageName }; + public AcademyDetailsServiceModel[] Academies { get; set; } = default!; public IOtherServicesLinkBuilder LinkBuilder { get; } = linkBuilder; public override async Task OnGetAsync() { var pageResult = await base.OnGetAsync(); - - if (pageResult.GetType() == typeof(NotFoundResult)) return pageResult; + if (pageResult is NotFoundResult) return pageResult; Academies = await academyService.GetAcademiesInTrustDetailsAsync(Uid); - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), ["Details"])); - return pageResult; } } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/FreeSchoolMeals.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/FreeSchoolMeals.cshtml.cs index fec5e871f..e2c60fae7 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/FreeSchoolMeals.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/FreeSchoolMeals.cshtml.cs @@ -1,5 +1,4 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Services.Academy; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; @@ -18,23 +17,17 @@ public class FreeSchoolMealsModel( : AcademiesPageModel(dataSourceService, trustService, exportService, logger, dateTimeProvider) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { TabName = "Free school meals" }; + base.TrustPageMetadata with { TabName = ViewConstants.AcademiesFreeSchoolMealsPageName }; public AcademyFreeSchoolMealsServiceModel[] Academies { get; set; } = default!; public override async Task OnGetAsync() { var pageResult = await base.OnGetAsync(); - - if (pageResult.GetType() == typeof(NotFoundResult)) return pageResult; + if (pageResult is NotFoundResult) return pageResult; Academies = await academyService.GetAcademiesInTrustFreeSchoolMealsAsync(Uid); - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), - ["Pupils eligible for free school meals"])); - - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.ExploreEducationStatistics), - ["Local authority average 2023/24", "National average 2023/24"])); return pageResult; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/PupilNumbers.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/PupilNumbers.cshtml.cs index d22e6ed47..bce2b6d38 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/PupilNumbers.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/PupilNumbers.cshtml.cs @@ -1,5 +1,4 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Services.Academy; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; @@ -17,19 +16,20 @@ public class PupilNumbersModel( IDateTimeProvider dateTimeProvider) : AcademiesPageModel(dataSourceService, trustService, exportService, logger, dateTimeProvider) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { TabName = "Pupil numbers" }; + public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with + { + TabName = ViewConstants.AcademiesPupilNumbersPageName + }; + public AcademyPupilNumbersServiceModel[] Academies { get; set; } = default!; public override async Task OnGetAsync() { var pageResult = await base.OnGetAsync(); - - if (pageResult.GetType() == typeof(NotFoundResult)) return pageResult; + if (pageResult is NotFoundResult) return pageResult; Academies = await academyService.GetAcademiesInTrustPupilNumbersAsync(Uid); - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), ["Pupil numbers"])); - return pageResult; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/_AcademiesLayout.cshtml b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/_AcademiesLayout.cshtml index 2c0974ffe..7916757bb 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/_AcademiesLayout.cshtml +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Academies/_AcademiesLayout.cshtml @@ -19,17 +19,17 @@ Contents
    -
  • +
  • Academies Details
  • -
  • +
  • Academies Pupil numbers
  • -
  • +
  • Academies Free school meals diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/ContactsAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/ContactsAreaModel.cs index b4bca8eab..56cffe07b 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/ContactsAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/ContactsAreaModel.cs @@ -14,7 +14,9 @@ ILogger logger ) : TrustsAreaModel(dataSourceService, trustService, logger) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Contacts" }; + public override TrustPageMetadata TrustPageMetadata => + base.TrustPageMetadata with { PageName = ViewConstants.ContactsPageName }; + public Person? ChairOfTrustees { get; set; } public Person? AccountingOfficer { get; set; } public Person? ChiefFinancialOfficer { get; set; } @@ -29,7 +31,8 @@ public override async Task OnGetAsync() SubNavigationLinks = [ - new TrustSubNavigationLinkModel("In DfE", "./InDfE", Uid, TrustPageMetadata.PageName!, this is InDfeModel), + new TrustSubNavigationLinkModel(ViewConstants.ContactsInDfePageName, "./InDfE", Uid, + TrustPageMetadata.PageName!, this is InDfeModel), new TrustSubNavigationLinkModel("In the trust", "./InTrust", Uid, TrustPageMetadata.PageName!, this is InTrustModel) ]; @@ -37,24 +40,31 @@ public override async Task OnGetAsync() (TrustRelationshipManager, SfsoLead, AccountingOfficer, ChairOfTrustees, ChiefFinancialOfficer) = await TrustService.GetTrustContactsAsync(Uid); - DataSources.Add(new DataSourceListEntry( - new DataSourceServiceModel(Source.FiatDb, TrustRelationshipManager?.LastModifiedAtTime, null, - TrustRelationshipManager?.LastModifiedByEmail), - new List - { ContactRole.TrustRelationshipManager.MapRoleToViewString() })); - - DataSources.Add(new DataSourceListEntry( - new DataSourceServiceModel(Source.FiatDb, SfsoLead?.LastModifiedAtTime, null, - SfsoLead?.LastModifiedByEmail), - new List - { ContactRole.SfsoLead.MapRoleToViewString() })); - - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), new List - { "Accounting officer name", "Chief financial officer name", "Chair of trustees name" })); + // Add data sources + var giasDataSource = await DataSourceService.GetAsync(Source.Gias); + var mstrDataSource = await DataSourceService.GetAsync(Source.Mstr); - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Mstr), - new List - { "Accounting officer email", "Chief financial officer email", "Chair of trustees email" })); + DataSourcesPerPage.AddRange([ + new DataSourcePageListEntry(ViewConstants.ContactsInDfePageName, [ + new DataSourceListEntry(new DataSourceServiceModel(Source.FiatDb, + TrustRelationshipManager?.LastModifiedAtTime, null, + TrustRelationshipManager?.LastModifiedByEmail), + ContactRole.TrustRelationshipManager.MapRoleToViewString()), + new DataSourceListEntry(new DataSourceServiceModel(Source.FiatDb, SfsoLead?.LastModifiedAtTime, + null, + SfsoLead?.LastModifiedByEmail), ContactRole.SfsoLead.MapRoleToViewString()) + ] + ), + new DataSourcePageListEntry("In the trust", [ + new DataSourceListEntry(giasDataSource, "Accounting officer name"), + new DataSourceListEntry(giasDataSource, "Chief financial officer name"), + new DataSourceListEntry(giasDataSource, "Chair of trustees name"), + new DataSourceListEntry(mstrDataSource, "Accounting officer email"), + new DataSourceListEntry(mstrDataSource, "Chief financial officer email"), + new DataSourceListEntry(mstrDataSource, "Chair of trustees email") + ] + ) + ]); return pageResult; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/EditContactModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/EditContactModel.cs index 0e6a9dfb5..fc445b9c4 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/EditContactModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/EditContactModel.cs @@ -20,7 +20,7 @@ public abstract class EditContactModel( public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { SubPageName = $"Edit {role.MapRoleToViewString()} details", - PageName = "Contacts" + PageName = ViewConstants.ContactsPageName }; public const string NameField = "Name"; diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/InDfe.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/InDfe.cshtml.cs index 0cc093034..d2b5f4f08 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/InDfe.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Contacts/InDfe.cshtml.cs @@ -10,5 +10,5 @@ public class InDfeModel( : ContactsAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "In DfE" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.ContactsInDfePageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/GovernanceAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/GovernanceAreaModel.cs index 6116b0879..825a86fd6 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/GovernanceAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/GovernanceAreaModel.cs @@ -12,7 +12,7 @@ public class GovernanceAreaModel( : TrustsAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { PageName = "Governance" }; + base.TrustPageMetadata with { PageName = ViewConstants.GovernancePageName }; public TrustGovernanceServiceModel TrustGovernance { get; set; } = default!; @@ -26,18 +26,35 @@ public override async Task OnGetAsync() SubNavigationLinks = [ - new TrustSubNavigationLinkModel($"Trust leadership ({TrustGovernance.CurrentTrustLeadership.Length})", + new TrustSubNavigationLinkModel( + $"{ViewConstants.GovernanceTrustLeadershipPageName} ({TrustGovernance.CurrentTrustLeadership.Length})", "./TrustLeadership", Uid, TrustPageMetadata.PageName!, this is TrustLeadershipModel), - new TrustSubNavigationLinkModel($"Trustees ({TrustGovernance.CurrentTrustees.Length})", "./Trustees", Uid, + new TrustSubNavigationLinkModel( + $"{ViewConstants.GovernanceTrusteesPageName} ({TrustGovernance.CurrentTrustees.Length})", "./Trustees", + Uid, TrustPageMetadata.PageName!, this is TrusteesModel), - new TrustSubNavigationLinkModel($"Members ({TrustGovernance.CurrentMembers.Length})", "./Members", Uid, + new TrustSubNavigationLinkModel( + $"{ViewConstants.GovernanceMembersPageName} ({TrustGovernance.CurrentMembers.Length})", "./Members", + Uid, TrustPageMetadata.PageName!, this is MembersModel), - new TrustSubNavigationLinkModel($"Historic members ({TrustGovernance.HistoricMembers.Length})", + new TrustSubNavigationLinkModel( + $"{ViewConstants.GovernanceHistoricMembersPageName} ({TrustGovernance.HistoricMembers.Length})", "./HistoricMembers", Uid, TrustPageMetadata.PageName!, this is HistoricMembersModel) ]; - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), - new List { "Governance" })); + // Add data sources + var giasDataSource = await DataSourceService.GetAsync(Source.Gias); + + DataSourcesPerPage.AddRange([ + new DataSourcePageListEntry(ViewConstants.GovernanceTrustLeadershipPageName, + [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceTrusteesPageName, + [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceMembersPageName, + [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceHistoricMembersPageName, + [new DataSourceListEntry(giasDataSource)]) + ]); return pageResult; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/HistoricMembers.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/HistoricMembers.cshtml.cs index 01995faea..6b13753ec 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/HistoricMembers.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/HistoricMembers.cshtml.cs @@ -10,5 +10,5 @@ public class HistoricMembersModel( : GovernanceAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Historic members" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceHistoricMembersPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Members.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Members.cshtml.cs index fa398f525..21d1aa1b7 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Members.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Members.cshtml.cs @@ -10,5 +10,5 @@ public class MembersModel( : GovernanceAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Members" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceMembersPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/TrustLeadership.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/TrustLeadership.cshtml.cs index d6610ec93..f172fb731 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/TrustLeadership.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/TrustLeadership.cshtml.cs @@ -10,5 +10,5 @@ public class TrustLeadershipModel( : GovernanceAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Trust leadership" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceTrustLeadershipPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Trustees.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Trustees.cshtml.cs index 12d20d3d5..1e01a0d9e 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Trustees.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Governance/Trustees.cshtml.cs @@ -10,5 +10,5 @@ public class TrusteesModel( : GovernanceAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Trustees" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceTrusteesPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/ITrustsAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/ITrustsAreaModel.cs index 6ed9ef25f..6487b4e74 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/ITrustsAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/ITrustsAreaModel.cs @@ -7,7 +7,7 @@ public interface ITrustsAreaModel { TrustSummaryServiceModel TrustSummary { get; } - List DataSources { get; } + List DataSourcesPerPage { get; } TrustPageMetadata TrustPageMetadata { get; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/CurrentRatings.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/CurrentRatings.cshtml.cs index b2656c429..d7cc09f60 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/CurrentRatings.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/CurrentRatings.cshtml.cs @@ -16,5 +16,5 @@ public class CurrentRatingsModel( academyService, exportService, dateTimeProvider, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Current ratings" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedCurrentRatingsPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/ImportantDates.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/ImportantDates.cshtml.cs index 918ca6fe4..9d75d71b0 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/ImportantDates.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/ImportantDates.cshtml.cs @@ -16,5 +16,5 @@ public class ImportantDatesModel( academyService, exportService, dateTimeProvider, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Important dates" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedImportantDatesPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/OfstedAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/OfstedAreaModel.cs index 671b9f7c7..4256a8772 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/OfstedAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/OfstedAreaModel.cs @@ -17,7 +17,9 @@ public class OfstedAreaModel( ILogger logger) : TrustsAreaModel(dataSourceService, trustService, logger) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Ofsted" }; + public override TrustPageMetadata TrustPageMetadata => + base.TrustPageMetadata with { PageName = ViewConstants.OfstedPageName }; + public AcademyOfstedServiceModel[] Academies { get; set; } = default!; private IAcademyService AcademyService { get; } = academyService; protected IExportService ExportService { get; } = exportService; @@ -33,26 +35,53 @@ public override async Task OnGetAsync() SubNavigationLinks = [ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", Uid, + TrustPageMetadata.PageName!, this is CurrentRatingsModel), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", Uid, + TrustPageMetadata.PageName!, this is PreviousRatingsModel), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", Uid, + TrustPageMetadata.PageName!, this is ImportantDatesModel), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", Uid, + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", Uid, TrustPageMetadata.PageName!, this is SafeguardingAndConcernsModel) ]; - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Gias), - ["Date joined trust"])); + // Add data sources + var giasDataSource = await DataSourceService.GetAsync(Source.Gias); + var misDataSource = await DataSourceService.GetAsync(Source.Mis); - DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.Mis), - [ - "Current Ofsted rating", - "Date of last inspection", - "Previous Ofsted rating", - "Date of previous inspection" - ])); + var dateJoinedTrust = new DataSourceListEntry(giasDataSource, "Date joined trust"); + + DataSourcesPerPage.AddRange([ + new DataSourcePageListEntry(ViewConstants.OfstedCurrentRatingsPageName, [ + dateJoinedTrust, + new DataSourceListEntry(misDataSource, "Current Ofsted rating"), + new DataSourceListEntry(misDataSource, "Date of current inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedPreviousRatingsPageName, [ + dateJoinedTrust, + new DataSourceListEntry(misDataSource, "Previous Ofsted rating"), + new DataSourceListEntry(misDataSource, "Date of previous inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedImportantDatesPageName, [ + dateJoinedTrust, + new DataSourceListEntry(misDataSource, "Date of current inspection"), + new DataSourceListEntry(misDataSource, "Date of previous inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedSafeguardingAndConcernsPageName, [ + dateJoinedTrust, + new DataSourceListEntry(misDataSource, "Effective safeguarding"), + new DataSourceListEntry(misDataSource, "Category of concern"), + new DataSourceListEntry(misDataSource, "Date of current inspection") + ] + ) + ]); return pageResult; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/PreviousRatings.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/PreviousRatings.cshtml.cs index 89019df90..89b937d60 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/PreviousRatings.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/PreviousRatings.cshtml.cs @@ -16,5 +16,5 @@ public class PreviousRatingsModel( academyService, exportService, dateTimeProvider, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Previous ratings" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedPreviousRatingsPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/SafeguardingAndConcerns.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/SafeguardingAndConcerns.cshtml.cs index b0fbc005b..edf4d96e4 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/SafeguardingAndConcerns.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Ofsted/SafeguardingAndConcerns.cshtml.cs @@ -16,5 +16,5 @@ public class SafeguardingAndConcernsModel( academyService, exportService, dateTimeProvider, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Safeguarding and concerns" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedSafeguardingAndConcernsPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/OverviewAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/OverviewAreaModel.cs index 729526576..39cc6f1a1 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/OverviewAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/OverviewAreaModel.cs @@ -11,7 +11,7 @@ public class OverviewAreaModel( ILogger logger) : TrustsAreaModel(dataSourceService, trustService, logger) { - public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Overview" }; + public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = ViewConstants.OverviewPageName }; public TrustOverviewServiceModel TrustOverview { get; set; } = default!; public override async Task OnGetAsync() @@ -21,11 +21,11 @@ public override async Task OnGetAsync() SubNavigationLinks = [ - new TrustSubNavigationLinkModel("Trust details", "./TrustDetails", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustDetailsPageName, "./TrustDetails", Uid, TrustPageMetadata.PageName!, this is TrustDetailsModel), - new TrustSubNavigationLinkModel("Trust summary", "./TrustSummary", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustSummaryPageName, "./TrustSummary", Uid, TrustPageMetadata.PageName!, this is TrustSummaryModel), - new TrustSubNavigationLinkModel("Reference numbers", "./ReferenceNumbers", Uid, TrustPageMetadata.PageName!, + new TrustSubNavigationLinkModel(ViewConstants.OverviewReferenceNumbersPageName, "./ReferenceNumbers", Uid, TrustPageMetadata.PageName!, this is ReferenceNumbersModel) ]; @@ -33,9 +33,12 @@ public override async Task OnGetAsync() TrustOverview = await TrustService.GetTrustOverviewAsync(Uid); // Add data sources - DataSources.Add(new DataSourceListEntry( - await DataSourceService.GetAsync(Source.Gias), - new List { "Trust details", "Trust summary", "Reference numbers" })); + var giasDataSource = await DataSourceService.GetAsync(Source.Gias); + DataSourcesPerPage.AddRange([ + new DataSourcePageListEntry(ViewConstants.OverviewTrustDetailsPageName, [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.OverviewTrustSummaryPageName, [new DataSourceListEntry(giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.OverviewReferenceNumbersPageName, [new DataSourceListEntry(giasDataSource)]) + ]); return Page(); } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/ReferenceNumbers.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/ReferenceNumbers.cshtml.cs index 1e755b117..9b91f0c82 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/ReferenceNumbers.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/ReferenceNumbers.cshtml.cs @@ -10,5 +10,5 @@ public class ReferenceNumbersModel( : OverviewAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Reference numbers" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OverviewReferenceNumbersPageName }; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustDetails.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustDetails.cshtml.cs index 15e61b6db..2fe052a94 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustDetails.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustDetails.cshtml.cs @@ -12,7 +12,7 @@ public class TrustDetailsModel( : OverviewAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Trust details" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OverviewTrustDetailsPageName }; public string? CompaniesHouseLink { get; set; } public string? GetInformationAboutSchoolsLink { get; set; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustSummary.cshtml.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustSummary.cshtml.cs index 69ca6064c..3be04c46d 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustSummary.cshtml.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/Overview/TrustSummary.cshtml.cs @@ -10,7 +10,7 @@ public class TrustSummaryModel( : OverviewAreaModel(dataSourceService, trustService, logger) { public override TrustPageMetadata TrustPageMetadata => - base.TrustPageMetadata with { SubPageName = "Trust summary" }; + base.TrustPageMetadata with { SubPageName = ViewConstants.OverviewTrustSummaryPageName }; public IEnumerable<(string Authority, int Total)> AcademiesInEachLocalAuthority => TrustOverview.AcademiesByLocalAuthority diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/TrustsAreaModel.cs b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/TrustsAreaModel.cs index 098b1629e..b2b61b4b9 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/TrustsAreaModel.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/TrustsAreaModel.cs @@ -1,5 +1,5 @@ -using System.Text.RegularExpressions; using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Extensions; using DfE.FindInformationAcademiesTrusts.Pages.Shared; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Academies; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; @@ -23,7 +23,7 @@ public abstract class TrustsAreaModel( [BindProperty(SupportsGet = true)] public string Uid { get; set; } = ""; public TrustSummaryServiceModel TrustSummary { get; set; } = default!; - public List DataSources { get; set; } = []; + public List DataSourcesPerPage { get; set; } = []; public virtual TrustPageMetadata TrustPageMetadata => new(TrustSummary.Name, ModelState.IsValid); public string MapDataSourceToName(DataSourceServiceModel dataSource) @@ -50,8 +50,7 @@ public string MapDataSourceToName(DataSourceServiceModel dataSource) public string MapDataSourceToTestId(DataSourceListEntry source) { - return - $@"data-source-{source.DataSource.Source.ToString().ToLowerInvariant()}-{string.Join("-", source.Fields.Select(s => Regex.Replace(s.ToLowerInvariant().Trim(), @"\s+", "-", RegexOptions.Compiled, TimeSpan.FromMilliseconds(500))))}"; + return $"data-source-{source.DataSource.Source.ToString()}-{source.DataField}".Kebabify(); } public TrustNavigationLinkModel[] NavigationLinks { get; set; } = []; @@ -76,15 +75,19 @@ private void InitializeNavigationLinks() { NavigationLinks = [ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", Uid, this is OverviewAreaModel, + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", Uid, + this is OverviewAreaModel, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", Uid, this is ContactsAreaModel, + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", Uid, + this is ContactsAreaModel, "contacts-nav"), - new TrustNavigationLinkModel($"Academies ({TrustSummary.NumberOfAcademies})", "/Trusts/Academies/Details", + new TrustNavigationLinkModel($"{ViewConstants.AcademiesPageName} ({TrustSummary.NumberOfAcademies})", + "/Trusts/Academies/Details", Uid, this is AcademiesPageModel, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", Uid, this is OfstedAreaModel, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", Uid, + this is OfstedAreaModel, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", Uid, + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", Uid, this is GovernanceAreaModel, "governance-nav") ]; } diff --git a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/_SourceList.cshtml b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/_SourceList.cshtml index 852169cab..7a5e924ac 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/Trusts/_SourceList.cshtml +++ b/DfE.FindInformationAcademiesTrusts/Pages/Trusts/_SourceList.cshtml @@ -1,34 +1,31 @@ -@using DfE.FindInformationAcademiesTrusts.Data.Enums -@model ITrustsAreaModel +@model ITrustsAreaModel
    - Source and updates + Where this information came from -
      - @foreach (var source in Model.DataSources) +
      + @foreach (var pageSource in Model.DataSourcesPerPage) { -
    • - @string.Join(", ", source.Fields) - - Last updated: @(source.LastUpdatedText) - - @if (source.DataSource.NextUpdated is not null) +

      + @pageSource.PageName +

      +
        + @foreach (var source in pageSource.DataSources) { - Next scheduled update: @source.DataSource.NextUpdated +
      • + @if (source.DataSource.UpdatedBy is not null) + { + @source.DataField was updated by @source.UpdatedByText on @source.LastUpdatedText + } + else + { + @source.DataField taken from @Model.MapDataSourceToName(source.DataSource) on @source.LastUpdatedText + } +
      • } - - @if (source.DataSource.UpdatedBy is not null) - { - Updated by: @source.UpdatedByText - } - - @if (source.DataSource.Source != Source.FiatDb) - { - Data taken from: @Model.MapDataSourceToName(source.DataSource) - } - +
      } -
    +
    diff --git a/DfE.FindInformationAcademiesTrusts/Pages/ViewConstants.cs b/DfE.FindInformationAcademiesTrusts/Pages/ViewConstants.cs index 0704a3b12..bb8931307 100644 --- a/DfE.FindInformationAcademiesTrusts/Pages/ViewConstants.cs +++ b/DfE.FindInformationAcademiesTrusts/Pages/ViewConstants.cs @@ -51,4 +51,30 @@ public static class ViewConstants "Process guidance and tools for making trust-related project decisions.", "https://educationgovuk.sharepoint.com/sites/lvewp00299/SitePages/RG%20high%20quality%20trust%20framework.aspx") ]; + + public const string OverviewPageName = "Overview"; + public const string OverviewTrustDetailsPageName = "Trust details"; + public const string OverviewTrustSummaryPageName = "Trust summary"; + public const string OverviewReferenceNumbersPageName = "Reference numbers"; + + public const string ContactsPageName = "Contacts"; + public const string ContactsInDfePageName = "In DfE"; + public const string ContactsInTrustPageName = "In the trust"; + + public const string AcademiesPageName = "Academies"; + public const string AcademiesDetailsPageName = "Details"; + public const string AcademiesPupilNumbersPageName = "Pupil numbers"; + public const string AcademiesFreeSchoolMealsPageName = "Free school meals"; + + public const string OfstedPageName = "Ofsted"; + public const string OfstedCurrentRatingsPageName = "Current ratings"; + public const string OfstedPreviousRatingsPageName = "Previous ratings"; + public const string OfstedImportantDatesPageName = "Important dates"; + public const string OfstedSafeguardingAndConcernsPageName = "Safeguarding and concerns"; + + public const string GovernancePageName = "Governance"; + public const string GovernanceTrustLeadershipPageName = "Trust leadership"; + public const string GovernanceTrusteesPageName = "Trustees"; + public const string GovernanceMembersPageName = "Members"; + public const string GovernanceHistoricMembersPageName = "Historic members"; } diff --git a/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourceListEntry.cs b/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourceListEntry.cs index 314b8eaab..7feac9964 100644 --- a/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourceListEntry.cs +++ b/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourceListEntry.cs @@ -2,7 +2,7 @@ namespace DfE.FindInformationAcademiesTrusts.Services.DataSource; -public record DataSourceListEntry(DataSourceServiceModel DataSource, IEnumerable Fields) +public record DataSourceListEntry(DataSourceServiceModel DataSource, string DataField = "All information") { public string LastUpdatedText => DataSource.LastUpdated is null ? "Unknown" diff --git a/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourcePageListEntry.cs b/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourcePageListEntry.cs new file mode 100644 index 000000000..78ce8b3c7 --- /dev/null +++ b/DfE.FindInformationAcademiesTrusts/Services/DataSource/DataSourcePageListEntry.cs @@ -0,0 +1,3 @@ +namespace DfE.FindInformationAcademiesTrusts.Services.DataSource; + +public record DataSourcePageListEntry(string PageName, List DataSources); diff --git a/DfE.FindInformationAcademiesTrusts/Services/Export/ExportService.cs b/DfE.FindInformationAcademiesTrusts/Services/Export/ExportService.cs index db9ee63af..ee886fc13 100644 --- a/DfE.FindInformationAcademiesTrusts/Services/Export/ExportService.cs +++ b/DfE.FindInformationAcademiesTrusts/Services/Export/ExportService.cs @@ -211,7 +211,7 @@ private static byte[] GenerateOfstedSpreadsheet( AcademyOfsted[] academiesOfstedRatings) { using var workbook = new XLWorkbook(); - var worksheet = workbook.Worksheets.Add("Ofsted"); + var worksheet = workbook.Worksheets.Add(ViewConstants.OfstedPageName); WriteTrustInformation(worksheet, trustSummary); WriteHeaders(worksheet, headers); diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/data-sources.cy.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/data-sources.cy.ts new file mode 100644 index 000000000..3d4e86892 --- /dev/null +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/data-sources.cy.ts @@ -0,0 +1,54 @@ +import commonPage from "../../pages/commonPage"; +import navigation from "../../pages/navigation"; +import { TestDataStore } from "../../support/test-data-store"; + +describe("Testing the data sources component", () => { + + beforeEach(() => { + cy.login(); + }); + + describe("Content pages", () => { + ['/', '/search', '/accessibility', '/cookies', '/privacy', '/error'].forEach((url) => { + it(`Should not have a data sources component on ${url}`, () => { + cy.visit(url); // don't turn off fail on status code because we want the test to fail if visit returns 404 as that means our test urls are incorrect + + commonPage + .checkPageContentHasLoaded() // We need to make sure the page content has finished loading before we check that something is *not* on the page + .checkDoesNotHaveDataSourcesComponent(); + }); + }); + + it(`Should not have a data sources component on /notfound`, () => { + cy.visit('/notfound', { failOnStatusCode: false }); + + commonPage + .checkPageContentHasLoaded() // We need to make sure the page content has finished loading before we check that something is *not* on the page + .checkDoesNotHaveDataSourcesComponent(); + }); + }); + + describe("Trust pages", () => { + TestDataStore.GetTrustSubpagesForUid(5712).forEach(({ pageName, subpages }) => { + const subpageNames = subpages.map(s => s.subpageName); + + describe(pageName, () => { + + subpages.forEach(({ subpageName, url }) => { + it(`Should have a data sources component on ${pageName} > ${subpageName}`, () => { + // Go to the given subpage + cy.visit(url); + + // Check that the given subpage list is up to date (so we don't miss any if new pages are added) + navigation.checkSubpageNavMatches(subpages); + + // Check that the data sources component has a subheading for each subnav + commonPage + .checkHasDataSourcesComponent() + .checkDataSourcesComponentHasSubpageHeadings(subpageNames); + }); + }); + }); + }); + }); +}); diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/academies.cy.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/academies.cy.ts index abc08a72e..91b3056cd 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/academies.cy.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/academies.cy.ts @@ -183,7 +183,7 @@ describe("Testing the components of the Academies page", () => { describe("Testing a trust that has no academies within it to ensure the issue of a 500 page appearing does not happen", () => { beforeEach(() => { cy.login(); - commonPage.interceptAndVerfiyNo500Errors(); + commonPage.interceptAndVerifyNo500Errors(); }); ['/trusts/academies/details?uid=17728', '/trusts/academies/pupil-numbers?uid=17728', '/trusts/academies/free-school-meals?uid=17728'].forEach((url) => { diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/contacts-page.cy.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/contacts-page.cy.ts index 11d09c7b6..e372d2cc0 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/contacts-page.cy.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/contacts-page.cy.ts @@ -264,7 +264,7 @@ describe("Testing the components of the Trust contacts page", () => { describe("Testing a trust that has no contacts within it to ensure the issue of a 500 page appearing does not happen", () => { beforeEach(() => { cy.login(); - commonPage.interceptAndVerfiyNo500Errors(); + commonPage.interceptAndVerifyNo500Errors(); }); ['/trusts/contacts/in-dfe?uid=17728', '/trusts/contacts/in-the-trust?uid=17728'].forEach((url) => { diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/ofsted-page.cy.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/ofsted-page.cy.ts index d2bdbe957..607ef1f6d 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/ofsted-page.cy.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/trusts/ofsted-page.cy.ts @@ -273,7 +273,7 @@ describe("Testing the Ofsted page and its subpages ", () => { describe("Testing a trust that has no ofsted data within it to ensure the issue of a 500 page appearing does not happen", () => { beforeEach(() => { cy.login(); - commonPage.interceptAndVerfiyNo500Errors(); + commonPage.interceptAndVerifyNo500Errors(); }); ['/trusts/ofsted/current-ratings?uid=17728', '/trusts/ofsted/previous-ratings?uid=17728', '/trusts/ofsted/important-dates?uid=17728', '/trusts/ofsted/safeguarding-and-concerns?uid=17728'].forEach((url) => { diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/commonPage.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/commonPage.ts index 63c8b3432..5b80fdecc 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/commonPage.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/commonPage.ts @@ -1,5 +1,6 @@ -class CommonPage { +import navigation from "./navigation"; +class CommonPage { elements = { successPopup: { section: () => cy.get('.govuk-notification-banner'), @@ -12,6 +13,13 @@ class CommonPage { }, trustName: () => cy.get('[data-testid="trust-name-heading"]'), + + elementPresentOnEveryPage: () => navigation.elements.accessibilityFooterButton().as('elementPresentOnEveryPage'), + + dataSources: { + section: () => cy.get('[data-testid="data-source-and-updates"]'), + subpageHeaders: () => this.elements.dataSources.section().find('.govuk-heading-s') + } }; /** @@ -57,13 +65,44 @@ class CommonPage { return this; } - public checkPageLoad(): void { - cy.window().then((win) => { - expect(win.document.readyState).to.eq('complete'); + public checkDoesNotHaveDataSourcesComponent(): this { + const { dataSources } = this.elements; + dataSources.section().should('not.exist'); + return this; + } + + public checkHasDataSourcesComponent(): this { + const { dataSources } = this.elements; + dataSources.section().should('be.visible'); + return this; + } + + public checkDataSourcesComponentHasSubpageHeadings(expectedSubpageHeadings: string[]): this { + const { dataSources } = this.elements; + + //Expand the details element so we can see its contents on any screenshots if this fails + dataSources.section().expandDetailsElement(); + + dataSources.subpageHeaders().should(($dataSourceHeadingElements) => { + const actualDataSourceHeadings = $dataSourceHeadingElements + .map((_, headingElement) => Cypress.$(headingElement).text().trim()) + .get(); + expect(actualDataSourceHeadings).to.deep.eq(expectedSubpageHeadings); }); + + return this; + } + + public checkPageContentHasLoaded(): this { + const { elementPresentOnEveryPage } = this.elements; + + elementPresentOnEveryPage().scrollIntoView(); + elementPresentOnEveryPage().should('be.visible'); + + return this; } - public interceptAndVerfiyNo500Errors(): void { + public interceptAndVerifyNo500Errors(): void { cy.intercept('**', (req) => { req.on('response', (res) => { expect(res.statusCode).to.not.eq(500); diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/navigation.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/navigation.ts index 0f1077dab..f3ac78b41 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/navigation.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/navigation.ts @@ -13,6 +13,8 @@ class Navigation { overviewServiceNavButton: () => cy.get('[data-testid="overview-nav"]'), }, + currentPageSubnavLinks: () => cy.get('.moj-sub-navigation__link'), + acadmiesSubNav: { ofstedAcadmiesTrustButton: () => cy.get('[data-testid="ofsted-nav"]'), pupilNumbersAcadmiesTrustButton: () => cy.get('#academies-pupil-numbers-link'), @@ -27,6 +29,21 @@ class Navigation { } }; + public checkSubpageNavMatches(expectedSubpages: { subpageName: string, url: string; }[]): this { + //Get the actual subpage nav items currently on the screen + this.elements.currentPageSubnavLinks().should(($subpageNavElements) => { + //Get the name and url out of the subpageNavElement jquery objects + const actualSubpages = $subpageNavElements.map((_, subpageNavElement) => ({ + subpageName: Cypress.$(subpageNavElement).contents().last().text().replace(/\(\d+\)/, '').trim(), // Get the visible subpage name (not the hidden a11y name) without any bracketed numbers + url: Cypress.$(subpageNavElement).attr('href') + })).get(); + + //Check that the actual subpages currently on the screen are the ones we are expecting to see + expect(actualSubpages).to.deep.equal(expectedSubpages); + }); + return this; + } + public checkBrowserPageTitleContains(pageTitle: string): this { cy.title().should('contain', pageTitle); return this; diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/trusts/contactsPage.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/trusts/contactsPage.ts index d08304e50..1cf2e2975 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/trusts/contactsPage.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/trusts/contactsPage.ts @@ -47,8 +47,8 @@ class ContactsPage { datasource: { section: () => cy.get('[data-testid="data-source-and-updates"]'), - trmLatestUpdatedBy: () => cy.get('[data-testid="data-source-fiatdb-trust-relationship-manager"] > :nth-child(3)'), - sfsoOLatestUpdatedBy: () => cy.get('[data-testid="data-source-fiatdb-sfso-(schools-financial-support-and-oversight)-lead"] > :nth-child(3)') + trmLatestUpdatedBy: () => cy.get('[data-testid="data-source-fiatdb-trust-relationship-manager"]'), + sfsoLatestUpdatedBy: () => cy.get('[data-testid="data-source-fiatdb-sfso-lead"]') }, subNav: { @@ -161,17 +161,17 @@ class ContactsPage { public checkTrustRelationshipManagerDatasourceLastUpdatedByUser(expectedUser: string): this { const { datasource } = this.elements; - datasource.section().click(); - datasource.section().should('be.visible'); - datasource.trmLatestUpdatedBy().should('contain.text', expectedUser); + datasource.section().expandDetailsElement(); + datasource.section().should('have.attr', 'open'); + datasource.trmLatestUpdatedBy().should('contain.text', 'Trust relationship manager was updated by ' + expectedUser + ' on '); return this; } public checkSfsoLeadDatasourceLastUpdatedByUser(expectedUser: string): this { const { datasource } = this.elements; - datasource.section().click(); - datasource.section().should('be.visible'); - datasource.sfsoOLatestUpdatedBy().should('contain.text', expectedUser); + datasource.section().expandDetailsElement(); + datasource.section().should('have.attr', 'open'); + datasource.sfsoLatestUpdatedBy().should('contain.text', 'SFSO (Schools financial support and oversight) lead was updated by ' + expectedUser + ' on '); return this; } diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/commands.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/commands.ts index aedeef784..fda39df49 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/commands.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/commands.ts @@ -9,4 +9,24 @@ Cypress.Commands.add("login", (params) => { new AuthenticationInterceptor().register(params); cy.visit("/"); -}); +}); + +Cypress.Commands.add("expandDetailsElement", { prevSubject: 'element', }, (subject) => { + + // Open the details element (disable logging so we can add a nice log below) + cy.wrap(subject, { log: false }) + .find('summary', { log: false }) + .click({ log: false }); + + //Add a nice log + Cypress.log({ + name: 'expandDetailsElement', + displayName: 'open', + message: `${subject.selector}`, + consoleProps: () => { // print to dev tools console on click + return { + AppliedTo: subject + }; + }, + }); +}); diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/e2e.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/e2e.ts index 5cd13344b..e19cbfb07 100644 --- a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/e2e.ts +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/e2e.ts @@ -1,11 +1,18 @@ /* eslint-disable @typescript-eslint/no-namespace */ //required to enable custom Cypress commands typescript support import { AuthenticationInterceptorParams } from '../auth/authenticationInterceptor'; -import './commands' +import './commands'; declare global { namespace Cypress { interface Chainable { login(params?: AuthenticationInterceptorParams): Chainable; + + /** + * Expands a details element + * + * As of Jan 2025, Cypress is unable to expand a HTML details element using a click. This is a workaround. + */ + expandDetailsElement(): Cypress.Chainable>; } } } diff --git a/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/test-data-store.ts b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/test-data-store.ts new file mode 100644 index 000000000..cb8af51b3 --- /dev/null +++ b/tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/support/test-data-store.ts @@ -0,0 +1,38 @@ +export class TestDataStore { + public static readonly GetTrustSubpagesForUid = (uid: number) => + [ + { + pageName: "Overview", + subpages: [ + { subpageName: "Trust details", url: `/trusts/overview/trust-details?uid=${uid}` }, + { subpageName: "Trust summary", url: `/trusts/overview/trust-summary?uid=${uid}` }, + { subpageName: "Reference numbers", url: `/trusts/overview/reference-numbers?uid=${uid}` }, + ] + }, + { + pageName: "Contacts", + subpages: [ + { subpageName: "In DfE", url: `/trusts/contacts/in-dfe?uid=${uid}` }, + { subpageName: "In the trust", url: `/trusts/contacts/in-the-trust?uid=${uid}` }, + ] + }, + { + pageName: "Ofsted", + subpages: [ + { subpageName: "Current ratings", url: `/trusts/ofsted/current-ratings?uid=${uid}` }, + { subpageName: "Previous ratings", url: `/trusts/ofsted/previous-ratings?uid=${uid}` }, + { subpageName: "Important dates", url: `/trusts/ofsted/important-dates?uid=${uid}` }, + { subpageName: "Safeguarding and concerns", url: `/trusts/ofsted/safeguarding-and-concerns?uid=${uid}` } + ] + }, + { + pageName: "Governance", + subpages: [ + { subpageName: `Trust leadership`, url: `/trusts/governance/trust-leadership?uid=${uid}` }, + { subpageName: "Trustees", url: `/trusts/governance/trustees?uid=${uid}` }, + { subpageName: "Members", url: `/trusts/governance/members?uid=${uid}` }, + { subpageName: "Historic members", url: `/trusts/governance/historic-members?uid=${uid}` } + ] + }, + ]; +} diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Extensions/StringExtensionsTest.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Extensions/StringExtensionsTest.cs index 481929571..b2b83c137 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Extensions/StringExtensionsTest.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Extensions/StringExtensionsTest.cs @@ -63,6 +63,19 @@ public void Kebabify_should_not_start_or_end_with_dash(string linkText, string e linkText.Kebabify().Should().Be(expected); } + [Theory] + [InlineData("hello, world!", "hello-world")] + [InlineData("hel-lo, world!", "hel-lo-world")] + [InlineData("goodbye: cruel; world...", "goodbye-cruel-world")] + [InlineData("@hello#$%^&*()_+= world", "hello-world")] + [InlineData("he\tllo!\nworld?", "helloworld")] + [InlineData("\"quoted\" 'text'", "quoted-text")] + [InlineData(" hello, world! ", "hello-world")] + public void Kebabify_should_remove_all_punctuation_characters(string input, string expected) + { + input.Kebabify().Should().Be(expected); + } + [Theory] [InlineData("test", "Test")] [InlineData("", "")] diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/AcademiesPageModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/AcademiesPageModelTests.cs index fdd4e6d60..5f4fd87c7 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/AcademiesPageModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/AcademiesPageModelTests.cs @@ -1,4 +1,6 @@ using DfE.FindInformationAcademiesTrusts.Data; +using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Academies; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; @@ -17,6 +19,13 @@ public class AcademiesPageModelTests private readonly Mock> _mockLogger = new(); private readonly AcademiesPageModel _sut; + private readonly DataSourceServiceModel _giasDataSource = + new(Source.Gias, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + + private readonly DataSourceServiceModel _eesDataSource = new(Source.ExploreEducationStatistics, + new DateTime(2025, 1, 1), + UpdateFrequency.Annually); + private class AcademiesPageModelImpl( IDataSourceService dataSourceService, ITrustService trustService, @@ -27,6 +36,8 @@ private class AcademiesPageModelImpl( public AcademiesPageModelTests() { + _mockDataSourceService.Setup(s => s.GetAsync(Source.Gias)).ReturnsAsync(_giasDataSource); + _mockDataSourceService.Setup(s => s.GetAsync(Source.ExploreEducationStatistics)).ReturnsAsync(_eesDataSource); _sut = new AcademiesPageModelImpl(_mockDataSourceService.Object, _mockTrustService.Object, _mockExportService.Object, _mockLogger.Object, _mockDateTimeProvider.Object); } @@ -109,7 +120,30 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.PageName.Should().Be("Academies"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.AcademiesPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } + + [Fact] + public async Task OnGetAsync_sets_correct_data_source_list() + { + TrustSummaryServiceModel fakeTrust = new("1234", "My Trust", "Multi-academy trust", 3); + _mockTrustService.Setup(t => t.GetTrustSummaryAsync(fakeTrust.Uid)).ReturnsAsync(fakeTrust); + _sut.Uid = fakeTrust.Uid; + + _ = await _sut.OnGetAsync(); + _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); + _mockDataSourceService.Verify(e => e.GetAsync(Source.ExploreEducationStatistics), Times.Once); + _sut.DataSourcesPerPage.Should().BeEquivalentTo([ + new DataSourcePageListEntry(ViewConstants.AcademiesDetailsPageName, + [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.AcademiesPupilNumbersPageName, + [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.AcademiesFreeSchoolMealsPageName, [ + new DataSourceListEntry(_giasDataSource, "Pupils eligible for free school meals"), + new DataSourceListEntry(_eesDataSource, "Local authority average 2023/24"), + new DataSourceListEntry(_eesDataSource, "National average 2023/24") + ]) + ]); + } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/DetailsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/DetailsModelTests.cs index 636f4db11..96630a429 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/DetailsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/DetailsModelTests.cs @@ -1,5 +1,4 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Academies; @@ -66,26 +65,21 @@ public async Task OnGetAsync_sets_academies_from_academyService() _sut.Academies.Should().BeEquivalentTo(academies); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - _ = await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Details" }); - } - [Fact] public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", true, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -102,7 +96,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.TabName.Should().Be("Details"); + _sut.TrustPageMetadata.TabName.Should().Be(ViewConstants.AcademiesDetailsPageName); _sut.TrustPageMetadata.PageName.Should().Be("Academies"); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/FreeSchoolMealsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/FreeSchoolMealsModelTests.cs index 19963ace4..f7b8529c7 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/FreeSchoolMealsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/FreeSchoolMealsModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Academies; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -44,22 +44,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(d => d.GetAsync(Source.ExploreEducationStatistics), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new[] - { - "Pupils eligible for free school meals" - }); - _sut.DataSources[1].Fields.Should().Contain(new[] - { - "Local authority average 2023/24", "National average 2023/24" - }); - } - [Fact] public async Task OnGetAsync_sets_academies_from_academyService() { @@ -82,12 +66,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (1)", "/Trusts/Academies/Details", "1234", true, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -104,7 +92,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.TabName.Should().Be("Free school meals"); + _sut.TrustPageMetadata.TabName.Should().Be(ViewConstants.AcademiesFreeSchoolMealsPageName); _sut.TrustPageMetadata.PageName.Should().Be("Academies"); _sut.TrustPageMetadata.TrustName.Should().Be("Test Trust"); } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/PupilNumbersModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/PupilNumbersModelTests.cs index cafa70749..ba92eae35 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/PupilNumbersModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Academies/PupilNumbersModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Academies; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -71,12 +71,10 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() } [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() + public async Task OnGetAsync_returns_RegularPageResult_if_Trust_is_found() { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Pupil numbers" }); + var result = await _sut.OnGetAsync(); + result.Should().NotBeOfType(); } [Fact] @@ -84,12 +82,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (1)", "/Trusts/Academies/Details", "1234", true, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -106,7 +108,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.TabName.Should().Be("Pupil numbers"); + _sut.TrustPageMetadata.TabName.Should().Be(ViewConstants.AcademiesPupilNumbersPageName); _sut.TrustPageMetadata.PageName.Should().Be("Academies"); _sut.TrustPageMetadata.TrustName.Should().Be("Test Trust"); } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/ContactsAreaModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/ContactsAreaModelTests.cs index 761adee13..c30f7bf25 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/ContactsAreaModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/ContactsAreaModelTests.cs @@ -1,7 +1,9 @@ using DfE.FindInformationAcademiesTrusts.Data; using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; +using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; using Microsoft.AspNetCore.Mvc; @@ -27,6 +29,12 @@ public class ContactsAreaModelTests private readonly InternalContact _trustRelationshipManager = new("Trust Relationship Manager", "trm@test.com", DateTime.Today, "test@email.com"); + private readonly DataSourceServiceModel _giasDataSource = + new(Source.Gias, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + + private readonly DataSourceServiceModel _mstrDataSource = new(Source.Mstr, + new DateTime(2025, 1, 1), UpdateFrequency.Monthly); + public ContactsAreaModelTests() { _mockTrustService.Setup(tp => tp.GetTrustContactsAsync(TestUid)).ReturnsAsync( @@ -34,6 +42,8 @@ public ContactsAreaModelTests() _chiefFinancialOfficer)); _mockTrustService.Setup(t => t.GetTrustSummaryAsync(_fakeTrust.Uid)) .ReturnsAsync(_fakeTrust); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Gias)).ReturnsAsync(_giasDataSource); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Mstr)).ReturnsAsync(_mstrDataSource); _sut = new ContactsAreaModel(_mockDataSourceService.Object, _mockTrustService.Object, new MockLogger().Object) @@ -126,15 +136,27 @@ public async Task OnGetAsync_sets_correct_data_source_list() await _sut.OnGetAsync(); _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); _mockDataSourceService.Verify(e => e.GetAsync(Source.Mstr), Times.Once); - _sut.DataSources.Count.Should().Be(4); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust relationship manager" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { "SFSO (Schools financial support and oversight) lead" }); - _sut.DataSources[2].Fields.Should().Contain(new List - { "Accounting officer name", "Chief financial officer name", "Chair of trustees name" }); - _sut.DataSources[3].Fields.Should().Contain(new List - { "Accounting officer email", "Chief financial officer email", "Chair of trustees email" }); + _sut.DataSourcesPerPage.Count.Should().Be(2); + _sut.DataSourcesPerPage.Should().BeEquivalentTo([ + new DataSourcePageListEntry(ViewConstants.ContactsInDfePageName, [ + new DataSourceListEntry(new DataSourceServiceModel(Source.FiatDb, + _trustRelationshipManager.LastModifiedAtTime, null, + _trustRelationshipManager.LastModifiedByEmail), "Trust relationship manager"), + new DataSourceListEntry(new DataSourceServiceModel(Source.FiatDb, _sfsoLead.LastModifiedAtTime, + null, + _sfsoLead.LastModifiedByEmail), "SFSO (Schools financial support and oversight) lead") + ] + ), + new DataSourcePageListEntry(ViewConstants.ContactsInTrustPageName, [ + new DataSourceListEntry(_giasDataSource, "Accounting officer name"), + new DataSourceListEntry(_giasDataSource, "Chief financial officer name"), + new DataSourceListEntry(_giasDataSource, "Chair of trustees name"), + new DataSourceListEntry(_mstrDataSource, "Accounting officer email"), + new DataSourceListEntry(_mstrDataSource, "Chief financial officer email"), + new DataSourceListEntry(_mstrDataSource, "Chair of trustees email") + ] + ) + ]); } [Fact] @@ -142,12 +164,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", TestUid, false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", TestUid, true, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", TestUid, + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", TestUid, true, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", TestUid, false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", TestUid, false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + TestUid, false, "governance-nav") ]); } @@ -157,8 +183,10 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("In DfE", "./InDfE", TestUid, "Contacts", false), - new TrustSubNavigationLinkModel("In the trust", "./InTrust", TestUid, "Contacts", false) + new TrustSubNavigationLinkModel(ViewConstants.ContactsInDfePageName, "./InDfE", TestUid, + ViewConstants.ContactsPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.ContactsInTrustPageName, "./InTrust", TestUid, + ViewConstants.ContactsPageName, false) ]); } @@ -167,7 +195,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditSfsoLeadModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditSfsoLeadModelTests.cs index 7913900a6..4a8331756 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditSfsoLeadModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditSfsoLeadModelTests.cs @@ -1,5 +1,6 @@ using DfE.FindInformationAcademiesTrusts.Data; using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; @@ -91,7 +92,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() _sut.TrustPageMetadata.SubPageName.Should() .Be("Edit SFSO (Schools financial support and oversight) lead details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } @@ -107,7 +108,7 @@ public async Task OnPostAsync_should_configure_TrustPageMetadata_when_model_is_v _sut.TrustPageMetadata.SubPageName.Should() .Be("Edit SFSO (Schools financial support and oversight) lead details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); _sut.TrustPageMetadata.ModelStateIsValid.Should().BeTrue(); } @@ -120,7 +121,7 @@ public async Task OnPostAsync_should_configure_TrustPageMetadata_when_model_is_n _sut.TrustPageMetadata.SubPageName.Should() .Be("Edit SFSO (Schools financial support and oversight) lead details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); _sut.TrustPageMetadata.ModelStateIsValid.Should().BeFalse(); } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditTrustRelationshipManagerModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditTrustRelationshipManagerModelTests.cs index 9fd141115..9afb685ee 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditTrustRelationshipManagerModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/EditTrustRelationshipManagerModelTests.cs @@ -1,5 +1,6 @@ using DfE.FindInformationAcademiesTrusts.Data; using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; @@ -92,7 +93,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() _ = await _sut.OnGetAsync(); _sut.TrustPageMetadata.SubPageName.Should().Be("Edit Trust relationship manager details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } @@ -107,7 +108,7 @@ public async Task OnPostAsync_should_configure_TrustPageMetadata_when_model_is_v _ = await _sut.OnPostAsync(); _sut.TrustPageMetadata.SubPageName.Should().Be("Edit Trust relationship manager details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); _sut.TrustPageMetadata.ModelStateIsValid.Should().BeTrue(); } @@ -119,7 +120,7 @@ public async Task OnPostAsync_should_configure_TrustPageMetadata_when_model_is_n _ = await _sut.OnPostAsync(); _sut.TrustPageMetadata.SubPageName.Should().Be("Edit Trust relationship manager details"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); _sut.TrustPageMetadata.ModelStateIsValid.Should().BeFalse(); } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InDfeModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InDfeModelTests.cs index b1e3e5c63..98cf8bb6a 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InDfeModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InDfeModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -119,34 +119,21 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mstr), Times.Once); - _sut.DataSources.Count.Should().Be(4); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust relationship manager" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { "SFSO (Schools financial support and oversight) lead" }); - _sut.DataSources[2].Fields.Should().Contain(new List - { "Accounting officer name", "Chief financial officer name", "Chair of trustees name" }); - _sut.DataSources[3].Fields.Should().Contain(new List - { "Accounting officer email", "Chief financial officer email", "Chair of trustees email" }); - } - [Fact] public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", true, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", true, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -156,8 +143,10 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("In DfE", "./InDfE", "1234", "Contacts", true), - new TrustSubNavigationLinkModel("In the trust", "./InTrust", "1234", "Contacts", false) + new TrustSubNavigationLinkModel(ViewConstants.ContactsInDfePageName, "./InDfE", "1234", + ViewConstants.ContactsPageName, true), + new TrustSubNavigationLinkModel(ViewConstants.ContactsInTrustPageName, "./InTrust", "1234", + ViewConstants.ContactsPageName, false) ]); } @@ -166,8 +155,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("In DfE"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.ContactsInDfePageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InTrustModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InTrustModelTests.cs index 5a8618f46..8a9e3dc2b 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InTrustModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Contacts/InTrustModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Contacts; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -119,34 +119,21 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mstr), Times.Once); - _sut.DataSources.Count.Should().Be(4); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust relationship manager" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { "SFSO (Schools financial support and oversight) lead" }); - _sut.DataSources[2].Fields.Should().Contain(new List - { "Accounting officer name", "Chief financial officer name", "Chair of trustees name" }); - _sut.DataSources[3].Fields.Should().Contain(new List - { "Accounting officer email", "Chief financial officer email", "Chair of trustees email" }); - } - [Fact] public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", true, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", true, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -156,8 +143,10 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("In DfE", "./InDfE", "1234", "Contacts", false), - new TrustSubNavigationLinkModel("In the trust", "./InTrust", "1234", "Contacts", true) + new TrustSubNavigationLinkModel(ViewConstants.ContactsInDfePageName, "./InDfE", "1234", + ViewConstants.ContactsPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.ContactsInTrustPageName, "./InTrust", "1234", + ViewConstants.ContactsPageName, true) ]); } @@ -166,8 +155,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("In the trust"); - _sut.TrustPageMetadata.PageName.Should().Be("Contacts"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.ContactsInTrustPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.ContactsPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/GovernanceAreaModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/GovernanceAreaModelTests.cs index a738b6f39..3106b2fd2 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/GovernanceAreaModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/GovernanceAreaModelTests.cs @@ -1,7 +1,9 @@ using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Data.Repositories.Trust; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Governance; +using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; using Microsoft.AspNetCore.Mvc; @@ -65,6 +67,9 @@ public class GovernanceAreaModelTests private readonly MockDataSourceService _mockDataSourceService = new(); private readonly Mock _mockTrustService = new(); + private readonly DataSourceServiceModel _giasDataSource = + new(Source.Gias, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + private static readonly string TestUid = "1234"; public GovernanceAreaModelTests() @@ -73,6 +78,7 @@ public GovernanceAreaModelTests() .ReturnsAsync(DummyTrustGovernanceServiceModel); _mockTrustService.Setup(t => t.GetTrustSummaryAsync(TestUid)) .ReturnsAsync(new TrustSummaryServiceModel(TestUid, "My trust", "", 0)); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Gias)).ReturnsAsync(_giasDataSource); _sut = new GovernanceAreaModel(_mockDataSourceService.Object, _mockTrustService.Object, new MockLogger().Object) @@ -98,8 +104,17 @@ public async Task OnGetAsync_sets_correct_data_source_list() { await _sut.OnGetAsync(); _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Governance" }); + _sut.DataSourcesPerPage.Count.Should().Be(4); + _sut.DataSourcesPerPage.Should().BeEquivalentTo([ + new DataSourcePageListEntry(ViewConstants.GovernanceTrustLeadershipPageName, + [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceTrusteesPageName, + [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceMembersPageName, + [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.GovernanceHistoricMembersPageName, + [new DataSourceListEntry(_giasDataSource)]) + ]); } [Fact] @@ -115,12 +130,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (0)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", true, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", true, "governance-nav") ]); } @@ -130,10 +149,14 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", "Governance", false) + new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", + ViewConstants.GovernancePageName, false), + new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", + ViewConstants.GovernancePageName, false) ]); } @@ -142,7 +165,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.PageName.Should().Be("Governance"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.GovernancePageName); _sut.TrustPageMetadata.TrustName.Should().Be("My trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/HistoricMembersModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/HistoricMembersModelTests.cs index b941e99a4..171b1762a 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/HistoricMembersModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/HistoricMembersModelTests.cs @@ -1,5 +1,5 @@ -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Data.Repositories.Trust; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Governance; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -93,15 +93,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_null() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Governance" }); - } - [Fact] public async Task OnGetAsync_sets_Governance_Service() { @@ -115,12 +106,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (0)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", true, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", true, "governance-nav") ]); } @@ -130,10 +125,14 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", "Governance", true) + new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", + ViewConstants.GovernancePageName, false), + new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", + ViewConstants.GovernancePageName, true) ]); } @@ -142,8 +141,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Historic members"); - _sut.TrustPageMetadata.PageName.Should().Be("Governance"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.GovernanceHistoricMembersPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.GovernancePageName); _sut.TrustPageMetadata.TrustName.Should().Be("My trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/MembersModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/MembersModelTests.cs index 0f62f8a25..039cb6f52 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/MembersModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/MembersModelTests.cs @@ -1,5 +1,5 @@ -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Data.Repositories.Trust; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Governance; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -93,15 +93,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_null() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Governance" }); - } - [Fact] public async Task OnGetAsync_sets_Governance_Service() { @@ -115,12 +106,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (0)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", true, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", true, "governance-nav") ]); } @@ -130,10 +125,14 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", "Governance", true), - new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", "Governance", false) + new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", + ViewConstants.GovernancePageName, false), + new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", ViewConstants.GovernancePageName, + true), + new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", + ViewConstants.GovernancePageName, false) ]); } @@ -142,8 +141,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Members"); - _sut.TrustPageMetadata.PageName.Should().Be("Governance"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.GovernanceMembersPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.GovernancePageName); _sut.TrustPageMetadata.TrustName.Should().Be("My trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrustLeadershipModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrustLeadershipModelTests.cs index a375375a4..0ac285582 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrustLeadershipModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrustLeadershipModelTests.cs @@ -1,5 +1,5 @@ -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Data.Repositories.Trust; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Governance; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -93,15 +93,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_null() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Governance" }); - } - [Fact] public async Task OnGetAsync_sets_Governance_Service() { @@ -115,12 +106,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (0)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", true, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", true, "governance-nav") ]); } @@ -130,10 +125,14 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", "Governance", true), - new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", "Governance", false) + new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", + ViewConstants.GovernancePageName, true), + new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", + ViewConstants.GovernancePageName, false) ]); } @@ -142,8 +141,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Trust leadership"); - _sut.TrustPageMetadata.PageName.Should().Be("Governance"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.GovernanceTrustLeadershipPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.GovernancePageName); _sut.TrustPageMetadata.TrustName.Should().Be("My trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrusteesModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrusteesModelTests.cs index 0a4c1eb62..87506bb9f 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrusteesModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Governance/TrusteesModelTests.cs @@ -1,5 +1,5 @@ -using DfE.FindInformationAcademiesTrusts.Data.Enums; using DfE.FindInformationAcademiesTrusts.Data.Repositories.Trust; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Governance; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -93,15 +93,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_null() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List { "Governance" }); - } - [Fact] public async Task OnGetAsync_sets_Governance_Service() { @@ -115,12 +106,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (0)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", true, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", true, "governance-nav") ]); } @@ -130,10 +125,14 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", "Governance", true), - new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", "Governance", false), - new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", "Governance", false) + new TrustSubNavigationLinkModel("Trust leadership (1)", "./TrustLeadership", "1234", + ViewConstants.GovernancePageName, false), + new TrustSubNavigationLinkModel("Trustees (1)", "./Trustees", "1234", ViewConstants.GovernancePageName, + true), + new TrustSubNavigationLinkModel("Members (1)", "./Members", "1234", ViewConstants.GovernancePageName, + false), + new TrustSubNavigationLinkModel("Historic members (1)", "./HistoricMembers", "1234", + ViewConstants.GovernancePageName, false) ]); } @@ -142,8 +141,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Trustees"); - _sut.TrustPageMetadata.PageName.Should().Be("Governance"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.GovernanceTrusteesPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.GovernancePageName); _sut.TrustPageMetadata.TrustName.Should().Be("My trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/CurrentRatingsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/CurrentRatingsModelTests.cs index ef3bfd820..082531765 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/CurrentRatingsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/CurrentRatingsModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Ofsted; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -33,7 +33,7 @@ public CurrentRatingsModelTests() _mockDateTimeProvider.Object, new MockLogger().Object ) - { Uid = "1234" }; + { Uid = "1234" }; } [Fact] @@ -44,22 +44,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mis), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Date joined trust" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { - "Current Ofsted rating", "Date of last inspection", "Previous Ofsted rating", "Date of previous inspection" - }); - } - - [Fact] public async Task OnGetAsync_sets_academies_from_academyService() { @@ -88,12 +72,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", true, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", true, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -103,14 +91,17 @@ public async Task OnGetAsync_sets_SubNavigationLinks_toEmptyArray() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", "1234", + ViewConstants.OfstedPageName, true), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", "1234", - "Ofsted", false), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", "1234", + ViewConstants.OfstedPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", "1234", - "Ofsted", false) + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", "1234", + ViewConstants.OfstedPageName, false) ]); } @@ -187,8 +178,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Current ratings"); - _sut.TrustPageMetadata.PageName.Should().Be("Ofsted"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OfstedCurrentRatingsPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OfstedPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/ImportantDatesModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/ImportantDatesModelTests.cs index 577163503..7865016f1 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/ImportantDatesModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/ImportantDatesModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Ofsted; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -33,7 +33,7 @@ public ImportantDatesModelTests() _mockDateTimeProvider.Object, new MockLogger().Object ) - { Uid = "1234" }; + { Uid = "1234" }; } [Fact] @@ -44,22 +44,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mis), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Date joined trust" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { - "Current Ofsted rating", "Date of last inspection", "Previous Ofsted rating", "Date of previous inspection" - }); - } - - [Fact] public async Task OnGetAsync_sets_academies_from_academyService() { @@ -88,12 +72,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", true, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", true, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -103,14 +91,17 @@ public async Task OnGetAsync_sets_SubNavigationLinks_toEmptyArray() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", "1234", - "Ofsted", false), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", "1234", + ViewConstants.OfstedPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", "1234", + ViewConstants.OfstedPageName, true), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", "1234", - "Ofsted", false) + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", "1234", + ViewConstants.OfstedPageName, false) ]); } @@ -187,8 +178,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Important dates"); - _sut.TrustPageMetadata.PageName.Should().Be("Ofsted"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OfstedImportantDatesPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OfstedPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/OfstedAreaModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/OfstedAreaModelTests.cs index fda383e7c..e28cf6511 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/OfstedAreaModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/OfstedAreaModelTests.cs @@ -1,8 +1,10 @@ using DfE.FindInformationAcademiesTrusts.Data; using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Ofsted; using DfE.FindInformationAcademiesTrusts.Services.Academy; +using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Export; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; @@ -21,10 +23,19 @@ public class OfstedAreaModelTests private readonly TrustSummaryServiceModel _fakeTrust = new("1234", "My Trust", "Multi-academy trust", 3); + private readonly DataSourceServiceModel _giasDataSource = + new(Source.Gias, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + + private readonly DataSourceServiceModel _misDataSource = + new(Source.Mis, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + public OfstedAreaModelTests() { _mockTrustService.Setup(t => t.GetTrustSummaryAsync(_fakeTrust.Uid)) .ReturnsAsync(_fakeTrust); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Gias)).ReturnsAsync(_giasDataSource); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Mis)).ReturnsAsync(_misDataSource); + _sut = new OfstedAreaModel(_mockDataSourceService.Object, _mockTrustService.Object, @@ -33,7 +44,7 @@ public OfstedAreaModelTests() _mockDateTimeProvider.Object, new MockLogger().Object ) - { Uid = "1234" }; + { Uid = "1234" }; } [Fact] @@ -50,13 +61,34 @@ public async Task OnGetAsync_sets_correct_data_source_list() await _sut.OnGetAsync(); _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); _mockDataSourceService.Verify(e => e.GetAsync(Source.Mis), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Date joined trust" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { - "Current Ofsted rating", "Date of last inspection", "Previous Ofsted rating", "Date of previous inspection" - }); + _sut.DataSourcesPerPage.Count.Should().Be(4); + _sut.DataSourcesPerPage.Should().BeEquivalentTo([ + new DataSourcePageListEntry(ViewConstants.OfstedCurrentRatingsPageName, [ + new DataSourceListEntry(_giasDataSource, "Date joined trust"), + new DataSourceListEntry(_misDataSource, "Current Ofsted rating"), + new DataSourceListEntry(_misDataSource, "Date of current inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedPreviousRatingsPageName, [ + new DataSourceListEntry(_giasDataSource, "Date joined trust"), + new DataSourceListEntry(_misDataSource, "Previous Ofsted rating"), + new DataSourceListEntry(_misDataSource, "Date of previous inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedImportantDatesPageName, [ + new DataSourceListEntry(_giasDataSource, "Date joined trust"), + new DataSourceListEntry(_misDataSource, "Date of current inspection"), + new DataSourceListEntry(_misDataSource, "Date of previous inspection") + ] + ), + new DataSourcePageListEntry(ViewConstants.OfstedSafeguardingAndConcernsPageName, [ + new DataSourceListEntry(_giasDataSource, "Date joined trust"), + new DataSourceListEntry(_misDataSource, "Effective safeguarding"), + new DataSourceListEntry(_misDataSource, "Category of concern"), + new DataSourceListEntry(_misDataSource, "Date of current inspection") + ] + ) + ]); } @@ -88,12 +120,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", true, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", true, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -103,14 +139,17 @@ public async Task OnGetAsync_sets_SubNavigationLinks_toEmptyArray() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", "1234", - "Ofsted", false), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", "1234", + ViewConstants.OfstedPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", "1234", - "Ofsted", false) + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", "1234", + ViewConstants.OfstedPageName, false) ]); } @@ -187,7 +226,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.PageName.Should().Be("Ofsted"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OfstedPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/PreviousRatingsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/PreviousRatingsModelTests.cs index 3812a3af9..f1db67866 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/PreviousRatingsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/PreviousRatingsModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Ofsted; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -33,7 +33,7 @@ public PreviousRatingsModelTests() _mockDateTimeProvider.Object, new MockLogger().Object ) - { Uid = "1234" }; + { Uid = "1234" }; } [Fact] @@ -44,22 +44,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mis), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Date joined trust" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { - "Current Ofsted rating", "Date of last inspection", "Previous Ofsted rating", "Date of previous inspection" - }); - } - - [Fact] public async Task OnGetAsync_sets_academies_from_academyService() { @@ -88,12 +72,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", true, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", true, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -103,14 +91,17 @@ public async Task OnGetAsync_sets_SubNavigationLinks_toEmptyArray() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", "1234", - "Ofsted", true), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", "1234", + ViewConstants.OfstedPageName, true), + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", "1234", - "Ofsted", false) + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", "1234", + ViewConstants.OfstedPageName, false) ]); } @@ -187,8 +178,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Previous ratings"); - _sut.TrustPageMetadata.PageName.Should().Be("Ofsted"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OfstedPreviousRatingsPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OfstedPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/SafeguardingAndConcernsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/SafeguardingAndConcernsModelTests.cs index 5d6dfc8e9..460631124 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/SafeguardingAndConcernsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Ofsted/SafeguardingAndConcernsModelTests.cs @@ -1,5 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data; -using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Ofsted; using DfE.FindInformationAcademiesTrusts.Services.Academy; @@ -33,7 +33,7 @@ public SafeguardingAndConcernsModelTests() _mockDateTimeProvider.Object, new MockLogger().Object ) - { Uid = "1234" }; + { Uid = "1234" }; } [Fact] @@ -44,22 +44,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Mis), Times.Once); - _sut.DataSources.Count.Should().Be(2); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Date joined trust" }); - _sut.DataSources[1].Fields.Should().Contain(new List - { - "Current Ofsted rating", "Date of last inspection", "Previous Ofsted rating", "Date of previous inspection" - }); - } - - [Fact] public async Task OnGetAsync_sets_academies_from_academyService() { @@ -88,12 +72,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", true, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", true, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -103,14 +91,17 @@ public async Task OnGetAsync_sets_SubNavigationLinks_toEmptyArray() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Current ratings", "./CurrentRatings", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedCurrentRatingsPageName, "./CurrentRatings", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Previous ratings", "./PreviousRatings", "1234", - "Ofsted", false), - new TrustSubNavigationLinkModel("Important dates", "./ImportantDates", "1234", "Ofsted", + new TrustSubNavigationLinkModel(ViewConstants.OfstedPreviousRatingsPageName, "./PreviousRatings", "1234", + ViewConstants.OfstedPageName, false), + new TrustSubNavigationLinkModel(ViewConstants.OfstedImportantDatesPageName, "./ImportantDates", "1234", + ViewConstants.OfstedPageName, false), - new TrustSubNavigationLinkModel("Safeguarding and concerns", "./SafeguardingAndConcerns", "1234", - "Ofsted", true) + new TrustSubNavigationLinkModel(ViewConstants.OfstedSafeguardingAndConcernsPageName, + "./SafeguardingAndConcerns", "1234", + ViewConstants.OfstedPageName, true) ]); } @@ -187,8 +178,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Safeguarding and concerns"); - _sut.TrustPageMetadata.PageName.Should().Be("Ofsted"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OfstedSafeguardingAndConcernsPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OfstedPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/OverviewAreaModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/OverviewAreaModelTests.cs index 3bfe34e8c..5847c2c1a 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/OverviewAreaModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/OverviewAreaModelTests.cs @@ -1,6 +1,8 @@ using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Overview; +using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Trust; using DfE.FindInformationAcademiesTrusts.UnitTests.Mocks; using Microsoft.AspNetCore.Mvc; @@ -18,11 +20,15 @@ public class OverviewAreaModelTests new(TrustUid, "", "", "", TrustType.MultiAcademyTrust, "", "", null, null, 0, new Dictionary(), 0, 0); + private readonly DataSourceServiceModel _giasDataSource = + new(Source.Gias, new DateTime(2025, 1, 1), UpdateFrequency.Daily); + public OverviewAreaModelTests() { _mockTrustService.Setup(t => t.GetTrustSummaryAsync(TrustUid)) .ReturnsAsync(new TrustSummaryServiceModel(TrustUid, "My Trust", "Multi-academy trust", 3)); _mockTrustService.Setup(t => t.GetTrustOverviewAsync(TrustUid)).ReturnsAsync(BaseTrustOverviewServiceModel); + _mockDataSourceService.Setup(s => s.GetAsync(Source.Gias)).ReturnsAsync(_giasDataSource); _sut = new OverviewAreaModel( _mockDataSourceService.Object, @@ -44,9 +50,12 @@ public async Task OnGetAsync_sets_correct_data_source_list() { _ = await _sut.OnGetAsync(); _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust details", "Reference numbers", "Trust summary" }); + _sut.DataSourcesPerPage.Count.Should().Be(3); + _sut.DataSourcesPerPage.Should().BeEquivalentTo([ + new DataSourcePageListEntry(ViewConstants.OverviewTrustDetailsPageName, [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.OverviewTrustSummaryPageName, [new DataSourceListEntry(_giasDataSource)]), + new DataSourcePageListEntry(ViewConstants.OverviewReferenceNumbersPageName, [new DataSourceListEntry(_giasDataSource)]) + ]); } [Fact] @@ -54,12 +63,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", true, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", true, + "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -69,9 +82,12 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust details", "./TrustDetails", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Trust summary", "./TrustSummary", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Reference numbers", "./ReferenceNumbers", "1234", "Overview", false) + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustDetailsPageName, "./TrustDetails", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustSummaryPageName, "./TrustSummary", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewReferenceNumbersPageName, "./ReferenceNumbers", "1234", + ViewConstants.OverviewPageName, false) ]); } @@ -80,7 +96,7 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.PageName.Should().Be("Overview"); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OverviewPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/ReferenceNumbersModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/ReferenceNumbersModelTests.cs index 3ee5197ac..cec8af2c7 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/ReferenceNumbersModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/ReferenceNumbersModelTests.cs @@ -1,4 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Overview; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -39,27 +40,21 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - _ = await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust details", "Reference numbers", "Trust summary" }); - } - [Fact] public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", true, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", true, + "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -69,9 +64,12 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust details", "./TrustDetails", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Trust summary", "./TrustSummary", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Reference numbers", "./ReferenceNumbers", "1234", "Overview", true) + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustDetailsPageName, "./TrustDetails", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustSummaryPageName, "./TrustSummary", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewReferenceNumbersPageName, "./ReferenceNumbers", "1234", + ViewConstants.OverviewPageName, true) ]); } @@ -80,8 +78,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Reference numbers"); - _sut.TrustPageMetadata.PageName.Should().Be("Overview"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OverviewReferenceNumbersPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OverviewPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustDetailsModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustDetailsModelTests.cs index b9840c7c5..098c483c0 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustDetailsModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustDetailsModelTests.cs @@ -17,7 +17,8 @@ public class TrustDetailsModelTests private readonly Mock _mockLinksToOtherServices = new(); private static readonly TrustOverviewServiceModel BaseTrustOverviewServiceModel = - new(TrustUid, "", "", "", TrustType.MultiAcademyTrust, "", "", null, null, 0, new Dictionary(), 0, + new(TrustUid, "GroupID", "", "", TrustType.MultiAcademyTrust, "", "", null, null, 0, + new Dictionary(), 0, 0); public TrustDetailsModelTests() @@ -42,16 +43,6 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - _ = await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust details", "Reference numbers", "Trust summary" }); - } - [Fact] public async Task CompaniesHouseLink_is_null_if_link_builder_returns_null() { @@ -129,12 +120,16 @@ public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", true, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", true, + "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -144,9 +139,12 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust details", "./TrustDetails", "1234", "Overview", true), - new TrustSubNavigationLinkModel("Trust summary", "./TrustSummary", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Reference numbers", "./ReferenceNumbers", "1234", "Overview", false) + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustDetailsPageName, "./TrustDetails", "1234", ViewConstants.OverviewPageName, + true), + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustSummaryPageName, "./TrustSummary", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewReferenceNumbersPageName, "./ReferenceNumbers", "1234", + ViewConstants.OverviewPageName, false) ]); } @@ -155,8 +153,25 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Trust details"); - _sut.TrustPageMetadata.PageName.Should().Be("Overview"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OverviewTrustDetailsPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OverviewPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } + + [Fact] + public void SharepointLink_should_be_empty_string_by_default() + { + _sut.SharepointLink.Should().Be(""); + } + + [Fact] + public async Task OnGetAsync_should_Set_correct_SharepointLink() + { + _mockLinksToOtherServices.Setup(l => + l.SharepointFolderLink(BaseTrustOverviewServiceModel.GroupId)) + .Returns("url/groupID"); + await _sut.OnGetAsync(); + + _sut.SharepointLink.Should().Be("url/groupID"); + } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustSummaryModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustSummaryModelTests.cs index fb11672c6..9d33aec42 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustSummaryModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/Overview/TrustSummaryModelTests.cs @@ -1,4 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Pages.Trusts.Overview; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -71,27 +72,21 @@ public async Task OnGetAsync_returns_NotFoundResult_if_Trust_is_not_found() result.Should().BeOfType(); } - [Fact] - public async Task OnGetAsync_sets_correct_data_source_list() - { - _ = await _sut.OnGetAsync(); - _mockDataSourceService.Verify(e => e.GetAsync(Source.Gias), Times.Once); - _sut.DataSources.Should().ContainSingle(); - _sut.DataSources[0].Fields.Should().Contain(new List - { "Trust details", "Reference numbers", "Trust summary" }); - } - [Fact] public async Task OnGetAsync_sets_correct_NavigationLinks() { _ = await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", true, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", true, + "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -101,9 +96,12 @@ public async Task OnGetAsync_sets_correct_SubNavigationLinks() { _ = await _sut.OnGetAsync(); _sut.SubNavigationLinks.Should().BeEquivalentTo([ - new TrustSubNavigationLinkModel("Trust details", "./TrustDetails", "1234", "Overview", false), - new TrustSubNavigationLinkModel("Trust summary", "./TrustSummary", "1234", "Overview", true), - new TrustSubNavigationLinkModel("Reference numbers", "./ReferenceNumbers", "1234", "Overview", false) + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustDetailsPageName, "./TrustDetails", "1234", ViewConstants.OverviewPageName, + false), + new TrustSubNavigationLinkModel(ViewConstants.OverviewTrustSummaryPageName, "./TrustSummary", "1234", ViewConstants.OverviewPageName, + true), + new TrustSubNavigationLinkModel(ViewConstants.OverviewReferenceNumbersPageName, "./ReferenceNumbers", "1234", + ViewConstants.OverviewPageName, false) ]); } @@ -112,8 +110,8 @@ public async Task OnGetAsync_should_configure_TrustPageMetadata() { _ = await _sut.OnGetAsync(); - _sut.TrustPageMetadata.SubPageName.Should().Be("Trust summary"); - _sut.TrustPageMetadata.PageName.Should().Be("Overview"); + _sut.TrustPageMetadata.SubPageName.Should().Be(ViewConstants.OverviewTrustSummaryPageName); + _sut.TrustPageMetadata.PageName.Should().Be(ViewConstants.OverviewPageName); _sut.TrustPageMetadata.TrustName.Should().Be("My Trust"); } } diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/TrustsAreaModelTests.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/TrustsAreaModelTests.cs index ed24e157d..b366096f8 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/TrustsAreaModelTests.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Pages/Trusts/TrustsAreaModelTests.cs @@ -1,4 +1,5 @@ using DfE.FindInformationAcademiesTrusts.Data.Enums; +using DfE.FindInformationAcademiesTrusts.Pages; using DfE.FindInformationAcademiesTrusts.Pages.Trusts; using DfE.FindInformationAcademiesTrusts.Services.DataSource; using DfE.FindInformationAcademiesTrusts.Services.Trust; @@ -66,12 +67,16 @@ public async Task OnGetAsync_should_populate_NavigationLinks() await _sut.OnGetAsync(); _sut.NavigationLinks.Should().BeEquivalentTo([ - new TrustNavigationLinkModel("Overview", "/Trusts/Overview/TrustDetails", "1234", false, "overview-nav"), - new TrustNavigationLinkModel("Contacts", "/Trusts/Contacts/InDfe", "1234", false, "contacts-nav"), + new TrustNavigationLinkModel(ViewConstants.OverviewPageName, "/Trusts/Overview/TrustDetails", "1234", + false, "overview-nav"), + new TrustNavigationLinkModel(ViewConstants.ContactsPageName, "/Trusts/Contacts/InDfe", "1234", false, + "contacts-nav"), new TrustNavigationLinkModel("Academies (3)", "/Trusts/Academies/Details", "1234", false, "academies-nav"), - new TrustNavigationLinkModel("Ofsted", "/Trusts/Ofsted/CurrentRatings", "1234", false, "ofsted-nav"), - new TrustNavigationLinkModel("Governance", "/Trusts/Governance/TrustLeadership", "1234", false, + new TrustNavigationLinkModel(ViewConstants.OfstedPageName, "/Trusts/Ofsted/CurrentRatings", "1234", false, + "ofsted-nav"), + new TrustNavigationLinkModel(ViewConstants.GovernancePageName, "/Trusts/Governance/TrustLeadership", + "1234", false, "governance-nav") ]); } @@ -127,17 +132,16 @@ public void MapDataSourceToName_should_return_Unknown_when_source_is_not_recogni } [Fact] - public void MapDataSourceToTestId_ShouldMapSourceAndFieldsCorrectly() + public void MapDataSourceToTestId_ShouldMapSourceAndDataFieldCorrectly() { // Arrange var source = new DataSourceServiceModel(Source.Cdm, null, null); - var fields = new List { "Field One", "FieldTwo" }; // Act - var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, fields)); + var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source)); // Assert - Assert.Equal("data-source-cdm-field-one-fieldtwo", result); + Assert.Equal("data-source-cdm-all-information", result); } [Fact] @@ -147,10 +151,10 @@ public void MapDataSourceToTestId_ShouldHandleEmptyFields() var source = new DataSourceServiceModel(Source.Gias, null, null); // Act - var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, new List())); + var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, "")); // Assert - Assert.Equal("data-source-gias-", result); // Fields are empty, but source should still be present + Assert.Equal("data-source-gias", result); // Field is empty, but source should still be present } [Fact] @@ -158,38 +162,35 @@ public void MapDataSourceToTestId_ShouldHandleFieldsWithSpaces() { // Arrange var source = new DataSourceServiceModel(Source.Mis, null, null); - var fields = new List { " Field Three", " FieldFour " }; // Act - var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, fields)); + var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, "fields")); // Assert - Assert.Equal("data-source-mis-field-three-fieldfour", result); + Assert.Equal("data-source-mis-fields", result); } [Fact] - public void MapDataSourceToTestId_ShouldHandleSingleFieldCorrectly() + public void MapDataSourceToTestId_ShouldHandleMixedCaseFields() { // Arrange - var source = new DataSourceServiceModel(Source.Mstr, null, null); - var fields = new List { "FieldOne" }; + var source = new DataSourceServiceModel(Source.FiatDb, null, null); // Act - var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, fields)); + var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, "FiElDOne FiELDTwo")); // Assert - Assert.Equal("data-source-mstr-fieldone", result); + Assert.Equal("data-source-fiatdb-fieldone-fieldtwo", result); } [Fact] - public void MapDataSourceToTestId_ShouldHandleMixedCaseFields() + public void MapDataSourceToTestId_ShouldRemovePunctuation_and_PreseveWordsAndNumbers() { // Arrange var source = new DataSourceServiceModel(Source.FiatDb, null, null); - var fields = new List { "FiElDOne", "FiELDTwo" }; // Act - var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, fields)); + var result = _sut.MapDataSourceToTestId(new DataSourceListEntry(source, "#FiElDOne @FiELDTwo!")); // Assert Assert.Equal("data-source-fiatdb-fieldone-fieldtwo", result); diff --git a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Services/DataSource/DataSourceListEntryTest.cs b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Services/DataSource/DataSourceListEntryTest.cs index e70464c78..07b2f3d86 100644 --- a/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Services/DataSource/DataSourceListEntryTest.cs +++ b/tests/DfE.FindInformationAcademiesTrusts.UnitTests/Services/DataSource/DataSourceListEntryTest.cs @@ -8,7 +8,7 @@ public class DataSourceListEntryTest [Fact] public void LastUpdatedText_returns_unknown_when_LastUpdated_is_null() { - var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null), []); + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null)); sut.LastUpdatedText.Should().Be("Unknown"); } @@ -16,28 +16,42 @@ public void LastUpdatedText_returns_unknown_when_LastUpdated_is_null() public void LastUpdatedText_returns_correctString_when_LastUpdated_is_set() { var date = DateTime.Today; - var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, date, null), []); + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, date, null)); sut.LastUpdatedText.Should().Be(date.ToString("dd MMM yyyy")); } [Fact] public void UpdatedByText_returns_null_when_UpdatedBy_is_null() { - var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null), []); + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null)); sut.UpdatedByText.Should().Be(null); } [Fact] public void UpdatedByText_returns_correctString_when_UpdatedBy_is_set() { - var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null, "Updated by"), []); + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null, "Updated by")); sut.UpdatedByText.Should().Be("Updated by"); } [Fact] public void UpdatedByText_returns_correctString_when_UpdatedBy_is_set_to_TRAMs_Migration() { - var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null, "TRAMs Migration"), []); + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Cdm, null, null, "TRAMs Migration")); sut.UpdatedByText.Should().Be("TRAMS Migration"); } + + [Fact] + public void DataField_default_is_correct() + { + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Gias, null, null)); + sut.DataField.Should().Be("All information"); + } + + [Fact] + public void DataField_is_correct_when_set() + { + var sut = new DataSourceListEntry(new DataSourceServiceModel(Source.Gias, null, null), "Not all information"); + sut.DataField.Should().Be("Not all information"); + } }