Exemple #1
0
    def test_country_limit(self, browser, base_test_data):
        """
        There should be more than 20 countries in current country and birth country facets
        """
        with open("profiles/data/countries.csv") as f:
            reader = csv.DictReader(f)
            country_codes = [row['code'] for row in reader]
        create_enrolled_user_batch(len(country_codes),
                                   program=base_test_data.program,
                                   is_staff=False)

        # Don't update elasticsearch for each profile, do that in bulk after
        with mute_signals(post_save):
            for i, profile in enumerate(Profile.objects.all()):
                code = country_codes[i % len(country_codes)]
                profile.birth_country = code
                profile.country = code
                profile.save()

        recreate_index()

        browser.get("/learners")
        browser.wait_until_loaded(By.CLASS_NAME, 'menu-icon')

        current_selector = '.filter--country .sk-hierarchical-menu-list__item'

        country_count = browser.driver.execute_script(
            "return document.querySelectorAll('{}').length".format(
                current_selector))
        assert country_count == len(country_codes)
Exemple #2
0
    def test_country_limit(self, browser, base_test_data):
        """
        There should be more than 20 countries in current country and birth country facets
        """
        with open("profiles/data/countries.csv") as f:
            reader = csv.DictReader(f)
            country_codes = [row['code'] for row in reader]
        create_enrolled_user_batch(len(country_codes), program=base_test_data.program, is_staff=False)

        # Don't update elasticsearch for each profile, do that in bulk after
        with mute_signals(post_save):
            for i, profile in enumerate(Profile.objects.all()):
                code = country_codes[i % len(country_codes)]
                profile.birth_country = code
                profile.country = code
                profile.save()

        recreate_index()

        browser.get("/learners")
        browser.wait_until_loaded(By.CLASS_NAME, 'menu-icon')

        current_selector = '.filter--country .sk-hierarchical-menu-list__item'

        country_count = browser.driver.execute_script(
            "return document.querySelectorAll('{}').length".format(current_selector)
        )
        assert country_count == len(country_codes)
Exemple #3
0
    def test_switch_program(self, browser, base_test_data, logged_in_staff):
        """
        Switching programs should show a different set of users
        """
        existing_program_user_count = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE
        create_enrolled_user_batch(existing_program_user_count, program=base_test_data.program, is_staff=False)

        new_program = ProgramFactory.create(live=True)
        new_program_user_count = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE - 1
        create_enrolled_user_batch(new_program_user_count, program=new_program, is_staff=False)
        ProgramEnrollment.objects.create(program=new_program, user=logged_in_staff)
        Role.objects.create(
            role=Staff.ROLE_ID,
            user=logged_in_staff,
            program=new_program,
        )

        # Load the learners page for the existing program
        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result', existing_program_user_count)
        # Switch programs and check that the correct number of users are returned
        switcher = browser.driver.find_element_by_css_selector('.micromasters-header .Select-input')
        switcher.send_keys(Keys.DOWN)
        switcher.send_keys(Keys.ENTER)
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result', new_program_user_count)
        # Refresh browser and verify the count is the same
        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result', new_program_user_count)
Exemple #4
0
    def test_learners(self, browser, base_test_data):
        """
        Page should contain the appropriate number of results on each page
        """
        page_size = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE
        num_users_to_create = page_size + 2
        create_enrolled_user_batch(num_users_to_create, program=base_test_data.program, is_staff=False)
        expected_second_page_count = num_users_to_create - page_size

        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result', page_size)
        browser.driver.find_elements_by_class_name('sk-pagination-option')[1].click()
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result', expected_second_page_count)
Exemple #5
0
    def test_learners(self, browser, base_test_data):
        """
        Page should contain the appropriate number of results on each page
        """
        page_size = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE
        num_users_to_create = page_size + 2
        create_enrolled_user_batch(num_users_to_create,
                                   program=base_test_data.program,
                                   is_staff=False)
        expected_second_page_count = num_users_to_create - page_size

        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result',
                                         page_size)
        browser.driver.find_elements_by_class_name(
            'sk-pagination-option')[1].click()
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result',
                                         expected_second_page_count)
Exemple #6
0
    def test_profile_navigation(self, browser, base_test_data):
        """
        Nothing should break when navigating to the profile and back to learners search page
        """
        create_enrolled_user_batch(2, program=base_test_data.program, is_staff=False)

        browser.get("/learners")
        browser.click_when_loaded(By.CLASS_NAME, 'menu-icon')
        browser.wait().until(
            lambda driver: "open" in driver.find_element_by_class_name('nav-drawer').get_attribute('class')
        )
        browser.click_when_loaded(By.CSS_SELECTOR, 'a .profile-image')
        browser.wait_until_loaded(By.CLASS_NAME, 'user-page')
        # Go back to learners
        browser.click_when_loaded(By.CLASS_NAME, 'menu-icon')
        browser.wait().until(
            lambda driver: "open" in driver.find_element_by_class_name('nav-drawer').get_attribute('class')
        )
        browser.click_when_loaded(By.CSS_SELECTOR, "a[href='/learners']")
        browser.wait_until_loaded(By.CLASS_NAME, 'learner-results')
Exemple #7
0
    def test_profile_navigation(self, browser, base_test_data):
        """
        Nothing should break when navigating to the profile and back to learners search page
        """
        create_enrolled_user_batch(2,
                                   program=base_test_data.program,
                                   is_staff=False)

        browser.get("/learners")
        browser.click_when_loaded(By.CLASS_NAME, 'menu-icon')
        browser.wait().until(
            lambda driver: "open" in driver.find_element_by_class_name(
                'nav-drawer').get_attribute('class'))
        browser.click_when_loaded(By.CSS_SELECTOR, 'a .profile-image')
        browser.wait_until_loaded(By.CLASS_NAME, 'user-page')
        # Go back to learners
        browser.click_when_loaded(By.CLASS_NAME, 'menu-icon')
        browser.wait().until(
            lambda driver: "open" in driver.find_element_by_class_name(
                'nav-drawer').get_attribute('class'))
        browser.click_when_loaded(By.CSS_SELECTOR, "a[href='/learners']")
        browser.wait_until_loaded(By.CLASS_NAME, 'learner-results')
Exemple #8
0
    def test_switch_program(self, browser, base_test_data, logged_in_staff):
        """
        Switching programs should show a different set of users
        """
        existing_program_user_count = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE
        create_enrolled_user_batch(existing_program_user_count,
                                   program=base_test_data.program,
                                   is_staff=False)

        new_program = ProgramFactory.create(live=True)
        new_program_user_count = settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE - 1
        create_enrolled_user_batch(new_program_user_count,
                                   program=new_program,
                                   is_staff=False)
        ProgramEnrollment.objects.create(program=new_program,
                                         user=logged_in_staff)
        Role.objects.create(
            role=Staff.ROLE_ID,
            user=logged_in_staff,
            program=new_program,
        )

        # Load the learners page for the existing program
        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result',
                                         existing_program_user_count)
        # Switch programs and check that the correct number of users are returned
        switcher = browser.driver.find_element_by_css_selector(
            '.micromasters-header .Select-input')
        switcher.send_keys(Keys.DOWN)
        switcher.send_keys(Keys.ENTER)
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result',
                                         new_program_user_count)
        # Refresh browser and verify the count is the same
        browser.get("/learners")
        browser.wait_until_element_count(By.CLASS_NAME, 'learner-result',
                                         new_program_user_count)