public void ShouldDetermineEmptyResultsForGoogleAnalytic()
        {
            var searchPage       = new StandardResults();
            var modelWithResults = new ProviderStandardSearchResultViewModel
            {
                TotalResults  = 1,
                Hits          = new[] { new StandardProviderResultItemViewModel() },
                DeliveryModes = new List <DeliveryModeViewModel>(),
                SortOrder     = "0"
            };

            var modelWithoutResults = new ProviderStandardSearchResultViewModel
            {
                TotalResults  = 1,
                Hits          = new StandardProviderResultItemViewModel[0],
                DeliveryModes = new List <DeliveryModeViewModel>(),
                SortOrder     = "0"
            };

            var htmlWithResults    = searchPage.RenderAsHtml(modelWithResults).ToAngleSharp();
            var htmlWithoutResults = searchPage.RenderAsHtml(modelWithoutResults).ToAngleSharp();

            GetAttribute(htmlWithResults, "#ga-no-result", "value").Should().BeEquivalentTo("False");
            GetAttribute(htmlWithoutResults, "#ga-no-result", "value").Should().BeEquivalentTo("True");
        }
        public void WhenSearchResultHasNoResultsShouldNotShowNewSearchLink()
        {
            var detail = new StandardResults();
            var model  = new ProviderStandardSearchResultViewModel
            {
                TotalResults           = 0,
                PostCodeMissing        = false,
                StandardId             = "1",
                StandardName           = "Test standard name",
                Hits                   = new List <StandardProviderResultItemViewModel>(),
                ActualPage             = 1,
                LastPage               = 1,
                ResultsToTake          = 10,
                PostCode               = "Test postcode",
                DeliveryModes          = new List <DeliveryModeViewModel>(),
                HasError               = false,
                TotalResultsForCountry = 3,
                AbsolutePath           = "www.abba.co.uk",
                SortOrder              = "0"
            };

            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetHtmlElement(html, ".new-postcode-search").Should().BeNull();
            GetPartial(html, ".new-postcode-search").Should().BeEmpty();
        }
        public void WhenSearchResultHasResultButNoDeliveryModeHasResultsShouldShowFilterBox()
        {
            var detail = new StandardResults();
            var model  = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 10,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test standard name",
                Hits            = new List <StandardProviderResultItemViewModel>()
                {
                    new StandardProviderResultItemViewModel()
                },
                ActualPage    = 1,
                LastPage      = 1,
                ResultsToTake = 10,
                PostCode      = "Test postcode",
                DeliveryModes = new List <DeliveryModeViewModel>
                {
                    new DeliveryModeViewModel {
                        Value = "value"
                    }
                },
                HasError = false,
                TotalResultsForCountry = 3,
                AbsolutePath           = "www.abba.co.uk",
                SortOrder = "0"
            };

            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetHtmlElement(html, ".filter-box").Should().NotBeNull();
        }
        public void WhenSearchResultHasNoResultButThereAreProvidersInCountryShouldShowCountMessage()
        {
            var detail = new StandardResults();
            var model  = new ProviderStandardSearchResultViewModel
            {
                TotalResults           = 0,
                PostCodeMissing        = false,
                StandardId             = "1",
                StandardName           = "Test standard name",
                StandardLevel          = 3,
                Hits                   = new List <StandardProviderResultItemViewModel>(),
                ActualPage             = 1,
                LastPage               = 1,
                ResultsToTake          = 10,
                PostCode               = "Test postcode",
                DeliveryModes          = new List <DeliveryModeViewModel>(),
                HasError               = false,
                TotalResultsForCountry = 3
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".total-providers-country").Should().NotBeEmpty();
            var expectedText = string.Format("view all ({0}) training providers for Test standard name, level 3 in England", model.TotalResultsForCountry);

            GetPartial(html, ".total-providers-country").Should().Be(expectedText);
        }
        public void WhenSearchResultHasPaginationAndIsTheLastPageShouldShowOnlyBackPageLink()
        {
            var detail = new StandardResults();
            var model  = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 20,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test standard name",
                Hits            = new List <StandardProviderResultItemViewModel>
                {
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel(),
                    new StandardProviderResultItemViewModel()
                },
                ActualPage    = 3,
                LastPage      = 3,
                ResultsToTake = 10,
                PostCode      = "Test postcode",
                DeliveryModes = new List <DeliveryModeViewModel>(),
                HasError      = false
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".page-navigation__btn.prev").Should().Contain("Previous page").And.Contain("2 of 3");
            GetPartial(html, ".page-navigation__btn.next").Should().BeEmpty();
        }
        public void ShouldHaveDataForGoogleAnalytic()
        {
            var searchPage     = new StandardResults();
            var nameOfStandard = "Name of standard";
            var level          = 2;
            var title          = $"{nameOfStandard}, level {level}";
            var postcode       = "N17";
            var model          = new ProviderStandardSearchResultViewModel
            {
                TotalResults  = 1,
                StandardName  = nameOfStandard,
                StandardLevel = level,
                PostCode      = postcode,
                Hits          = new StandardProviderResultItemViewModel [0],
                DeliveryModes = new List <DeliveryModeViewModel>(),
                SortOrder     = "0"
            };

            var html = searchPage.RenderAsHtml(model).ToAngleSharp();

            GetAttribute(html, "#ga-apprenticeship-title", "value").Should().BeEquivalentTo(title);
            GetAttribute(html, "#ga-postcode", "value").Should().BeEquivalentTo(postcode);
        }
        public void WhenSearchResultHasNoResultShouldShowUsefulInformationMessage()
        {
            var detail = new StandardResults();
            var model  = new ProviderStandardSearchResultViewModel
            {
                TotalResults           = 0,
                PostCodeMissing        = false,
                StandardId             = "1",
                StandardName           = "Test standard name",
                Hits                   = new List <StandardProviderResultItemViewModel>(),
                ActualPage             = 1,
                LastPage               = 1,
                ResultsToTake          = 10,
                PostCode               = "Test postcode",
                DeliveryModes          = new List <DeliveryModeViewModel>(),
                HasError               = false,
                TotalResultsForCountry = 0
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".return-search-results").Should().Be("return to your apprenticeship training search results");
            GetPartial(html, ".start-again").Should().Be("start your job role or keyword search again");
        }