Merge pull request #10455 from edx/search/optimization
Search performance (SOL-1030, SOL-1031)
This commit is contained in:
@@ -29,7 +29,7 @@ class CoursewareSearchPage(CoursePage):
|
||||
def search(self):
|
||||
""" execute the search """
|
||||
self.q(css=self.search_bar_selector + ' [type="submit"]').click()
|
||||
self.wait_for_element_visibility('.search-info', 'Search results are shown')
|
||||
self.wait_for_ajax()
|
||||
|
||||
def search_for_term(self, text):
|
||||
"""
|
||||
|
||||
@@ -30,8 +30,6 @@ class CoursewareSearchCohortTest(ContainerBase):
|
||||
"""
|
||||
Test courseware search.
|
||||
"""
|
||||
USERNAME = 'STUDENT_TESTER'
|
||||
EMAIL = 'student101@example.com'
|
||||
|
||||
TEST_INDEX_FILENAME = "test_root/index_file.dat"
|
||||
|
||||
@@ -71,6 +69,14 @@ class CoursewareSearchCohortTest(ContainerBase):
|
||||
self.browser, username=self.cohort_b_student_username, email=self.cohort_b_student_email, no_login=True
|
||||
).visit()
|
||||
|
||||
# Create a student who will end up in the default cohort group
|
||||
self.cohort_default_student_username = "cohort_default_student"
|
||||
self.cohort_default_student_email = "cohort_default_student@example.com"
|
||||
StudioAutoAuthPage(
|
||||
self.browser, username=self.cohort_default_student_username,
|
||||
email=self.cohort_default_student_email, no_login=True
|
||||
).visit()
|
||||
|
||||
self.courseware_search_page = CoursewareSearchPage(self.browser, self.course_id)
|
||||
|
||||
# Enable Cohorting and assign cohorts and content groups
|
||||
@@ -183,6 +189,7 @@ class CoursewareSearchCohortTest(ContainerBase):
|
||||
set_visibility(1, self.content_group_a)
|
||||
set_visibility(2, self.content_group_b)
|
||||
set_visibility(3, self.content_group_a, self.content_group_b)
|
||||
set_visibility(4, 'All Students and Staff') # Does not work without this
|
||||
|
||||
container_page.publish_action.click()
|
||||
|
||||
@@ -213,7 +220,7 @@ class CoursewareSearchCohortTest(ContainerBase):
|
||||
"""
|
||||
Make sure that the page is accessible.
|
||||
"""
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self._auto_auth(self.cohort_default_student_username, self.cohort_default_student_email, False)
|
||||
self.courseware_search_page.visit()
|
||||
|
||||
def test_cohorted_search_user_a_a_content(self):
|
||||
@@ -234,20 +241,20 @@ class CoursewareSearchCohortTest(ContainerBase):
|
||||
self.courseware_search_page.search_for_term(self.group_a_html)
|
||||
assert self.group_a_html not in self.courseware_search_page.search_results.html[0]
|
||||
|
||||
def test_cohorted_search_user_c_ab_content(self):
|
||||
def test_cohorted_search_user_default_ab_content(self):
|
||||
"""
|
||||
Test user not enrolled in any cohorts can't see any of restricted content.
|
||||
"""
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self._auto_auth(self.cohort_default_student_username, self.cohort_default_student_email, False)
|
||||
self.courseware_search_page.visit()
|
||||
self.courseware_search_page.search_for_term(self.group_a_and_b_html)
|
||||
assert self.group_a_and_b_html not in self.courseware_search_page.search_results.html[0]
|
||||
|
||||
def test_cohorted_search_user_c_all_content(self):
|
||||
def test_cohorted_search_user_default_all_content(self):
|
||||
"""
|
||||
Test user can search public content if cohorts used on course.
|
||||
"""
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self._auto_auth(self.cohort_default_student_username, self.cohort_default_student_email, False)
|
||||
self.courseware_search_page.visit()
|
||||
self.courseware_search_page.search_for_term(self.visible_to_all_html)
|
||||
assert self.visible_to_all_html in self.courseware_search_page.search_results.html[0]
|
||||
|
||||
@@ -52,7 +52,7 @@ class SplitTestCoursewareSearchTest(ContainerBase):
|
||||
self.course_info['run']
|
||||
)
|
||||
|
||||
self._add_and_configure_split_test()
|
||||
self._create_group_configuration()
|
||||
self._studio_reindex()
|
||||
|
||||
def _auto_auth(self, username, email, staff):
|
||||
@@ -72,41 +72,24 @@ class SplitTestCoursewareSearchTest(ContainerBase):
|
||||
self.course_outline.start_reindex()
|
||||
self.course_outline.wait_for_ajax()
|
||||
|
||||
def _add_and_configure_split_test(self):
|
||||
def _create_group_configuration(self):
|
||||
"""
|
||||
Add a split test and a configuration to a test course fixture
|
||||
Create a group configuration for course
|
||||
"""
|
||||
# Create a new group configurations
|
||||
# pylint: disable=W0212
|
||||
# pylint: disable=protected-access
|
||||
self.course_fixture._update_xblock(self.course_fixture._course_location, {
|
||||
"metadata": {
|
||||
u"user_partitions": [
|
||||
create_user_partition_json(
|
||||
0,
|
||||
"Name",
|
||||
"Description.",
|
||||
"Configuration A/B",
|
||||
"Content Group Partition.",
|
||||
[Group("0", "Group A"), Group("1", "Group B")]
|
||||
),
|
||||
create_user_partition_json(
|
||||
456,
|
||||
"Name 2",
|
||||
"Description 2.",
|
||||
[Group("2", "Group C"), Group("3", "Group D")]
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
# Add a split test module to the 'Test Unit' vertical in the course tree
|
||||
split_test_1 = XBlockFixtureDesc('split_test', 'Test Content Experiment 1', metadata={'user_partition_id': 0})
|
||||
split_test_1_parent_vertical = self.course_fixture.get_nested_xblocks(category="vertical")[1]
|
||||
self.course_fixture.create_xblock(split_test_1_parent_vertical.locator, split_test_1)
|
||||
|
||||
# Add a split test module to the 'Test 2 Unit' vertical in the course tree
|
||||
split_test_2 = XBlockFixtureDesc('split_test', 'Test Content Experiment 2', metadata={'user_partition_id': 456})
|
||||
split_test_2_parent_vertical = self.course_fixture.get_nested_xblocks(category="vertical")[2]
|
||||
self.course_fixture.create_xblock(split_test_2_parent_vertical.locator, split_test_2)
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
"""
|
||||
Populate the children of the test course fixture.
|
||||
@@ -116,28 +99,26 @@ class SplitTestCoursewareSearchTest(ContainerBase):
|
||||
})
|
||||
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Content Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Content Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Content Unit').add_children(
|
||||
XBlockFixtureDesc('html', 'VISIBLETOALLCONTENT', data='<html>VISIBLETOALLCONTENT</html>')
|
||||
)
|
||||
)
|
||||
),
|
||||
XBlockFixtureDesc('chapter', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit')
|
||||
XBlockFixtureDesc('vertical', 'Test Unit').add_children(
|
||||
XBlockFixtureDesc(
|
||||
'html',
|
||||
'VISIBLE TO A',
|
||||
data='<html>VISIBLE TO A</html>',
|
||||
metadata={"group_access": {0: [0]}}
|
||||
),
|
||||
XBlockFixtureDesc(
|
||||
'html',
|
||||
'VISIBLE TO B',
|
||||
data='<html>VISIBLE TO B</html>',
|
||||
metadata={"group_access": {0: [1]}}
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
XBlockFixtureDesc('chapter', 'X Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'X Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'X Unit')
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
self.test_1_breadcrumb = "Test Section \xe2\x96\xb8 Test Subsection \xe2\x96\xb8 Test Unit".decode("utf-8")
|
||||
self.test_2_breadcrumb = "X Section \xe2\x96\xb8 X Subsection \xe2\x96\xb8 X Unit".decode("utf-8")
|
||||
|
||||
def test_page_existence(self):
|
||||
"""
|
||||
Make sure that the page is accessible.
|
||||
@@ -145,15 +126,6 @@ class SplitTestCoursewareSearchTest(ContainerBase):
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self.courseware_search_page.visit()
|
||||
|
||||
def test_search_for_experiment_content_user_not_assigned(self):
|
||||
"""
|
||||
Test user can't search for experiment content if not assigned to a group.
|
||||
"""
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self.courseware_search_page.visit()
|
||||
self.courseware_search_page.search_for_term("Group")
|
||||
assert "Sorry, no results were found." in self.courseware_search_page.search_results.html[0]
|
||||
|
||||
def test_search_for_experiment_content_user_assigned_to_one_group(self):
|
||||
"""
|
||||
Test user can search for experiment content restricted to his group
|
||||
@@ -161,8 +133,5 @@ class SplitTestCoursewareSearchTest(ContainerBase):
|
||||
"""
|
||||
self._auto_auth(self.USERNAME, self.EMAIL, False)
|
||||
self.courseware_search_page.visit()
|
||||
self.course_navigation_page.go_to_section("Test Section", "Test Subsection")
|
||||
self.courseware_search_page.search_for_term("Group")
|
||||
self.courseware_search_page.search_for_term("VISIBLE TO")
|
||||
assert "1 result" in self.courseware_search_page.search_results.html[0]
|
||||
assert self.test_1_breadcrumb in self.courseware_search_page.search_results.html[0]
|
||||
assert self.test_2_breadcrumb not in self.courseware_search_page.search_results.html[0]
|
||||
|
||||
Reference in New Issue
Block a user