示例#1
0
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());
            var index = new Index();

            var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel;
            var view            = index.RenderAsHtml(searchViewModel);

            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            view.GetElementbyId("Location").Should().NotBeNull();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            view.GetElementbyId("loc-within").Should().NotBeNull();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            //Shares parent with loc-within here.
            view.GetElementbyId("apprenticeship-level").Should().NotBeNull();

            view.GetElementbyId("search-button").Should().NotBeNull();
            view.GetElementbyId("search-button").Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("search-button").Attributes["class"].Value.Contains(" active").Should().BeFalse();

            view.GetElementbyId("browse-button").Should().NotBeNull();
            view.GetElementbyId("browse-button").Attributes["class"].Value.Contains(" tab2").Should().BeFalse();
            view.GetElementbyId("browse-button").Attributes["class"].Value.Contains(" active").Should().BeFalse();
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());

            var categories = new categories();

            var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("category-load-failed").Should().NotBeNull();
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());

            var categories = new categoriesAndSubCategories();

            var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeTrue();
            view.GetElementbyId("category-load-failed").Should().NotBeNull();
        }
示例#4
0
        public void BlacklistedCategoryCodes()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories()).Returns(GetCategories);

            var response = Mediator.Index(ApprenticeshipSearchMode.Category);

            var categories = response.ViewModel.Categories;

            categories.Count.Should().Be(3);
            categories.Any(c => c.CodeName == "00").Should().BeFalse();
            categories.Any(c => c.CodeName == "99").Should().BeFalse();
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());
            var searchUpdate = new searchUpdate();

            var searchViewModel        = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;
            var searchResultsViewModel = Mediator.Results(null, searchViewModel).ViewModel;
            var view = searchUpdate.RenderAsHtml(searchResultsViewModel.VacancySearch);

            view.GetElementbyId("Keywords").Should().BeNull();
            view.GetElementbyId("Location").Should().NotBeNull();
            view.GetElementbyId("loc-within").Should().NotBeNull();
            view.GetElementbyId("apprenticeship-level").Should().NotBeNull();
            view.GetElementbyId("search-button").Should().NotBeNull();

            var createNewSearchLink = view.GetElementbyId("start-again-link");

            createNewSearchLink.Should().NotBeNull();
            createNewSearchLink.OuterHtml.Should().Contain("SearchMode=Category");
        }
示例#6
0
        public void TestKeywordSearchModification()
        {
            const string selectedCategoryCode        = "2";
            const string selectedCategorySubCategory = "2_2";

            ReferenceDataService.Setup(rds => rds.GetCategories()).Returns(new List <Category>
            {
                new Category
                {
                    CodeName      = "1",
                    SubCategories = new List <Category>
                    {
                        new Category {
                            CodeName = "1_1"
                        },
                        new Category {
                            CodeName = "1_2"
                        }
                    }
                },
                new Category
                {
                    CodeName      = selectedCategoryCode,
                    SubCategories = new List <Category>
                    {
                        new Category {
                            CodeName = "2_1"
                        },
                        new Category {
                            CodeName = selectedCategorySubCategory
                        }
                    }
                }
            });

            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Keywords     = AKeyword,
                Location     = ACityWithOneSuggestedLocation,
                LocationType = ApprenticeshipLocationType.NonNational,
                Category     = selectedCategoryCode,
                //Select Sub Categories from a different category than the one selected plus a valid one
                SubCategories = new[]
                {
                    "1_1",
                    "1_2",
                    selectedCategorySubCategory
                },
                SearchMode = ApprenticeshipSearchMode.Keyword
            };

            var response = Mediator.Results(searchViewModel);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.Ok, true);

            //The search sent to the search provider should have been modified based on the search mode
            _searchSentToSearchProvider.Should().NotBeNull();
            _searchSentToSearchProvider.Keywords.Should().Be(AKeyword);
            _searchSentToSearchProvider.Location.Should().Be(ACityWithOneSuggestedLocation);
            _searchSentToSearchProvider.LocationType.Should().Be(ApprenticeshipLocationType.NonNational);
            _searchSentToSearchProvider.Categories.Should().BeNull();
            _searchSentToSearchProvider.Category.Should().BeNullOrEmpty();
            _searchSentToSearchProvider.SubCategories.Should().BeNull();
            _searchSentToSearchProvider.SearchMode.Should().Be(ApprenticeshipSearchMode.Keyword);

            //But the returned search should be the original search the user submitted so as not to lose any of their changes
            var returnedSearch = response.ViewModel.VacancySearch;

            returnedSearch.Should().NotBeNull();
            returnedSearch.Keywords.Should().Be(AKeyword);
            returnedSearch.Location.Should().Be(ACityWithOneSuggestedLocation);
            returnedSearch.LocationType.Should().Be(ApprenticeshipLocationType.NonNational);
            returnedSearch.Categories.Should().NotBeNull();
            returnedSearch.Categories.Count.Should().Be(2);
            returnedSearch.Category.Should().Be(selectedCategoryCode);
            returnedSearch.SubCategories.Length.Should().Be(1);
            returnedSearch.SubCategories[0].Should().Be(selectedCategorySubCategory);
            returnedSearch.SearchMode.Should().Be(ApprenticeshipSearchMode.Keyword);
        }