<commit_before>describe("chorus.pages.SearchIndexPage", function() {
    beforeEach(function() {
        this.query = "50/50";
    });

    it("has a helpId", function() {
        this.page = new chorus.pages.SearchIndexPage(this.query);
        expect(this.page.helpId).toBe("search");
    });

    context("when the search returns with unprocessableEntity", function() {
        beforeEach(function() {
            this.page = new chorus.pages.SearchIndexPage(this.query);
            spyOn(Backbone.history, 'loadUrl');
            this.server.lastFetchFor(this.page.model).failUnprocessableEntity();
        });

        it("shows a nice error popup", function() {
            expect(Backbone.history.loadUrl).toHaveBeenCalledWith('/unprocessableEntity');
            expect(chorus.pageOptions.title).toMatchTranslation('search.bad_entity_type.title');
            expect(chorus.pageOptions.text).toMatchTranslation('search.bad_entity_type.text');
        });
    });

    describe("when searching for all items, across all of chorus", function() {
        beforeEach(function() {
            this.page = new chorus.pages.SearchIndexPage(this.query);
        });

        it("fetches the search results for the given query", function() {
            expect(this.page.search.entityType()).toBe("all");
            expect(this.page.search.searchIn()).toBe("all");
            expect(this.page.search).toHaveBeenFetched();
        });

        describe("when the search result fetch completes", function() {
            beforeEach(function() {
                this.server.completeFetchFor(this.page.search, rspecFixtures.searchResult());
            });

            it("doesn't display the list content details", function() {
                expect(this.page.mainContent.contentDetails).toBeUndefined();
            });

            it("has breadcrumbs", function() {
                expect(this.page.$(".breadcrumbs li:eq(0)")).toContainTranslation('breadcrumbs.home');
                expect((this.page.$(".breadcrumbs li:eq(0) a")).attr("href")).toBe("#/");

                expect(this.page.$(".breadcrumbs li:eq(1) .slug")).toContainTranslation('breadcrumbs.search_results');
            });

            it("has the right title", function() {
                expect(this.page.$(".default_content_header h1")).toContainTranslation("search.index.title", {query: "50/50"});
            });

            it("has a 'Show All Results' link", function() {
                expect(this.page.$('.default_content_header .type .title')).toContainTranslation("search.show");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.all");
            });

            it("has filtered result links", function() {
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.workfile");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.hdfs_entry");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.dataset");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.workspace");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.user");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.instance");
            });

            describe("filtering by result type", function() {
                beforeEach(function() {
                    spyOn(chorus.router, "navigate");
                    this.page.$('.default_content_header li[data-type="workspace"] a').click();
                });

                it("should navigate to the filtered result type page", function() {
                    expect(this.page.search.entityType()).toBe("workspace");
                    expect(this.page.search.searchIn()).toBe("all");
                    expect(chorus.router.navigate).toHaveBeenCalledWith(this.page.search.showUrl());
                });
            });

            it("has a 'Search in' filter link", function() {
                var searchInMenu = this.page.$(".default_content_header .search_in");
                var searchInOptions = searchInMenu.find(".menu a");
                expect(searchInMenu.find(".chosen")).toContainTranslation("search.in.all");
                expect(searchInMenu.find(".title")).toContainTranslation("search.search_in");
                expect(searchInOptions.length).toBe(2);
                expect(searchInOptions).toContainTranslation("search.in.all");
                expect(searchInOptions).toContainTranslation("search.in.my_workspaces");
            });

            it("navigates to the right page when 'my workspaces' is selected from the 'search in' menu", function() {
                spyOn(chorus.router, "navigate");
                chorus.PageEvents.broadcast("choice:search_in", "my_workspaces");
                expect(this.page.search.entityType()).toBe("all");
                expect(this.page.search.searchIn()).toBe("my_workspaces");
                expect(chorus.router.navigate).toHaveBeenCalledWith(this.page.search.showUrl());
            });

            describe("the workfile section", function() {
                beforeEach(function() {
                    this.workfileLIs = this.page.$(".workfile_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.workfileLIs.length).toBeGreaterThan(0);
                });

                it("selects the first workfile by default", function() {
                    expect(this.workfileLIs.eq(0)).toHaveClass("selected");
                });

                describe("clicking on a workfile search result", function() {
                    beforeEach(function() {
                        this.workfileLIs.eq(3).trigger("click");
                    });

                    it("selects that workfile", function() {
                        expect(this.workfileLIs.eq(3)).toHaveClass("selected");
                    });

                    it("shows that workfile in the sidebar", function() {
                        expect(this.page.sidebar.$(".fileName")).toHaveText("Public");
                    });

                    it("sets the workfile as the selectedItem on the search result", function() {
                        expect(this.page.search.selectedItem).toBe(this.page.search.workfiles().at(3));
                    });
                });
            });

            describe("the workspace section", function() {
                beforeEach(function() {
                    this.workspaceLIs = this.page.$(".workspace_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.workspaceLIs.length).toBeGreaterThan(0);
                });

                describe("clicking on a workspace search result", function() {
                    beforeEach(function() {
                        this.workspaceLIs.eq(1).trigger("click");
                    });

                    it("selects that workspace", function() {
                        expect(this.workspaceLIs.eq(1)).toHaveClass("selected");
                    });

                    it("shows that workspace in the sidebar", function() {
                        expect(this.page.sidebar.$(".info .name")).toHaveText("Private");
                    });

                    it("show the 'add a note' link in the sidebar", function() {
                        expect(this.page.sidebar.$("a[data-dialog='NotesNew']")).toExist();
                    });

                    it("show the 'add an insight' link in the sidebar", function() {
                        expect(this.page.sidebar.$("a[data-dialog='InsightsNew']")).toExist();
                    });
                });
            });

            describe("the dataset section", function() {
                beforeEach(function() {
                    this.datasetLIs = this.page.$(".dataset_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.datasetLIs.length).toBeGreaterThan(0);
                });

                describe("clicking on a tabular data search result", function() {
                    beforeEach(function() {
                        this.datasetLIs.eq(2).trigger("click");
                    });

                    it("selects that tabular data item", function() {
                        expect(this.datasetLIs.eq(2)).toHaveClass("selected");
                    });

                    it("shows the tabular data item in the sidebar", function() {
                        expect(this.page.sidebar.$(".info .name")).toHaveText("typeahead");
                    });

                    it("shows the associate-with-workspace link in the sidebar", function() {
                        expect(this.page.sidebar.$('a.associate')).toExist();
                    });
                });
            });

            describe("the instance section", function() {
                beforeEach(function() {
                    this.instanceLIs = this.page.$(".instance_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.instanceLIs.length).toBe(3);
                });

                describe("clicking on an instance search result", function() {
                    beforeEach(function() {
                        spyOn(this.page.sidebars.instance, "setInstance");
                        this.instanceLIs.eq(0).trigger("click");
                    });

                    it("selects that instance", function() {
                        expect(this.instanceLIs.eq(0)).toHaveClass("selected");
                    });

                    it("shows the instance in the sidebar", function() {
                        expect($(this.page.sidebar.el)).toHaveClass("instance_list_sidebar");
                        expect(this.page.sidebars.instance.setInstance).toHaveBeenCalledWith(this.page.search.instances().at(0));
                    });<commit_msg>Update jasmine fixture reference<commit_after>describe("chorus.pages.SearchIndexPage", function() {
    beforeEach(function() {
        this.query = "50/50";
    });

    it("has a helpId", function() {
        this.page = new chorus.pages.SearchIndexPage(this.query);
        expect(this.page.helpId).toBe("search");
    });

    context("when the search returns with unprocessableEntity", function() {
        beforeEach(function() {
            this.page = new chorus.pages.SearchIndexPage(this.query);
            spyOn(Backbone.history, 'loadUrl');
            this.server.lastFetchFor(this.page.model).failUnprocessableEntity();
        });

        it("shows a nice error popup", function() {
            expect(Backbone.history.loadUrl).toHaveBeenCalledWith('/unprocessableEntity');
            expect(chorus.pageOptions.title).toMatchTranslation('search.bad_entity_type.title');
            expect(chorus.pageOptions.text).toMatchTranslation('search.bad_entity_type.text');
        });
    });

    describe("when searching for all items, across all of chorus", function() {
        beforeEach(function() {
            this.page = new chorus.pages.SearchIndexPage(this.query);
        });

        it("fetches the search results for the given query", function() {
            expect(this.page.search.entityType()).toBe("all");
            expect(this.page.search.searchIn()).toBe("all");
            expect(this.page.search).toHaveBeenFetched();
        });

        describe("when the search result fetch completes", function() {
            beforeEach(function() {
                this.server.completeFetchFor(this.page.search, rspecFixtures.searchResult());
            });

            it("doesn't display the list content details", function() {
                expect(this.page.mainContent.contentDetails).toBeUndefined();
            });

            it("has breadcrumbs", function() {
                expect(this.page.$(".breadcrumbs li:eq(0)")).toContainTranslation('breadcrumbs.home');
                expect((this.page.$(".breadcrumbs li:eq(0) a")).attr("href")).toBe("#/");

                expect(this.page.$(".breadcrumbs li:eq(1) .slug")).toContainTranslation('breadcrumbs.search_results');
            });

            it("has the right title", function() {
                expect(this.page.$(".default_content_header h1")).toContainTranslation("search.index.title", {query: "50/50"});
            });

            it("has a 'Show All Results' link", function() {
                expect(this.page.$('.default_content_header .type .title')).toContainTranslation("search.show");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.all");
            });

            it("has filtered result links", function() {
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.workfile");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.hdfs_entry");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.dataset");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.workspace");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.user");
                expect(this.page.$('.default_content_header .type a')).toContainTranslation("search.type.instance");
            });

            describe("filtering by result type", function() {
                beforeEach(function() {
                    spyOn(chorus.router, "navigate");
                    this.page.$('.default_content_header li[data-type="workspace"] a').click();
                });

                it("should navigate to the filtered result type page", function() {
                    expect(this.page.search.entityType()).toBe("workspace");
                    expect(this.page.search.searchIn()).toBe("all");
                    expect(chorus.router.navigate).toHaveBeenCalledWith(this.page.search.showUrl());
                });
            });

            it("has a 'Search in' filter link", function() {
                var searchInMenu = this.page.$(".default_content_header .search_in");
                var searchInOptions = searchInMenu.find(".menu a");
                expect(searchInMenu.find(".chosen")).toContainTranslation("search.in.all");
                expect(searchInMenu.find(".title")).toContainTranslation("search.search_in");
                expect(searchInOptions.length).toBe(2);
                expect(searchInOptions).toContainTranslation("search.in.all");
                expect(searchInOptions).toContainTranslation("search.in.my_workspaces");
            });

            it("navigates to the right page when 'my workspaces' is selected from the 'search in' menu", function() {
                spyOn(chorus.router, "navigate");
                chorus.PageEvents.broadcast("choice:search_in", "my_workspaces");
                expect(this.page.search.entityType()).toBe("all");
                expect(this.page.search.searchIn()).toBe("my_workspaces");
                expect(chorus.router.navigate).toHaveBeenCalledWith(this.page.search.showUrl());
            });

            describe("the workfile section", function() {
                beforeEach(function() {
                    this.workfileLIs = this.page.$(".workfile_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.workfileLIs.length).toBeGreaterThan(0);
                });

                it("selects the first workfile by default", function() {
                    expect(this.workfileLIs.eq(0)).toHaveClass("selected");
                });

                describe("clicking on a workfile search result", function() {
                    beforeEach(function() {
                        this.workfileLIs.eq(3).trigger("click");
                    });

                    it("selects that workfile", function() {
                        expect(this.workfileLIs.eq(3)).toHaveClass("selected");
                    });

                    it("shows that workfile in the sidebar", function() {
                        expect(this.page.sidebar.$(".fileName")).toHaveText("Public");
                    });

                    it("sets the workfile as the selectedItem on the search result", function() {
                        expect(this.page.search.selectedItem).toBe(this.page.search.workfiles().at(3));
                    });
                });
            });

            describe("the workspace section", function() {
                beforeEach(function() {
                    this.workspaceLIs = this.page.$(".workspace_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.workspaceLIs.length).toBeGreaterThan(0);
                });

                describe("clicking on a workspace search result", function() {
                    beforeEach(function() {
                        this.workspaceLIs.eq(1).trigger("click");
                    });

                    it("selects that workspace", function() {
                        expect(this.workspaceLIs.eq(1)).toHaveClass("selected");
                    });

                    it("shows that workspace in the sidebar", function() {
                        expect(this.page.sidebar.$(".info .name")).toHaveText("Private");
                    });

                    it("show the 'add a note' link in the sidebar", function() {
                        expect(this.page.sidebar.$("a[data-dialog='NotesNew']")).toExist();
                    });

                    it("show the 'add an insight' link in the sidebar", function() {
                        expect(this.page.sidebar.$("a[data-dialog='InsightsNew']")).toExist();
                    });
                });
            });

            describe("the dataset section", function() {
                beforeEach(function() {
                    this.datasetLIs = this.page.$(".dataset_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.datasetLIs.length).toBeGreaterThan(0);
                });

                describe("clicking on a tabular data search result", function() {
                    beforeEach(function() {
                        this.datasetLIs.eq(2).trigger("click");
                    });

                    it("selects that tabular data item", function() {
                        expect(this.datasetLIs.eq(2)).toHaveClass("selected");
                    });

                    it("shows the tabular data item in the sidebar", function() {
                        expect(this.page.sidebar.$(".info .name")).toHaveText("typeahead_gpdb_table");
                    });

                    it("shows the associate-with-workspace link in the sidebar", function() {
                        expect(this.page.sidebar.$('a.associate')).toExist();
                    });
                });
            });

            describe("the instance section", function() {
                beforeEach(function() {
                    this.instanceLIs = this.page.$(".instance_list li");
                });

                it("shows a list of search results", function() {
                    expect(this.instanceLIs.length).toBe(3);
                });

                describe("clicking on an instance search result", function() {
                    beforeEach(function() {
                        spyOn(this.page.sidebars.instance, "setInstance");
                        this.instanceLIs.eq(0).trigger("click");
                    });

                    it("selects that instance", function() {
                        expect(this.instanceLIs.eq(0)).toHaveClass("selected");
                    });

                    it("shows the instance in the sidebar", function() {
                        expect($(this.page.sidebar.el)).toHaveClass("instance_list_sidebar");
                        expect(this.page.sidebars.instance.setInstance).toHaveBeenCalledWith(this.page.search.instances().at(0));
                    });
{'fraction_non_alphanumeric': 0.1399124939231891, 'fraction_numerical': 0.002722411278561011, 'mean_word_length': 1.8117823947512302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1684508', 'n_tokens_mistral': 5283, 'n_tokens_neox': 4955, 'n_words': 833}