class NewProgramHelpTest(ProgramsConfigMixin, AcceptanceTest): """ Test help links on a 'New Program' page """ def setUp(self): super(NewProgramHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.program_page = DashboardPageWithPrograms(self.browser) self.auth_page.visit() self.set_programs_api_configuration(True) self.program_page.visit() def test_program_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'New Program' page Given that I am on the 'New Program' 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 'index.html' """ self.program_page.click_new_program_button() href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course' \ '/en/latest/index.html' # Assert that help link is correct. assert_nav_help_link( test=self, page=self.program_page, href=href, )
class NewProgramHelpTest(ProgramsConfigMixin, AcceptanceTest): """ Test help links on a 'New Program' page """ def setUp(self): super(NewProgramHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.program_page = DashboardPageWithPrograms(self.browser) self.auth_page.visit() self.set_programs_api_configuration(True) self.program_page.visit() def test_program_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'New Program' page Given that I am on the 'New Program' 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 'index.html' """ self.program_page.click_new_program_button() href = 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course' \ '/en/open-release-ficus.master/index.html' # Assert that help link is correct. assert_nav_help_link( test=self, page=self.program_page, href=href, )
class DashboardProgramsTabTest(ProgramsConfigMixin, CatalogConfigMixin, AcceptanceTest): """ Test the programs tab on the studio home page. """ def setUp(self): super(DashboardProgramsTabTest, self).setUp() self.stub_programs_api() self.stub_catalog_api() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPageWithPrograms(self.browser) self.auth_page.visit() def stub_programs_api(self): """Stub out the programs API with fake data.""" self.set_programs_api_configuration(is_enabled=True) ProgramsFixture().install_programs([]) def stub_catalog_api(self): """Stub out the catalog API's program endpoint.""" self.set_catalog_configuration(is_enabled=True) CatalogFixture().install_programs([]) def test_tab_is_disabled(self): """ The programs tab and "new program" button should not appear at all unless enabled via the config model. """ self.set_programs_api_configuration() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.is_programs_tab_present()) self.assertFalse(self.dashboard_page.is_new_program_button_present()) def test_tab_is_enabled_with_empty_list(self): """ The programs tab and "new program" button should appear when enabled via config. When the programs list is empty, a button should appear that allows creating a new program. """ self.dashboard_page.visit() self.assertTrue(self.dashboard_page.is_programs_tab_present()) self.assertTrue(self.dashboard_page.is_new_program_button_present()) results = self.dashboard_page.get_program_list() self.assertEqual(results, []) self.assertTrue(self.dashboard_page.is_empty_list_create_button_present()) def test_tab_is_enabled_with_nonempty_list(self): """ The programs tab and "new program" button should appear when enabled via config, and the results of the program list should display when the list is nonempty. """ test_program_values = [('first program', 'org1'), ('second program', 'org2')] programs = [ factories.Program( name=name, organizations=[ factories.Organization(key=org), ], course_codes=[ factories.CourseCode(run_modes=[ factories.RunMode(), ]), ] ) for name, org in test_program_values ] ProgramsFixture().install_programs(programs) self.dashboard_page.visit() self.assertTrue(self.dashboard_page.is_programs_tab_present()) self.assertTrue(self.dashboard_page.is_new_program_button_present()) self.assertFalse(self.dashboard_page.is_empty_list_create_button_present()) results = self.dashboard_page.get_program_list() self.assertEqual(results, test_program_values) def test_tab_requires_staff(self): """ The programs tab and "new program" button will not be available, even when enabled via config, if the user is not global staff. """ AutoAuthPage(self.browser, staff=False).visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.is_programs_tab_present()) self.assertFalse(self.dashboard_page.is_new_program_button_present())
class DashboardProgramsTabTest(ProgramsConfigMixin, WebAppTest): """ Test the programs tab on the studio home page. """ def setUp(self): super(DashboardProgramsTabTest, self).setUp() ProgramsFixture().install_programs([]) self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPageWithPrograms(self.browser) self.auth_page.visit() def test_tab_is_disabled(self): """ The programs tab and "new program" button should not appear at all unless enabled via the config model. """ self.set_programs_api_configuration() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.is_programs_tab_present()) self.assertFalse(self.dashboard_page.is_new_program_button_present()) def test_tab_is_enabled_with_empty_list(self): """ The programs tab and "new program" button should appear when enabled via config. When the programs list is empty, a button should appear that allows creating a new program. """ self.set_programs_api_configuration(True) self.dashboard_page.visit() self.assertTrue(self.dashboard_page.is_programs_tab_present()) self.assertTrue(self.dashboard_page.is_new_program_button_present()) results = self.dashboard_page.get_program_list() self.assertEqual(results, []) self.assertTrue( self.dashboard_page.is_empty_list_create_button_present()) def test_tab_is_enabled_with_nonempty_list(self): """ The programs tab and "new program" button should appear when enabled via config, and the results of the program list should display when the list is nonempty. """ test_program_values = [('first program', 'org1'), ('second program', 'org2')] programs = [ factories.Program(name=name, organizations=[ factories.Organization(key=org), ], course_codes=[ factories.CourseCode(run_modes=[ factories.RunMode(), ]), ]) for name, org in test_program_values ] ProgramsFixture().install_programs(programs) self.set_programs_api_configuration(True) self.dashboard_page.visit() self.assertTrue(self.dashboard_page.is_programs_tab_present()) self.assertTrue(self.dashboard_page.is_new_program_button_present()) self.assertFalse( self.dashboard_page.is_empty_list_create_button_present()) results = self.dashboard_page.get_program_list() self.assertEqual(results, test_program_values) def test_tab_requires_staff(self): """ The programs tab and "new program" button will not be available, even when enabled via config, if the user is not global staff. """ self.set_programs_api_configuration(True) AutoAuthPage(self.browser, staff=False).visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.is_programs_tab_present()) self.assertFalse(self.dashboard_page.is_new_program_button_present())