Esempio n. 1
0
    def test_embed_render_lifecycle_for_child_course(self):
        child_name, child_title = self.create_new_course()
        self.make_course_enrollable(child_name)
        parent_name = self.create_new_course(login=False)[0]
        self.set_child_courses_and_make_course_available(
            parent_name, child_name)
        pageobjects.RootPage(self).load(
            integration.TestBase.INTEGRATION_SERVER_BASE_URL).click_logout()
        demo_page = embed_pageobjects.DemoPage(self).load(
            self.get_demo_child_url(parent_name))
        embeds = demo_page.get_cb_embed_elements()

        self.assertTrue(len(embeds) == 1)

        for cb_embed in embeds:
            page = demo_page.load_embed(
                cb_embed, wait_for=embed_pageobjects.StateSignIn)
            self.assert_is_sign_in_page(page)

        demo_page.login(self.email)

        # Force refetch of embeds because login state changed.
        for cb_embed in demo_page.get_cb_embed_elements():
            page = demo_page.load_embed(cb_embed)
            self.assert_is_embed_page(page, child_title)
Esempio n. 2
0
    def test_embed_local_errors(self):
        self.load_sample_course()
        pageobjects.RootPage(self).load(
            integration.TestBase.INTEGRATION_SERVER_BASE_URL).click_logout()

        local_error_page = embed_pageobjects.DemoPage(self).load(
            self.get_local_errors_url())

        # Before signing in, the first embed shows the sign-in widget, and the
        # second shows both a global and a local error.
        cb_embeds = local_error_page.get_cb_embed_elements()

        self.assertEquals(2, len(cb_embeds))
        self.assert_is_sign_in_page(
            local_error_page.load_embed(
                cb_embeds[0], wait_for=embed_pageobjects.StateSignIn))

        second_embed_page = local_error_page.load_embed(
            cb_embeds[1], wait_for=embed_pageobjects.StateError)
        global_error_message = (
            'Embed src '
            '"http://localhost:8082/sample/modules/embed/v1/resource/example/'
            '2" does not match origin "http://localhost:8081"')
        local_error_message = (
            'Embed src '
            '"http://localhost:8082/sample/modules/embed/v1/resource/example/'
            '2" does not match first cb-embed src found, which is from the '
            'deployment at "http://localhost:8081/sample/modules/embed/v1". '
            'All cb-embeds in a single page must be from the same Course '
            'Builder deployment.')

        self.assert_embed_has_error(second_embed_page, global_error_message)
        self.assert_embed_has_error(second_embed_page, local_error_message)

        # After signing in, the first embed shows content and the second embed
        # shows both a global and a local error.
        local_error_page.login(self.email)

        cb_embeds = local_error_page.get_cb_embed_elements()

        self.assertEquals(2, len(cb_embeds))

        first_embed_page = local_error_page.load_embed(cb_embeds[0])
        second_embed_page = local_error_page.load_embed(
            cb_embeds[1], wait_for=embed_pageobjects.StateError)

        self.assert_is_embed_page(first_embed_page, self.SAMPLE_COURSE_TITLE)
        self.assert_embed_has_error(second_embed_page, global_error_message)
        self.assert_embed_has_error(second_embed_page, local_error_message)
Esempio n. 3
0
    def test_embed_render_lifecycle_for_single_course(self):
        dashboard_page = self.load_sample_course()
        pageobjects.RootPage(self).load(
            integration.TestBase.INTEGRATION_SERVER_BASE_URL).click_logout()
        demo_page = embed_pageobjects.DemoPage(self).load(
            self.get_demo_url())
        embeds = demo_page.get_cb_embed_elements()

        self.assertTrue(len(embeds) == 3)

        for cb_embed in embeds:
            page = demo_page.load_embed(
                cb_embed, wait_for=embed_pageobjects.StateSignIn)
            self.assert_is_sign_in_page(page)

        demo_page.login(self.email)

        # Force refetch of embeds because login state changed.
        for cb_embed in demo_page.get_cb_embed_elements():
            page = demo_page.load_embed(cb_embed)
            self.assert_is_embed_page(page, self.SAMPLE_COURSE_TITLE)
Esempio n. 4
0
    def test_embed_global_errors(self):
        self.load_sample_course()
        pageobjects.RootPage(self).load(
            integration.TestBase.INTEGRATION_SERVER_BASE_URL).click_logout()

        global_error_page = embed_pageobjects.DemoPage(self).load(
            self.get_global_errors_url())

        # Because both widgets have configuration errors, the embeds are both in
        # state error and no sign-in widget is shown.
        cb_embeds = global_error_page.get_cb_embed_elements()

        self.assertEquals(2, len(cb_embeds))

        first_error_page = global_error_page.load_embed(
            cb_embeds[0], wait_for=embed_pageobjects.StateError)
        global_error_message = (
            'Embed src '
            '"http://other:8081/sample/modules/embed/v1/resource/example/1" '
            'does not match origin "http://localhost:8081"')

        self.assert_embed_has_error(first_error_page, global_error_message)

        second_error_page = global_error_page.load_embed(
            cb_embeds[1], wait_for=embed_pageobjects.StateError)
        global_error_message = (
            'Embed src '
            '"http://localhost:8082/sample/modules/embed/v1/resource/example/'
            '2" does not match origin "http://localhost:8081"')
        local_error_message = (
            'Embed src '
            '"http://localhost:8082/sample/modules/embed/v1/resource/example/'
            '2" does not match first cb-embed src found, which is from the '
            'deployment at "http://other:8081/sample/modules/embed/v1". '
            'All cb-embeds in a single page must be from the same Course '
            'Builder deployment.')

        self.assert_embed_has_error(second_error_page, global_error_message)
        self.assert_embed_has_error(second_error_page, local_error_message)