def test_that_pinning_filter_persists_for_session(self, api, mozwebqa, existing_user, login, product, element):
        # create suite, cases and test run
        product_version_name = u'%s %s' % (product['name'], product['version']['name'])
        case, suite, run = self.create_and_run_test(api, mozwebqa, product, element)

        # go to manage cases page
        manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
        manage_cases_pg.go_to_manage_cases_page()

        # filter on product
        filter_item = manage_cases_pg.filter_form.filter_by(lookup='product', value=product['name'])
        self.check_pinned_filter(filter_item, is_pinned=False)

        # see only cases for specified product
        displayed_cases = manage_cases_pg.test_cases
        assert 1 == len(displayed_cases)
        assert case.name.lower() == displayed_cases[0].name.lower()

        # pin product filter
        filter_item.pin_filter()
        self.check_pinned_filter(filter_item, is_pinned=True)

        # go to manage suites page
        manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
        manage_suites_pg.go_to_manage_suites_page()

        # see only suites for specified product
        displayed_suites = manage_suites_pg.test_suites
        assert 1 == len(displayed_suites)
        assert suite.name.lower() == displayed_suites[0].name.lower()

        # go to results page
        view_results_pg = MozTrapViewRunResultsPage(mozwebqa)
        view_results_pg.go_to_view_run_results_page()

        # see only results for specified product
        # because we are going to check the same thing several times
        # let's define a function and call it each time we need this check

        def check_test_run_results(results):
            assert 1 == len(results)
            assert run['name'].lower() == results[0].name.lower()
            assert product_version_name == results[0].product_version

        check_test_run_results(view_results_pg.test_run_results)

        # refresh page and see that filter persists
        view_results_pg.refresh()
        check_test_run_results(view_results_pg.test_run_results)

        # log out and back in and see that filter persists
        view_results_pg.header.click_logout()
        view_results_pg.header.login(existing_user['email'], existing_user['password'])
        check_test_run_results(view_results_pg.test_run_results)

        # check that filter is still pinned
        filters = view_results_pg.filter_form.filter_items
        assert 1 == len(filters)
        self.check_pinned_filter(filters[0], is_pinned=True)
    def test_that_pinning_filter_persists_for_session(self, api, base_url,
                                                      selenium, existing_user,
                                                      login, product, element):
        # create suite, cases and test run
        product_version_name = u'%s %s' % (product['name'],
                                           product['version']['name'])
        case, suite, run = self.create_and_run_test(api, base_url, selenium,
                                                    product, element)

        # go to manage cases page
        manage_cases_pg = MozTrapManageCasesPage(base_url, selenium)
        manage_cases_pg.go_to_manage_cases_page()

        # filter on product
        filter_item = manage_cases_pg.filter_form.filter_by(
            lookup='product', value=product['name'])
        self.check_pinned_filter(filter_item, is_pinned=False)

        # see only cases for specified product
        displayed_cases = manage_cases_pg.test_cases
        assert 1 == len(displayed_cases)
        assert case.name.lower() == displayed_cases[0].name.lower()

        # pin product filter
        filter_item.pin_filter()
        self.check_pinned_filter(filter_item, is_pinned=True)

        # go to manage suites page
        manage_suites_pg = MozTrapManageSuitesPage(base_url, selenium)
        manage_suites_pg.go_to_manage_suites_page()

        # see only suites for specified product
        displayed_suites = manage_suites_pg.test_suites
        assert 1 == len(displayed_suites)
        assert suite.name.lower() == displayed_suites[0].name.lower()

        # go to results page
        view_results_pg = MozTrapViewRunResultsPage(base_url, selenium)
        view_results_pg.go_to_view_run_results_page()

        # see only results for specified product
        # because we are going to check the same thing several times
        # let's define a function and call it each time we need this check

        def check_test_run_results(results):
            assert 1 == len(results)
            assert run['name'].lower() == results[0].name.lower()
            assert product_version_name == results[0].product_version

        check_test_run_results(view_results_pg.test_run_results)

        # refresh page and see that filter persists
        view_results_pg.refresh()
        check_test_run_results(view_results_pg.test_run_results)

        # log out and back in and see that filter persists
        view_results_pg.header.click_logout()
        view_results_pg.header.login(existing_user['email'],
                                     existing_user['password'])
        check_test_run_results(view_results_pg.test_run_results)

        # check that filter is still pinned
        filters = view_results_pg.filter_form.filter_items
        assert 1 == len(filters)
        self.check_pinned_filter(filters[0], is_pinned=True)
    def test_that_pinning_filter_persists_for_session(self, mozwebqa_logged_in, product, element):
        # create suite, cases and test run
        product_version_name = u'%s %s' % (product['name'], product['version']['name'])
        case, suite, run = self.create_and_run_test(mozwebqa_logged_in, product, element)

        # go to manage cases page
        manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
        manage_cases_pg.go_to_manage_cases_page()

        # filter on product
        filter_item = manage_cases_pg.filter_form.filter_by(lookup='product', value=product['name'])
        self.check_pinned_filter(filter_item, is_pinned=False)

        # see only cases for specified product
        displayed_cases = manage_cases_pg.test_cases
        Assert.equal(len(displayed_cases), 1, 'there should be only one case displayed')
        Assert.equal(case.name.lower(), displayed_cases[0].name.lower(),
                     'displayed case name differs from expected value')

        # pin product filter
        filter_item.pin_filter()
        self.check_pinned_filter(filter_item, is_pinned=True)

        # go to manage suites page
        manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
        manage_suites_pg.go_to_manage_suites_page()

        # see only suites for specified product
        displayed_suites = manage_suites_pg.test_suites
        Assert.equal(len(displayed_suites), 1, 'there should be only one suite displayed')
        Assert.equal(suite.name.lower(), displayed_suites[0].name.lower(),
                     'displayed suite name differs from expected value')

        # go to results page
        view_results_pg = MozTrapViewRunResultsPage(mozwebqa_logged_in)
        view_results_pg.go_to_view_run_results_page()

        # see only results for specified product
        # because we are going to check the same thing several times
        # let's define a function and call it each time we need this check

        def check_test_run_results(results):
            Assert.equal(len(results), 1, 'there should be only one test run result')
            Assert.equal(run['name'].lower(), results[0].name.lower(),
                         'displayed run name differs from expected value')
            Assert.equal(product_version_name, results[0].product_version,
                         'displayed test run productversion differs from expected value')

        check_test_run_results(view_results_pg.test_run_results)

        # refresh page and see that filter persists
        view_results_pg.refresh()
        check_test_run_results(view_results_pg.test_run_results)

        # log out and back in and see that filter persists
        view_results_pg.header.click_logout()
        view_results_pg.header.click_login()
        check_test_run_results(view_results_pg.test_run_results)

        # check that filter is still pinned
        filters = view_results_pg.filter_form.filter_items
        Assert.equal(len(filters), 1)
        self.check_pinned_filter(filters[0], is_pinned=True)
    def test_that_pinning_filter_persists_for_session(self, api, mozwebqa,
                                                      existing_user, login,
                                                      product, element):
        # create suite, cases and test run
        product_version_name = u'%s %s' % (product['name'],
                                           product['version']['name'])
        case, suite, run = self.create_and_run_test(api, mozwebqa, product,
                                                    element)

        # go to manage cases page
        manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
        manage_cases_pg.go_to_manage_cases_page()

        # filter on product
        filter_item = manage_cases_pg.filter_form.filter_by(
            lookup='product', value=product['name'])
        self.check_pinned_filter(filter_item, is_pinned=False)

        # see only cases for specified product
        displayed_cases = manage_cases_pg.test_cases
        Assert.equal(len(displayed_cases), 1,
                     'there should be only one case displayed')
        Assert.equal(case.name.lower(), displayed_cases[0].name.lower(),
                     'displayed case name differs from expected value')

        # pin product filter
        filter_item.pin_filter()
        self.check_pinned_filter(filter_item, is_pinned=True)

        # go to manage suites page
        manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
        manage_suites_pg.go_to_manage_suites_page()

        # see only suites for specified product
        displayed_suites = manage_suites_pg.test_suites
        Assert.equal(len(displayed_suites), 1,
                     'there should be only one suite displayed')
        Assert.equal(suite.name.lower(), displayed_suites[0].name.lower(),
                     'displayed suite name differs from expected value')

        # go to results page
        view_results_pg = MozTrapViewRunResultsPage(mozwebqa)
        view_results_pg.go_to_view_run_results_page()

        # see only results for specified product
        # because we are going to check the same thing several times
        # let's define a function and call it each time we need this check

        def check_test_run_results(results):
            Assert.equal(len(results), 1,
                         'there should be only one test run result')
            Assert.equal(run['name'].lower(), results[0].name.lower(),
                         'displayed run name differs from expected value')
            Assert.equal(
                product_version_name, results[0].product_version,
                'displayed test run productversion differs from expected value'
            )

        check_test_run_results(view_results_pg.test_run_results)

        # refresh page and see that filter persists
        view_results_pg.refresh()
        check_test_run_results(view_results_pg.test_run_results)

        # log out and back in and see that filter persists
        view_results_pg.header.click_logout()
        view_results_pg.header.login(existing_user['email'],
                                     existing_user['password'])
        check_test_run_results(view_results_pg.test_run_results)

        # check that filter is still pinned
        filters = view_results_pg.filter_form.filter_items
        Assert.equal(len(filters), 1)
        self.check_pinned_filter(filters[0], is_pinned=True)