def test_studio_help_links(self): """Test that the help links are present and have the correct content.""" page = DashboardPage(self.browser) page.visit() click_studio_help(page) links = studio_help_links(page) expected_links = [{ 'href': u'http://docs.edx.org/', 'text': u'edX Documentation', 'sr_text': u'Access documentation on http://docs.edx.org' }, { 'href': u'https://open.edx.org/', 'text': u'Open edX Portal', 'sr_text': u'Access the Open edX Portal' }, { 'href': u'https://www.edx.org/course/overview-creating-edx-course-edx-edx101#.VO4eaLPF-n1', 'text': u'Enroll in edX101', 'sr_text': u'Enroll in edX101: Overview of Creating an edX Course' }, { 'href': u'https://www.edx.org/course/creating-course-edx-studio-edx-studiox', 'text': u'Enroll in StudioX', 'sr_text': u'Enroll in StudioX: Creating a Course with edX Studio' }, { 'href': u'mailto:[email protected]', 'text': u'Contact Us', 'sr_text': 'Send an email to [email protected]' }] for expected, actual in zip(expected_links, links): self.assertEqual(expected['href'], actual.get_attribute('href')) self.assertEqual(expected['text'], actual.text) self.assertEqual( expected['sr_text'], actual.find_element_by_xpath('following-sibling::span').text )
def test_studio_help_links(self): """Test that the help links are present and have the correct content.""" page = DashboardPage(self.browser) page.visit() click_studio_help(page) links = studio_help_links(page) expected_links = [ { "href": u"http://docs.edx.org/", "text": u"edX Documentation", "sr_text": u"Access documentation on http://docs.edx.org", }, {"href": u"https://open.edx.org/", "text": u"Open edX Portal", "sr_text": u"Access the Open edX Portal"}, { "href": u"https://www.edx.org/course/overview-creating-edx-course-edx-edx101#.VO4eaLPF-n1", "text": u"Enroll in edX101", "sr_text": u"Enroll in edX101: Overview of Creating an edX Course", }, { "href": u"https://www.edx.org/course/creating-course-edx-studio-edx-studiox", "text": u"Enroll in StudioX", "sr_text": u"Enroll in StudioX: Creating a Course with edX Studio", }, { "href": u"mailto:[email protected]", "text": u"Contact Us", "sr_text": "Send an email to [email protected]", }, ] for expected, actual in zip(expected_links, links): self.assertEqual(expected["href"], actual.get_attribute("href")) self.assertEqual(expected["text"], actual.text) self.assertEqual(expected["sr_text"], actual.find_element_by_xpath("following-sibling::span").text)
class LibraryTabHelpTest(AcceptanceTest): """ Test help links on the library tab present at dashboard. """ def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() def test_library_tab_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page. Given that I am on the 'Home'(Courses tab) page. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ self.assertTrue(self.dashboard_page.has_new_library_button) click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False) expected_url = _get_expected_documentation_url( '/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=expected_url)
class StudioLanguageTest(AcceptanceTest): """ Test suite for the Studio Language """ shard = 21 def setUp(self): super(StudioLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit() def test_studio_language_change(self): """ Scenario: Ensure that language selection is working fine. First I go to the user dashboard page in studio. I can see 'English' is selected by default. Then I choose 'Dummy Language' from drop down (at top of the page). Then I visit the student account settings page and I can see the language has been updated to 'Dummy Language' in both drop downs. """ dummy_language = u'Dummy Language (Esperanto)' self.dashboard_page.visit() language_selector = self.dashboard_page.language_selector self.assertEqual(get_selected_option_text(language_selector), u'English') select_option_by_text(language_selector, dummy_language) self.dashboard_page.wait_for_ajax() self.account_settings.visit() self.assertEqual( self.account_settings.value_for_dropdown_field('pref-lang'), dummy_language) self.assertEqual(get_selected_option_text(language_selector), u'Dummy Language (Esperanto)')
def test_studio_help_links(self): """Test that the help links are present and have the correct content.""" page = DashboardPage(self.browser) page.visit() click_studio_help(page) links = studio_help_links(page) expected_links = [{ 'href': u'http://docs.edx.org/', 'text': u'edX Documentation', 'sr_text': u'Access documentation on http://docs.edx.org' }, { 'href': u'https://open.edx.org/', 'text': u'Open edX Portal', 'sr_text': u'Access the Open edX Portal' }, { 'href': u'https://www.edx.org/course/overview-creating-edx-course-edx-edx101#.VO4eaLPF-n1', 'text': u'Enroll in edX101', 'sr_text': u'Enroll in edX101: Overview of Creating an edX Course' }, { 'href': u'https://www.edx.org/course/creating-course-edx-studio-edx-studiox', 'text': u'Enroll in StudioX', 'sr_text': u'Enroll in StudioX: Creating a Course with edX Studio' }, { 'href': u'mailto:[email protected]', 'text': u'Contact Us', 'sr_text': 'Send an email to [email protected]' }] for expected, actual in zip(expected_links, links): self.assertEqual(expected['href'], actual.get_attribute('href')) self.assertEqual(expected['text'], actual.text) self.assertEqual( expected['sr_text'], actual.find_element_by_xpath('following-sibling::span').text )
class LibraryTabHelpTest(AcceptanceTest): """ Test help links on the library tab present at dashboard. """ def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() def test_library_tab_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page. Given that I am on the 'Home'(Courses tab) page. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should end with 'getting_started/get_started.html' """ self.assertTrue(self.dashboard_page.has_new_library_button) click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False) # The href we want to see in anchor help element. href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/' \ 'en/open-release-ficus.master/getting_started/get_started.html' # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=href )
class LibraryTabHelpTest(AcceptanceTest): """ Test help links on the library tab present at dashboard. """ def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() def test_library_tab_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page. Given that I am on the 'Home'(Courses tab) page. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should end with 'getting_started/get_started.html' """ self.assertTrue(self.dashboard_page.has_new_library_button) click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False) # The href we want to see in anchor help element. href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/' \ 'en/latest/getting_started/get_started.html' # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=href)
class LibraryTabHelpTest(AcceptanceTest): """ Test help links on the library tab present at dashboard. """ def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() def test_library_tab_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page. Given that I am on the 'Home'(Courses tab) page. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ self.assertTrue(self.dashboard_page.has_new_library_button) click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False) expected_url = _get_expected_documentation_url('/get_started.html') # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=expected_url )
class StudioLanguageTest(AcceptanceTest): """ Test suite for the Studio Language """ def setUp(self): super(StudioLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit() def test_studio_language_change(self): """ Scenario: Ensure that language selection is working fine. First I go to the user dashboard page in studio. I can see 'English' is selected by default. Then I choose 'Dummy Language' from drop down (at top of the page). Then I visit the student account settings page and I can see the language has been updated to 'Dummy Language' in both drop downs. """ dummy_language = u'Dummy Language (Esperanto)' self.dashboard_page.visit() language_selector = self.dashboard_page.language_selector self.assertEqual( get_selected_option_text(language_selector), u'English' ) select_option_by_text(language_selector, dummy_language) self.dashboard_page.wait_for_ajax() self.account_settings.visit() self.assertEqual(self.account_settings.value_for_dropdown_field('pref-lang'), dummy_language) self.assertEqual( get_selected_option_text(language_selector), u'Dummy Language (Esperanto)' )
def test_page_redirect(self): """ /course/ is the base URL for all courses, but by itself, it should redirect to /home/. """ self.dashboard_page = DashboardPage(self.browser) # pylint: disable=attribute-defined-outside-init self.dashboard_page.visit() self.assertEqual(self.browser.current_url.strip('/').rsplit('/')[-1], 'home')
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser)
def setUp(self): super(NewCourseHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button()
def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library()
class CoursePagesTest(StudioCourseTest): """ Tests that verify the pages in Studio that you can get to when logged in and have a course. """ COURSE_ID_SEPARATOR = "." def setUp(self): """ Install a course with no content using a fixture. """ super(CoursePagesTest, self).setUp() self.pages = [ clz(self.browser, self.course_info["org"], self.course_info["number"], self.course_info["run"]) for clz in [ AssetIndexPage, CourseUpdatesPage, PagesPage, ExportCoursePage, ImportCoursePage, CourseTeamPage, CourseOutlinePage, SettingsPage, AdvancedSettingsPage, GradingPage, TextbookUploadPage, ] ] def test_page_redirect(self): """ /course/ is the base URL for all courses, but by itself, it should redirect to /home/. """ self.dashboard_page = DashboardPage(self.browser) # pylint: disable=attribute-defined-outside-init self.dashboard_page.visit() self.assertEqual(self.browser.current_url.strip("/").rsplit("/")[-1], "home") def test_page_existence(self): """ Make sure that all these pages are accessible once you have a course. Rather than fire up the browser just to check each url, do them all sequentially in this testcase. """ # In the real workflow you will be at the dashboard page # after you log in. This test was intermittently failing on the # first (asset) page load with a 404. # Not exactly sure why, so adding in a visit # to the dashboard page here to replicate the usual flow. self.dashboard_page = DashboardPage(self.browser) self.dashboard_page.visit() # Verify that each page is available for page in self.pages: page.visit()
class NewLibraryHelpTest(AcceptanceTest): """ Test help links while creating a new library """ def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library() def test_library_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should end with 'getting_started/get_started.html' """ # The href we want to see in anchor help element. href = ( "http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/" "en/latest/getting_started/get_started.html" ) # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=href) def test_library_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Getting Started with edX Studio' in the sidebar links Then Help link should open. And help url should end with 'getting_started/get_started.html' """ # The href we want to see in anchor help element. href = ( "http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/" "en/latest/getting_started/get_started.html" ) # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=href, help_text="Getting Started with edX Studio", as_list_item=True, )
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2"
class CoursePagesTest(StudioCourseTest): """ Tests that verify the pages in Studio that you can get to when logged in and have a course. """ shard = 21 COURSE_ID_SEPARATOR = "." def setUp(self): """ Install a course with no content using a fixture. """ super(CoursePagesTest, self).setUp() self.pages = [ clz(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) for clz in [ AssetIndexPageStudioFrontend, CourseUpdatesPage, PagesPage, ExportCoursePage, ImportCoursePage, CourseTeamPage, CourseOutlinePage, SettingsPage, AdvancedSettingsPage, GradingPage, TextbookUploadPage ] ] def test_page_redirect(self): """ /course/ is the base URL for all courses, but by itself, it should redirect to /home/. """ self.dashboard_page = DashboardPage(self.browser) # pylint: disable=attribute-defined-outside-init self.dashboard_page.visit() self.assertEqual( self.browser.current_url.strip('/').rsplit('/')[-1], 'home') def test_page_existence(self): """ Make sure that all these pages are accessible once you have a course. Rather than fire up the browser just to check each url, do them all sequentially in this testcase. """ # In the real workflow you will be at the dashboard page # after you log in. This test was intermittently failing on the # first (asset) page load with a 404. # Not exactly sure why, so adding in a visit # to the dashboard page here to replicate the usual flow. self.dashboard_page = DashboardPage(self.browser) self.dashboard_page.visit() # Verify that each page is available for page in self.pages: page.visit()
def setUp(self, is_staff=False): """ Install a course with no content using a fixture. """ super(CourseTeamPageTest, self).setUp(is_staff) self.other_user = self._make_user('other') self.dashboard_page = DashboardPage(self.browser) self.page = CourseTeamPage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self._go_to_course_team_page()
class NewLibraryHelpTest(AcceptanceTest): """ Test help links while creating a new library """ def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library() @skip( "Disabled as edx.org help links are now different than Open edX (@catong can advise)" ) def test_library_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/get_started.html') # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=expected_url) @skip( "Disabled as edx.org help links are now different than Open edX (@catong can advise)" ) def test_library_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Getting Started with edX Studio' in the sidebar links Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/get_started.html') # Assert that help link is correct. assert_side_bar_help_link(test=self, page=self.dashboard_page, href=expected_url, help_text='Getting Started with edX Studio', as_list_item=True)
class NewLibraryHelpTest(AcceptanceTest): """ Test help links while creating a new library """ def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library() def test_library_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/get_started.html') # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=expected_url ) def test_library_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Getting Started with edX Studio' in the sidebar links Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/get_started.html') # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=expected_url, help_text='Getting Started with edX Studio', as_list_item=True )
class NewCourseHelpTest(AcceptanceTest): """ Test help links while creating a new course. """ def setUp(self): super(NewCourseHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() def test_course_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Course' page in the dashboard. Given that I am on the 'Create a New Course' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=expected_url ) def test_course_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Course' page in the dashboard. Given that I am on the 'Create a New Course' page in the dashboard. And I want help about the process And I click the 'Getting Started with edX Studio' in the sidebar links Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=expected_url, help_text='Getting Started with edX Studio', as_list_item=True )
class NewLibraryHelpTest(AcceptanceTest): """ Test help links while creating a new library """ def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library() def test_library_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should end with 'getting_started/get_started.html' """ # The href we want to see in anchor help element. href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/' \ 'en/open-release-ficus.master/getting_started/get_started.html' # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=href) def test_library_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Getting Started with Edraak Studio' in the sidebar links Then Help link should open. And help url should end with 'getting_started/get_started.html' """ # The href we want to see in anchor help element. href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/' \ 'en/open-release-ficus.master/getting_started/get_started.html' # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=href, help_text='Getting Started with Edraak Studio', as_list_item=True)
def setUp(self, is_staff=True, test_xss=False): """ Load the helper for the home page (dashboard page) """ super(ArchivedCourseTest, self).setUp(is_staff=is_staff, test_xss=test_xss) self.dashboard_page = DashboardPage(self.browser)
class LoggedInPagesTest(AcceptanceTest): """ Verify the pages in Studio that you can get to when logged in and do not have a course yet. """ def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser) def test_logged_in_no_courses(self): """ Make sure that you can get to the dashboard and home pages without a course. """ self.auth_page.visit() self.dashboard_page.visit() self.home_page.visit()
class LoggedInPagesTest(AcceptanceTest): """ Verify the pages in Studio that you can get to when logged in and do not have a course yet. """ def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser) def test_logged_in_no_courses(self): """ Make sure that you can get to the dashboard and home pages without a course. """ self.auth_page.visit() self.dashboard_page.visit() self.home_page.visit()
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser)
def setUp(self): super(NewCourseHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button()
def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library()
def test_page_redirect(self): """ /course/ is the base URL for all courses, but by itself, it should redirect to /home/. """ self.dashboard_page = DashboardPage(self.browser) # pylint: disable=attribute-defined-outside-init self.dashboard_page.visit() self.assertEqual(self.browser.current_url.strip('/').rsplit('/')[-1], 'home')
def test_page_existence(self): """ Make sure that all these pages are accessible once you have a course. Rather than fire up the browser just to check each url, do them all sequentially in this testcase. """ # In the real workflow you will be at the dashboard page # after you log in. This test was intermittently failing on the # first (asset) page load with a 404. # Not exactly sure why, so adding in a visit # to the dashboard page here to replicate the usual flow. self.dashboard_page = DashboardPage(self.browser) self.dashboard_page.visit() # Verify that each page is available for page in self.pages: page.visit()
def setUp(self, is_staff=False): """ Install a course with no content using a fixture. """ super(CourseTeamPageTest, self).setUp(is_staff) self.other_user = self._make_user('other') self.dashboard_page = DashboardPage(self.browser) self.page = CourseTeamPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self._go_to_course_team_page()
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2"
class ArchivedCourseTest(StudioCourseTest): """ Tests that archived courses appear in their own list. """ def setUp(self, is_staff=True, test_xss=False): """ Load the helper for the home page (dashboard page) """ super(ArchivedCourseTest, self).setUp(is_staff=is_staff, test_xss=test_xss) self.dashboard_page = DashboardPage(self.browser) def populate_course_fixture(self, course_fixture): current_time = datetime.datetime.now() course_start_date = current_time - datetime.timedelta(days=60) course_end_date = current_time - datetime.timedelta(days=90) course_fixture.add_course_details({ 'start_date': course_start_date, 'end_date': course_end_date }) def test_archived_course(self): """ Scenario: Ensure that an archived course displays in its own list and can be clicked on. """ self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_course( org=self.course_info['org'], number=self.course_info['number'], run=self.course_info['run'], archived=True )) # Click on the archived course and make sure that the Studio course outline appears. self.dashboard_page.click_course_run(self.course_info['run']) course_outline_page = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) course_outline_page.wait_for_page()
def test_page_existence(self): """ Make sure that all these pages are accessible once you have a course. Rather than fire up the browser just to check each url, do them all sequentially in this testcase. """ # In the real workflow you will be at the dashboard page # after you log in. This test was intermittently failing on the # first (asset) page load with a 404. # Not exactly sure why, so adding in a visit # to the dashboard page here to replicate the usual flow. self.dashboard_page = DashboardPage(self.browser) self.dashboard_page.visit() # Verify that each page is available for page in self.pages: page.visit()
def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser)
def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser)
class CourseRerunTest(StudioCourseTest): """ Feature: Courses can be rerun """ __test__ = True SECTION_NAME = 'Rerun Section' SUBSECITON_NAME = 'Rerun Subsection' UNIT_NAME = 'Rerun Unit' COMPONENT_NAME = 'Rerun Component' COMPONENT_CONTENT = 'Test Content' def setUp(self): """ Login as global staff because that's the only way to rerun a course. """ super(CourseRerunTest, self).setUp(is_staff=True) self.dashboard_page = DashboardPage(self.browser) def populate_course_fixture(self, course_fixture): """ Create a sample course with one section, one subsection, one unit, and one component. """ course_fixture.add_children( XBlockFixtureDesc('chapter', self.SECTION_NAME).add_children( XBlockFixtureDesc('sequential', self.SUBSECITON_NAME).add_children( XBlockFixtureDesc('vertical', self.UNIT_NAME).add_children( XBlockFixtureDesc('html', self.COMPONENT_NAME, self.COMPONENT_CONTENT) ) ) ) ) def test_course_rerun(self): """ Scenario: Courses can be rerun Given I have a course with a section, subsesction, vertical, and html component with content 'Test Content' When I visit the course rerun page And I type 'test_rerun' in the course run field And I click Create Rerun And I visit the course listing page And I wait for all courses to finish processing And I click on the course with run 'test_rerun' Then I see a rerun notification on the course outline page And when I click 'Dismiss' on the notification Then I do not see a rerun notification And when I expand the subsection and click on the unit And I click 'View Live Version' Then I see one html component with the content 'Test Content' """ course_info = (self.course_info['org'], self.course_info['number'], self.course_info['run']) updated_course_info = course_info[0] + "+" + course_info[1] + "+" + course_info[2] self.dashboard_page.visit() self.dashboard_page.create_rerun(updated_course_info) rerun_page = CourseRerunPage(self.browser, *course_info) rerun_page.wait_for_page() course_run = 'test_rerun_' + str(random.randrange(1000000, 9999999)) rerun_page.course_run = course_run rerun_page.create_rerun() def finished_processing(): self.dashboard_page.visit() return not self.dashboard_page.has_processing_courses EmptyPromise(finished_processing, "Rerun finished processing", try_interval=5, timeout=60).fulfill() assert_in(course_run, self.dashboard_page.course_runs) self.dashboard_page.click_course_run(course_run) outline_page = CourseOutlinePage(self.browser, *course_info) outline_page.wait_for_page() self.assertTrue(outline_page.has_rerun_notification) outline_page.dismiss_rerun_notification() EmptyPromise(lambda: not outline_page.has_rerun_notification, "Rerun notification dismissed").fulfill() subsection = outline_page.section(self.SECTION_NAME).subsection(self.SUBSECITON_NAME) subsection.expand_subsection() unit_page = subsection.unit(self.UNIT_NAME).go_to() unit_page.view_published_version() courseware = CoursewarePage(self.browser, self.course_id) courseware.wait_for_page() self.assertEqual(courseware.num_xblock_components, 1) self.assertEqual(courseware.xblock_component_html_content(), self.COMPONENT_CONTENT)
def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit()
def setUp(self): """ Login as global staff because that's the only way to rerun a course. """ super(CourseRerunTest, self).setUp(is_staff=True) self.dashboard_page = DashboardPage(self.browser)
def setUp(self): super(StudioLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit()
class CreateLibraryTest(AcceptanceTest): """ Test that we can create a new content library on the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) def test_create_library(self): """ From the home page: Click "New Library" Fill out the form Submit the form We should be redirected to the edit view for the library Return to the home page The newly created library should now appear in the list of libraries """ unique_suffix = uuid4().hex[:4] name = "New Library Name " + unique_suffix org = "TestOrgX" + unique_suffix number = "TESTLIB_" + unique_suffix self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_library(name=name, org=org, number=number)) self.assertTrue(self.dashboard_page.has_new_library_button()) self.dashboard_page.click_new_library() self.assertTrue(self.dashboard_page.is_new_library_form_visible()) self.dashboard_page.fill_new_library_form(name, org, number) self.assertTrue(self.dashboard_page.is_new_library_form_valid()) self.dashboard_page.submit_new_library_form() # The next page is the library edit view; make sure it loads: lib_page = LibraryEditPage(self.browser, LibraryLocator(org, number)) lib_page.wait_for_page() # Then go back to the home page and make sure the new library is listed there: self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_library(name=name, org=org, number=number))
class CreateLibraryTest(AcceptanceTest): """ Test that we can create a new content library on the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) def test_create_library(self): """ From the home page: Click "New Library" Fill out the form Submit the form We should be redirected to the edit view for the library Return to the home page The newly created library should now appear in the list of libraries """ unique_suffix = uuid4().hex[:4] name = "New Library Name " + unique_suffix org = "TestOrgX" + unique_suffix number = "TESTLIB_" + unique_suffix self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_library(name=name, org=org, number=number)) self.assertTrue(self.dashboard_page.has_new_library_button()) self.dashboard_page.click_new_library() self.assertTrue(self.dashboard_page.is_new_library_form_visible()) self.dashboard_page.fill_new_library_form(name, org, number) self.assertTrue(self.dashboard_page.is_new_library_form_valid()) self.dashboard_page.submit_new_library_form() # The next page is the library edit view; make sure it loads: lib_page = LibraryEditPage(self.browser, LibraryLocator(org, number)) lib_page.wait_for_page() # Then go back to the home page and make sure the new library is listed there: self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_library(name=name, org=org, number=number))
class CreateCourseTest(WebAppTest): """ Test that we can create a new course the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2" def test_create_course_with_non_existing_org(self): """ Scenario: Ensure that the course creation with non existing org display proper error message. Given I have filled course creation form with a non existing and all required fields When I click 'Create' button Form validation should pass Then I see the error message explaining reason for failure to create course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_course(org='testOrg', number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, 'testOrg', self.course_number, self.course_run) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() self.assertTrue(self.dashboard_page.error_notification.present) self.assertIn( u'Organization you selected does not exist in the system', self.dashboard_page.error_notification_message) def test_create_course_with_existing_org(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, self.course_org, self.course_number, self.course_run) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage(self.browser, self.course_org, self.course_number, self.course_run) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run)) def test_create_course_with_existing_org_via_autocomplete(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields And I selected `Course Organization` input via autocomplete When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() new_org = 'orgX2' self.assertFalse( self.dashboard_page.has_course(org=new_org, number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, '', self.course_number, self.course_run) self.dashboard_page.course_org_field.fill('org') self.dashboard_page.select_item_in_autocomplete_widget(new_org) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage(self.browser, new_org, self.course_number, self.course_run) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_course(org=new_org, number=self.course_number, run=self.course_run))
class CourseTeamPageTest(StudioCourseTest): """ As a course author, I want to be able to add others to my team """ def _make_user(self, username): """ Registers user and returns user representation dictionary as expected by `log_in` function """ user = { 'username': username, 'email': username + "@example.com", 'password': username + '123' } AutoAuthPage( self.browser, no_login=True, username=user.get('username'), email=user.get('email'), password=user.get('password') ).visit() return user def setUp(self, is_staff=False): """ Install a course with no content using a fixture. """ super(CourseTeamPageTest, self).setUp(is_staff) self.other_user = self._make_user('other') self.dashboard_page = DashboardPage(self.browser) self.page = CourseTeamPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self._go_to_course_team_page() def _go_to_course_team_page(self): """ Opens Course Team page """ self.page.visit() self.page.wait_until_no_loading_indicator() def _refresh_page(self): """ Reload the page. """ self.page = CourseTeamPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self._go_to_course_team_page() def _assert_current_course(self, visible=True): """ Checks if current course is accessible to current user """ self.dashboard_page.visit() courses = self.dashboard_page.list_courses() def check_course_equality(course1, course2): """ Compares to course dictionaries using org, number and run as keys""" return ( course1['org'] == course2['display_organization'] and course1['number'] == course2['display_coursenumber'] and course1['run'] == course2['run'] ) actual_visible = any((check_course_equality(course, self.course_info) for course in courses)) self.assertEqual(actual_visible, visible) def _assert_user_present(self, user, present=True): """ Checks if specified user present on Course Team page """ if present: self.page.wait_for( lambda: user.get('username') in self.page.usernames, description="Wait for user to be present" ) else: self.page.wait_for( lambda: user.get('username') not in self.page.usernames, description="Wait for user to be absent" ) def _should_see_dialog(self, dialog_type, dialog_message): """ Asserts dialog with specified message is shown """ self.page.modal_dialog_visible(dialog_type) self.assertIn(dialog_message, self.page.modal_dialog_text(dialog_type)) def _assert_is_staff(self, user, can_manage=True): """ Checks if user have staff permissions, can be promoted and can't be demoted """ self.assertIn("staff", user.role_label.lower()) if can_manage: self.assertTrue(user.can_promote) self.assertFalse(user.can_demote) self.assertIn("Add Admin Access", user.promote_button_text) def _assert_is_admin(self, user): """ Checks if user have admin permissions, can't be promoted and can be demoted """ self.assertIn("admin", user.role_label.lower()) self.assertFalse(user.can_promote) self.assertTrue(user.can_demote) self.assertIn("Remove Admin Access", user.demote_button_text) def _assert_can_manage_users(self): """ Checks if current user can manage course team """ self.assertTrue(self.page.has_add_button) for user in self.page.users: self.assertTrue(user.can_promote or user.can_demote) # depending on actual user role self.assertTrue(user.can_delete) def _assert_can_not_manage_users(self): """ Checks if current user can't manage course team """ self.assertFalse(self.page.has_add_button) for user in self.page.users: self.assertFalse(user.can_promote) self.assertFalse(user.can_demote) self.assertFalse(user.can_delete) def test_admins_can_add_other_users(self): """ Scenario: Admins can add other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And other user logs in Then he does see the course on her page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.log_in(self.other_user) self._assert_current_course(visible=True) def test_added_users_cannot_add_or_delete_other_users(self): """ Scenario: Added users cannot delete or add other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And other user logs in And he selects the new course And he views the course team settings Then he cannot manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.log_in(self.other_user) self._assert_current_course(visible=True) self._go_to_course_team_page() bob = self.page.get_user(self.other_user.get('email')) self.assertTrue(bob.is_current_user) self.assertFalse(self.page.has_add_button) self._assert_can_not_manage_users() def test_admins_can_delete_other_users(self): """ Scenario: Admins can delete other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And I delete other user from the course team And other user logs in Then he does not see the course on her page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.page.delete_user_from_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=False) self.log_in(self.other_user) self._assert_current_course(visible=False) def test_admins_cannot_add_users_that_do_not_exist(self): """ Scenario: Admins cannot add users that do not exist Given I have opened a new course in Studio And I am viewing the course team settings When I add "dennis" to the course team Then I should see "Could not find user by email address" somewhere on the page """ self.page.add_user_to_course("*****@*****.**") self._should_see_dialog('error', "Could not find user by email address") def test_admins_should_be_able_to_make_other_people_into_admins(self): """ Scenario: Admins should be able to make other people into admins Given I have opened a new course in Studio And I am viewing the course team settings And I add other user to the course team When I make other user a course team admin And other user logs in And he selects the new course And he views the course team settings Then other user should be marked as an admin And he can manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) other.click_promote() self._refresh_page() self._assert_is_admin(other) self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_manage_users() def test_admins_should_be_able_to_remove_other_admins(self): """ Scenario: Admins should be able to remove other admins Given I have opened a new course in Studio And I grant admin rights to other user Then he can add, delete, promote and demote users And I am viewing the course team settings When I remove admin rights from other user And other user logs in And he selects the new course And he views the course team settings Then other user should not be marked as an admin And he cannot manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) # precondition check - frank is an admin and can add/delete/promote/demote users self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_manage_users() self.log_in(self.user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) other.click_demote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_not_manage_users() def test_admins_should_be_able_to_remove_themself_if_other_admin_exists(self): """ Scenario: Admins should be able to give course ownership to someone else Given I have opened a new course in Studio And I am viewing the course team settings And I'm the only course admin Then I cannot delete or demote myself When I add other user to the course team And I make other user a course team admin Then I can delete or demote myself When I delete myself from the course team And I am logged into studio Then I do not see the course on my page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) current = self.page.get_user(self.user.get('email')) self.assertFalse(current.can_demote) self.assertFalse(current.can_delete) self.assertIn("Promote another member to Admin to remove your admin rights", current.no_change_warning_text) other = self.page.get_user(self.other_user.get('email')) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) current = self.page.get_user(self.user.get('email')) self.assertTrue(current.can_demote) self.assertTrue(current.can_delete) current.click_delete() self.log_in(self.user) self._assert_current_course(visible=False) def test_admins_should_be_able_to_give_course_ownership_to_someone_else(self): """ Scenario: Admins should be able to give course ownership to someone else Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And I make other user a course team admin When I remove admin rights from myself Then I should not be marked as an admin And I cannot manage users And I cannot make myself a course team admin When other user logs in And he selects the new course And he views the course team settings And he deletes me from the course team And I am logged into studio Then I do not see the course on my page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) current = self.page.get_user(self.user.get('email')) self.assertFalse(current.can_demote) self.assertFalse(current.can_delete) self.assertIn("Promote another member to Admin to remove your admin rights", current.no_change_warning_text) other = self.page.get_user(self.other_user.get('email')) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) current = self.page.get_user(self.user.get('email')) self.assertTrue(current.can_demote) self.assertTrue(current.can_delete) current.click_demote() self._refresh_page() current = self.page.get_user(self.user.get('email')) self._assert_is_staff(current, can_manage=False) self._assert_can_not_manage_users() self.assertFalse(current.can_promote) self.log_in(self.other_user) self._go_to_course_team_page() current = self.page.get_user(self.user.get('email')) current.click_delete() self._refresh_page() self._assert_user_present(self.user, present=False) self.log_in(self.user) self._assert_current_course(visible=False)
def setUp(self): super(StudioLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit()
class CourseRerunTest(StudioCourseTest): """ Feature: Courses can be rerun """ shard = 21 __test__ = True SECTION_NAME = 'Rerun Section' SUBSECITON_NAME = 'Rerun Subsection' UNIT_NAME = 'Rerun Unit' COMPONENT_NAME = 'Rerun Component' COMPONENT_CONTENT = 'Test Content' def setUp(self): """ Login as global staff because that's the only way to rerun a course. """ super(CourseRerunTest, self).setUp(is_staff=True) self.dashboard_page = DashboardPage(self.browser) def populate_course_fixture(self, course_fixture): """ Create a sample course with one section, one subsection, one unit, and one component. """ course_fixture.add_children( XBlockFixtureDesc('chapter', self.SECTION_NAME).add_children( XBlockFixtureDesc('sequential', self.SUBSECITON_NAME).add_children( XBlockFixtureDesc('vertical', self.UNIT_NAME).add_children( XBlockFixtureDesc('html', self.COMPONENT_NAME, self.COMPONENT_CONTENT) ) ) ) ) def test_course_rerun(self): """ Scenario: Courses can be rerun Given I have a course with a section, subsesction, vertical, and html component with content 'Test Content' When I visit the course rerun page And I type 'test_rerun' in the course run field And I click Create Rerun And I visit the course listing page And I wait for all courses to finish processing And I click on the course with run 'test_rerun' Then I see a rerun notification on the course outline page And when I click 'Dismiss' on the notification Then I do not see a rerun notification And when I expand the subsection and click on the unit And I click 'View Live Version' Then I see one html component with the content 'Test Content' """ course_info = (self.course_info['org'], self.course_info['number'], self.course_info['run']) updated_course_info = course_info[0] + "+" + course_info[1] + "+" + course_info[2] self.dashboard_page.visit() self.dashboard_page.scroll_to_course(course_info[1]) self.dashboard_page.create_rerun(updated_course_info) rerun_page = CourseRerunPage(self.browser, *course_info) rerun_page.wait_for_page() course_run = 'test_rerun_' + str(random.randrange(1000000, 9999999)) rerun_page.course_run = course_run rerun_page.create_rerun() def finished_processing(): self.dashboard_page.visit() return not self.dashboard_page.has_processing_courses EmptyPromise(finished_processing, "Rerun finished processing", try_interval=5, timeout=60).fulfill() assert course_run in self.dashboard_page.course_runs self.dashboard_page.click_course_run(course_run) outline_page = CourseOutlinePage(self.browser, *course_info) outline_page.wait_for_page() self.assertTrue(outline_page.has_rerun_notification) outline_page.dismiss_rerun_notification() EmptyPromise(lambda: not outline_page.has_rerun_notification, "Rerun notification dismissed").fulfill() subsection = outline_page.section(self.SECTION_NAME).subsection(self.SUBSECITON_NAME) subsection.expand_subsection() unit_page = subsection.unit(self.UNIT_NAME).go_to() unit_page.view_published_version() courseware = CoursewarePage(self.browser, self.course_id) courseware.wait_for_page() self.assertEqual(courseware.num_xblock_components, 1) self.assertEqual(courseware.xblock_component_html_content(), self.COMPONENT_CONTENT)
class CreateCourseTest(WebAppTest): """ Test that we can create a new course the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2" def test_create_course_with_non_existing_org(self): """ Scenario: Ensure that the course creation with non existing org display proper error message. Given I have filled course creation form with a non existing and all required fields When I click 'Create' button Form validation should pass Then I see the error message explaining reason for failure to create course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_course( org='testOrg', number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, 'testOrg', self.course_number, self.course_run ) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() self.assertTrue(self.dashboard_page.error_notification.present) self.assertIn( u'Organization you selected does not exist in the system', self.dashboard_page.error_notification_message ) def test_create_course_with_existing_org(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_course( org=self.course_org, number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, self.course_org, self.course_number, self.course_run ) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage( self.browser, self.course_org, self.course_number, self.course_run ) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_course( org=self.course_org, number=self.course_number, run=self.course_run )) def test_create_course_with_existing_org_via_autocomplete(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields And I selected `Course Organization` input via autocomplete When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() new_org = 'orgX2' self.assertFalse(self.dashboard_page.has_course( org=new_org, number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, '', self.course_number, self.course_run ) self.dashboard_page.course_org_field.fill('org') self.dashboard_page.select_item_in_autocomplete_widget(new_org) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage( self.browser, new_org, self.course_number, self.course_run ) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_course( org=new_org, number=self.course_number, run=self.course_run ))
def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit()
class CourseTeamPageTest(StudioCourseTest): """ As a course author, I want to be able to add others to my team """ shard = 2 def _make_user(self, username): """ Registers user and returns user representation dictionary as expected by `log_in` function """ user = { 'username': username, 'email': username + "@example.com", 'password': username + '123$%^' } AutoAuthPage(self.browser, no_login=True, username=user.get('username'), email=user.get('email'), password=user.get('password')).visit() return user def _update_user(self, user_info): """ Update user with provided `user_info` Arguments: `user_info`: dictionary containing values of attributes to be updated """ AutoAuthPage(self.browser, no_login=True, **user_info).visit() def setUp(self, is_staff=False): """ Install a course with no content using a fixture. """ super(CourseTeamPageTest, self).setUp(is_staff) self.other_user = self._make_user('other') self.dashboard_page = DashboardPage(self.browser) self.page = CourseTeamPage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self._go_to_course_team_page() def _go_to_course_team_page(self): """ Opens Course Team page """ self.page.visit() self.page.wait_until_no_loading_indicator() def _refresh_page(self): """ Reload the page. """ self.page = CourseTeamPage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self._go_to_course_team_page() def _assert_current_course(self, visible=True): """ Checks if current course is accessible to current user """ self.dashboard_page.visit() courses = self.dashboard_page.list_courses() def check_course_equality(course1, course2): """ Compares to course dictionaries using org, number and run as keys""" return (course1['org'] == course2['display_organization'] and course1['number'] == course2['display_coursenumber'] and course1['run'] == course2['run']) actual_visible = any((check_course_equality(course, self.course_info) for course in courses)) self.assertEqual(actual_visible, visible) def _assert_user_present(self, user, present=True): """ Checks if specified user present on Course Team page """ if present: self.page.wait_for( lambda: user.get('username') in self.page.usernames, description="Wait for user to be present") else: self.page.wait_for( lambda: user.get('username') not in self.page.usernames, description="Wait for user to be absent") def _should_see_dialog(self, dialog_type, dialog_message): """ Asserts dialog with specified message is shown """ self.page.modal_dialog_visible(dialog_type) self.assertIn(dialog_message, self.page.modal_dialog_text(dialog_type)) def _assert_is_staff(self, user, can_manage=True): """ Checks if user have staff permissions, can be promoted and can't be demoted """ self.assertIn("staff", user.role_label.lower()) if can_manage: self.assertTrue(user.can_promote) self.assertFalse(user.can_demote) self.assertIn("Add Admin Access", user.promote_button_text) def _assert_is_admin(self, user): """ Checks if user have admin permissions, can't be promoted and can be demoted """ self.assertIn("admin", user.role_label.lower()) self.assertFalse(user.can_promote) self.assertTrue(user.can_demote) self.assertIn("Remove Admin Access", user.demote_button_text) def _assert_can_manage_users(self): """ Checks if current user can manage course team """ self.assertTrue(self.page.has_add_button) for user in self.page.users: self.assertTrue( user.can_promote or user.can_demote) # depending on actual user role self.assertTrue(user.can_delete) def _assert_can_not_manage_users(self): """ Checks if current user can't manage course team """ self.assertFalse(self.page.has_add_button) for user in self.page.users: self.assertFalse(user.can_promote) self.assertFalse(user.can_demote) self.assertFalse(user.can_delete) def test_admins_can_add_other_users(self): """ Scenario: Admins can add other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And other user logs in Then he does see the course on her page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.log_in(self.other_user) self._assert_current_course(visible=True) def test_added_users_cannot_add_or_delete_other_users(self): """ Scenario: Added users cannot delete or add other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And other user logs in And he selects the new course And he views the course team settings Then he cannot manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.log_in(self.other_user) self._assert_current_course(visible=True) self._go_to_course_team_page() bob = self.page.get_user(self.other_user.get('email')) self.assertTrue(bob.is_current_user) self.assertFalse(self.page.has_add_button) self._assert_can_not_manage_users() def test_admins_can_delete_other_users(self): """ Scenario: Admins can delete other users Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And I delete other user from the course team And other user logs in Then he does not see the course on her page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) self.page.delete_user_from_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=False) self.log_in(self.other_user) self._assert_current_course(visible=False) def test_admins_can_delete_other_inactive_users(self): """ Scenario: Admins can delete other inactive users Given I have opened a new course in Studio And I am viewing the course team settings. When I add other user to the course team, And then delete that other user from the course team. And other user logs in Then he/she does not see the course on page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) # inactivate user user_info = { 'username': self.other_user.get('username'), 'email': self.other_user.get('email'), 'password': self.other_user.get('password'), 'is_active': False } self._update_user(user_info) # go to course team page to perform delete operation self._go_to_course_team_page() self.page.delete_user_from_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=False) def test_admins_cannot_add_users_that_do_not_exist(self): """ Scenario: Admins cannot add users that do not exist Given I have opened a new course in Studio And I am viewing the course team settings When I add "dennis" to the course team Then I should see "Could not find user by email address" somewhere on the page """ self.page.add_user_to_course("*****@*****.**") self._should_see_dialog('error', "Could not find user by email address") def test_admins_should_be_able_to_make_other_people_into_admins(self): """ Scenario: Admins should be able to make other people into admins Given I have opened a new course in Studio And I am viewing the course team settings And I add other user to the course team When I make other user a course team admin And other user logs in And he selects the new course And he views the course team settings Then other user should be marked as an admin And he can manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) other.click_promote() self._refresh_page() self._assert_is_admin(other) self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_manage_users() def test_admins_should_be_able_to_remove_other_admins(self): """ Scenario: Admins should be able to remove other admins Given I have opened a new course in Studio And I grant admin rights to other user Then he can add, delete, promote and demote users And I am viewing the course team settings When I remove admin rights from other user And other user logs in And he selects the new course And he views the course team settings Then other user should not be marked as an admin And he cannot manage users """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) # precondition check - frank is an admin and can add/delete/promote/demote users self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_manage_users() self.log_in(self.user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) other.click_demote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_staff(other) self.log_in(self.other_user) self._go_to_course_team_page() other = self.page.get_user(self.other_user.get('email')) self.assertTrue(other.is_current_user) self._assert_can_not_manage_users() def test_admins_should_be_able_to_remove_themself_if_other_admin_exists( self): """ Scenario: Admins should be able to give course ownership to someone else Given I have opened a new course in Studio And I am viewing the course team settings And I'm the only course admin Then I cannot delete or demote myself When I add other user to the course team And I make other user a course team admin Then I can delete or demote myself When I delete myself from the course team And I am logged into studio Then I do not see the course on my page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) current = self.page.get_user(self.user.get('email')) self.assertFalse(current.can_demote) self.assertFalse(current.can_delete) self.assertIn( "Promote another member to Admin to remove your admin rights", current.no_change_warning_text) other = self.page.get_user(self.other_user.get('email')) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) current = self.page.get_user(self.user.get('email')) self.assertTrue(current.can_demote) self.assertTrue(current.can_delete) current.click_delete() self.log_in(self.user) self._assert_current_course(visible=False) def test_admins_should_be_able_to_give_course_ownership_to_someone_else( self): """ Scenario: Admins should be able to give course ownership to someone else Given I have opened a new course in Studio And I am viewing the course team settings When I add other user to the course team And I make other user a course team admin When I remove admin rights from myself Then I should not be marked as an admin And I cannot manage users And I cannot make myself a course team admin When other user logs in And he selects the new course And he views the course team settings And he deletes me from the course team And I am logged into studio Then I do not see the course on my page """ self.page.add_user_to_course(self.other_user.get('email')) self._assert_user_present(self.other_user, present=True) current = self.page.get_user(self.user.get('email')) self.assertFalse(current.can_demote) self.assertFalse(current.can_delete) self.assertIn( "Promote another member to Admin to remove your admin rights", current.no_change_warning_text) other = self.page.get_user(self.other_user.get('email')) other.click_promote() self._refresh_page() other = self.page.get_user(self.other_user.get('email')) self._assert_is_admin(other) current = self.page.get_user(self.user.get('email')) self.assertTrue(current.can_demote) self.assertTrue(current.can_delete) current.click_demote() self._refresh_page() current = self.page.get_user(self.user.get('email')) self._assert_is_staff(current, can_manage=False) self._assert_can_not_manage_users() self.assertFalse(current.can_promote) self.log_in(self.other_user) self._go_to_course_team_page() current = self.page.get_user(self.user.get('email')) current.click_delete() self._refresh_page() self._assert_user_present(self.user, present=False) self.log_in(self.user) self._assert_current_course(visible=False)
def setUp(self): """ Login as global staff because that's the only way to rerun a course. """ super(CourseRerunTest, self).setUp(is_staff=True) self.dashboard_page = DashboardPage(self.browser)
class CreateCourseTest(AcceptanceTest): """ Test that we can create a new course the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2" def test_create_course_with_non_existing_org(self): """ Scenario: Ensure that the course creation with non existing org display proper error message. Given I have filled course creation form with a non existing and all required fields When I click 'Create' button Form validation should pass Then I see the error message explaining reason for failure to create course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_course(org='testOrg', number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, 'testOrg', self.course_number, self.course_run) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() self.assertTrue(self.dashboard_page.error_notification.present) self.assertIn( u'Organization you selected does not exist in the system', self.dashboard_page.error_notification_message) def test_create_course_with_existing_org(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, self.course_org, self.course_number, self.course_run) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage(self.browser, self.course_org, self.course_number, self.course_run) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run)) # Click on the course listing and verify that the Studio course outline page opens. self.dashboard_page.click_course_run(self.course_run) course_outline_page.wait_for_page() def test_create_course_with_existing_org_via_autocomplete(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields And I selected `Course Organization` input via autocomplete When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() new_org = 'orgX2' self.assertFalse( self.dashboard_page.has_course(org=new_org, number=self.course_number, run=self.course_run)) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, '', self.course_number, self.course_run) self.dashboard_page.course_org_field.fill('org') self.dashboard_page.select_item_in_autocomplete_widget(new_org) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage(self.browser, new_org, self.course_number, self.course_run) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_course(org=new_org, number=self.course_number, run=self.course_run)) def test_error_appears_with_long_tuple(self): """ Scenario: Ensure that the course creation is not successful with 66 characters long tuple. Given I have filled course creation from with combined length of 66 characters for Organization, course Number and course Run. And I have a valid course name Then form validation should not pass And I see error for combined length longer than 65 """ course_org = "012345678901234567890123456789" course_number = ''.join( random.choice(string.digits) for _ in range(30)) course_run = "0123456" self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(self.course_name, course_org, course_number, course_run) self.assertEqual( self.dashboard_page.course_creation_error_message, 'The combined length of the organization, course number, and course run fields cannot be more than 65 ' 'characters.') self.assertTrue(self.dashboard_page.is_create_button_disabled()) def test_no_error_appears_for_long_course_name(self): """ Scenario: Ensure that the course creation with 66 characters long course name is successful. Given I have filled course creation form with 66 characters long course name. And I have filled remaining form within the allowed characters length. When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ course_name = ''.join( random.choice(string.ascii_uppercase) for _ in range(66)) self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run)) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form(course_name, self.course_org, self.course_number, self.course_run) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage(self.browser, self.course_org, self.course_number, self.course_run) course_outline_page.visit() course_outline_page.wait_for_page() self.dashboard_page.visit() # Assert that course is present on dashboard self.assertTrue( self.dashboard_page.has_course(org=self.course_org, number=self.course_number, run=self.course_run))