class LibraryHelpTest(StudioLibraryTest): """ Test help links on a Library page. """ def setUp(self): super(LibraryHelpTest, self).setUp() self.library_page = LibraryPage(self.browser, self.library_key) self.library_user_page = LibraryUsersPage(self.browser, self.library_key) def test_library_user_access_setting_nav_help(self): """ Scenario: Help link in navigation bar is working on 'User Access' settings page of library. Given that I am on the 'User Access' settings page of library. 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.library_user_page.visit() expected_url = _get_expected_documentation_url( '/course_components/libraries.html#give-other-users-access-to-your-library' ) # Assert that help link is correct. assert_nav_help_link( test=self, page=self.library_user_page, href=expected_url, )
def setUp(self): super(LibraryUsersPageTest, self).setUp() # Create a second user for use in these tests: AutoAuthPage(self.browser, username="******", email="*****@*****.**", no_login=True).visit() self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit()
def setUp(self): super(LibraryHelpTest, self).setUp() self.library_page = LibraryPage(self.browser, self.library_key) self.library_user_page = LibraryUsersPage(self.browser, self.library_key)
class LibraryHelpTest(StudioLibraryTest): """ Test help links on a Library page. """ def setUp(self): super(LibraryHelpTest, self).setUp() self.library_page = LibraryPage(self.browser, self.library_key) self.library_user_page = LibraryUsersPage(self.browser, self.library_key) def test_library_content_nav_help(self): """ Scenario: Help link in navigation bar is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list 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 'course/components/libraries.html' """ self.library_page.visit() # 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/course_components/libraries.html" # Assert that help link is correct. assert_nav_help_link(test=self, page=self.library_page, href=href) def test_library_content_side_bar_help(self): """ Scenario: Help link in sidebar links is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list page). And I want help about the process And I click the 'Learn more about content libraries' in the sidebar links Then Help link should open. And help url should end with 'course/components/libraries.html' """ self.library_page.visit() # 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/course_components/libraries.html' # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.library_page, href=href, help_text='Learn more about content libraries') def test_library_user_access_setting_nav_help(self): """ Scenario: Help link in navigation bar is working on 'User Access' settings page of library. Given that I am on the 'User Access' settings page of library. 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 'creating_content/libraries.html#give-other-users-access-to-your-library' """ self.library_user_page.visit() # 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/course_components/libraries.html#give-other-users-access-to-your-library' # Assert that help link is correct. assert_nav_help_link(test=self, page=self.library_user_page, href=href)
class LibraryHelpTest(StudioLibraryTest): """ Test help links on a Library page. """ def setUp(self): super(LibraryHelpTest, self).setUp() self.library_page = LibraryPage(self.browser, self.library_key) self.library_user_page = LibraryUsersPage(self.browser, self.library_key) def test_library_content_nav_help(self): """ Scenario: Help link in navigation bar is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list 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 'course/components/libraries.html' """ self.library_page.visit() # 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/course_components/libraries.html" # Assert that help link is correct. assert_nav_help_link( test=self, page=self.library_page, href=href ) def test_library_content_side_bar_help(self): """ Scenario: Help link in sidebar links is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list page). And I want help about the process And I click the 'Learn more about content libraries' in the sidebar links Then Help link should open. And help url should end with 'course/components/libraries.html' """ self.library_page.visit() # 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/course_components/libraries.html' # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.library_page, href=href, help_text='Learn more about content libraries' ) def test_library_user_access_setting_nav_help(self): """ Scenario: Help link in navigation bar is working on 'User Access' settings page of library. Given that I am on the 'User Access' settings page of library. 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 'creating_content/libraries.html#give-other-users-access-to-your-library' """ self.library_user_page.visit() # 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/course_components/libraries.html#give-other-users-access-to-your-library' # Assert that help link is correct. assert_nav_help_link( test=self, page=self.library_user_page, href=href )
def _refresh_page(self): """ Reload the page. """ self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit()
class LibraryUsersPageTest(StudioLibraryTest): """ Test the functionality of the library "Instructor Access" page. """ def setUp(self): super(LibraryUsersPageTest, self).setUp() # Create a second user for use in these tests: AutoAuthPage(self.browser, username="******", email="*****@*****.**", no_login=True).visit() self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit() def _refresh_page(self): """ Reload the page. """ self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit() def test_user_management(self): """ Scenario: Ensure that we can edit the permissions of users. Given I have a library in Studio where I am the only admin assigned (which is the default for a newly-created library) And I navigate to Library "Instructor Access" Page in Studio Then there should be one user listed (myself), and I must not be able to remove myself or my instructor privilege. When I click Add Instructor Then I see a form to complete When I complete the form and submit it Then I can see the new user is listed as a "User" of the library When I click to Add Staff permissions to the new user Then I can see the new user has staff permissions and that I am now able to promote them to an Admin or remove their staff permissions. When I click to Add Admin permissions to the new user Then I can see the new user has admin permissions and that I can now remove Admin permissions from either user. """ def check_is_only_admin(user): """ Ensure user is an admin user and cannot be removed. (There must always be at least one admin user.) """ self.assertIn("admin", user.role_label.lower()) self.assertFalse(user.can_promote) self.assertFalse(user.can_demote) self.assertFalse(user.can_delete) self.assertTrue(user.has_no_change_warning) self.assertIn("Promote another member to Admin to remove your admin rights", user.no_change_warning_text) self.assertEqual(len(self.page.users), 1) user = self.page.users[0] self.assertTrue(user.is_current_user) check_is_only_admin(user) # Add a new user: self.assertTrue(self.page.has_add_button) self.assertFalse(self.page.new_user_form_visible) self.page.click_add_button() self.assertTrue(self.page.new_user_form_visible) self.page.set_new_user_email('*****@*****.**') self.page.click_submit_new_user_form() # Check the new user's listing: def get_two_users(): """ Expect two users to be listed, one being me, and another user. Returns me, them """ users = self.page.users self.assertEqual(len(users), 2) self.assertEqual(len([u for u in users if u.is_current_user]), 1) if users[0].is_current_user: return users[0], users[1] else: return users[1], users[0] self._refresh_page() user_me, them = get_two_users() check_is_only_admin(user_me) self.assertIn("user", them.role_label.lower()) self.assertTrue(them.can_promote) self.assertIn("Add Staff Access", them.promote_button_text) self.assertFalse(them.can_demote) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Add Staff permissions to the new user: them.click_promote() self._refresh_page() user_me, them = get_two_users() check_is_only_admin(user_me) self.assertIn("staff", them.role_label.lower()) self.assertTrue(them.can_promote) self.assertIn("Add Admin Access", them.promote_button_text) self.assertTrue(them.can_demote) self.assertIn("Remove Staff Access", them.demote_button_text) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Add Admin permissions to the new user: them.click_promote() self._refresh_page() user_me, them = get_two_users() self.assertIn("admin", user_me.role_label.lower()) self.assertFalse(user_me.can_promote) self.assertTrue(user_me.can_demote) self.assertTrue(user_me.can_delete) self.assertFalse(user_me.has_no_change_warning) self.assertIn("admin", them.role_label.lower()) self.assertFalse(them.can_promote) self.assertTrue(them.can_demote) self.assertIn("Remove Admin Access", them.demote_button_text) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Delete the new user: them.click_delete() self._refresh_page() self.assertEqual(len(self.page.users), 1) user = self.page.users[0] self.assertTrue(user.is_current_user)
class LibraryUsersPageTest(StudioLibraryTest): """ Test the functionality of the library "Instructor Access" page. """ def setUp(self): super(LibraryUsersPageTest, self).setUp() # Create a second user for use in these tests: AutoAuthPage(self.browser, username="******", email="*****@*****.**", no_login=True).visit() self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit() def _refresh_page(self): """ Reload the page. """ self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit() def test_user_management(self): """ Scenario: Ensure that we can edit the permissions of users. Given I have a library in Studio where I am the only admin assigned (which is the default for a newly-created library) And I navigate to Library "Instructor Access" Page in Studio Then there should be one user listed (myself), and I must not be able to remove myself or my instructor privilege. When I click Add Instructor Then I see a form to complete When I complete the form and submit it Then I can see the new user is listed as a "User" of the library When I click to Add Staff permissions to the new user Then I can see the new user has staff permissions and that I am now able to promote them to an Admin or remove their staff permissions. When I click to Add Admin permissions to the new user Then I can see the new user has admin permissions and that I can now remove Admin permissions from either user. """ def check_is_only_admin(user): """ Ensure user is an admin user and cannot be removed. (There must always be at least one admin user.) """ self.assertIn("admin", user.role_label.lower()) self.assertFalse(user.can_promote) self.assertFalse(user.can_demote) self.assertFalse(user.can_delete) self.assertTrue(user.has_no_change_warning) self.assertIn( "Promote another member to Admin to remove your admin rights", user.no_change_warning_text) self.assertEqual(len(self.page.users), 1) user = self.page.users[0] self.assertTrue(user.is_current_user) check_is_only_admin(user) # Add a new user: self.assertTrue(self.page.has_add_button) self.assertFalse(self.page.new_user_form_visible) self.page.click_add_button() self.assertTrue(self.page.new_user_form_visible) self.page.set_new_user_email('*****@*****.**') self.page.click_submit_new_user_form() # Check the new user's listing: def get_two_users(): """ Expect two users to be listed, one being me, and another user. Returns me, them """ users = self.page.users self.assertEqual(len(users), 2) self.assertEqual(len([u for u in users if u.is_current_user]), 1) if users[0].is_current_user: return users[0], users[1] else: return users[1], users[0] self._refresh_page() user_me, them = get_two_users() check_is_only_admin(user_me) self.assertIn("user", them.role_label.lower()) self.assertTrue(them.can_promote) self.assertIn("Add Staff Access", them.promote_button_text) self.assertFalse(them.can_demote) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Add Staff permissions to the new user: them.click_promote() self._refresh_page() user_me, them = get_two_users() check_is_only_admin(user_me) self.assertIn("staff", them.role_label.lower()) self.assertTrue(them.can_promote) self.assertIn("Add Admin Access", them.promote_button_text) self.assertTrue(them.can_demote) self.assertIn("Remove Staff Access", them.demote_button_text) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Add Admin permissions to the new user: them.click_promote() self._refresh_page() user_me, them = get_two_users() self.assertIn("admin", user_me.role_label.lower()) self.assertFalse(user_me.can_promote) self.assertTrue(user_me.can_demote) self.assertTrue(user_me.can_delete) self.assertFalse(user_me.has_no_change_warning) self.assertIn("admin", them.role_label.lower()) self.assertFalse(them.can_promote) self.assertTrue(them.can_demote) self.assertIn("Remove Admin Access", them.demote_button_text) self.assertTrue(them.can_delete) self.assertFalse(them.has_no_change_warning) # Delete the new user: them.click_delete() self._refresh_page() self.assertEqual(len(self.page.users), 1) user = self.page.users[0] self.assertTrue(user.is_current_user)
class LibraryHelpTest(StudioLibraryTest): """ Test help links on a Library page. """ def setUp(self): super(LibraryHelpTest, self).setUp() self.library_page = LibraryPage(self.browser, self.library_key) self.library_user_page = LibraryUsersPage(self.browser, self.library_key) @skip( "Disabled as edx.org help links are now different than Open edX (@catong can advise)" ) def test_library_content_nav_help(self): """ Scenario: Help link in navigation bar is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list 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.library_page.visit() expected_url = _get_expected_documentation_url( '/course_components/libraries.html') # Assert that help link is correct. assert_nav_help_link(test=self, page=self.library_page, href=expected_url) @skip( "Disabled as edx.org help links are now different than Open edX (@catong can advise)" ) def test_library_content_side_bar_help(self): """ Scenario: Help link in sidebar links is working on content library page(click a library on the Library list page). Given that I am on the content library page(click a library on the Library list page). And I want help about the process And I click the 'Learn more about content libraries' in the sidebar links Then Help link should open. And help url should be correct """ self.library_page.visit() expected_url = _get_expected_documentation_url( '/course_components/libraries.html') # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.library_page, href=expected_url, help_text='Learn more about content libraries') @skip( "Disabled as edx.org help links are now different than Open edX (@catong can advise)" ) def test_library_user_access_setting_nav_help(self): """ Scenario: Help link in navigation bar is working on 'User Access' settings page of library. Given that I am on the 'User Access' settings page of library. 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.library_user_page.visit() expected_url = _get_expected_documentation_url( '/course_components/libraries.html#give-other-users-access-to-your-library' ) # Assert that help link is correct. assert_nav_help_link( test=self, page=self.library_user_page, href=expected_url, )