Example #1
0
    def test_show_warning_when_adding_new_translation(self):

        user = self.create_new_user(email='*****@*****.**')

        new_page = SampleNewPage(self)
        new_page.open(login=True, user=user)

        # User sets the language to English and starts editing.
        new_page.change_language('en')
        new_page.click_edit_category('cat_1')

        # User does not see a translation warning (no object yet)
        step_page = SampleStepPage(self)
        assert not step_page.has_translation_warning()

        # User fills out a key and submits the step.
        step_page.get_el(step_page.LOC_FORM_INPUT_KEY_1).send_keys('Foo')
        step_page.submit_step()

        # User opens another step and does not see a translation warning
        new_page.click_edit_category('cat_1')
        assert not step_page.has_translation_warning()
        step_page.back_without_saving()

        # User now changes the language to French and wants to edit again.
        new_page.change_language('fr')
        new_page.click_edit_category('cat_1')

        # User sees a warning, telling him that he is about to add a new
        # translation.
        assert step_page.has_translation_warning()

        # User decides to go back to the overview.
        step_page.translation_warning_click_go_back()

        # User again wants to edit in French
        new_page.click_edit_category('cat_1')
        assert step_page.has_translation_warning()

        # This time, user continues and submits the step.
        step_page.translation_warning_click_continue()
        step_page.submit_step(confirm_add_translation=True)

        # When he opens the step again (in French), no warning is displayed
        # anymore.
        new_page.click_edit_category('cat_1')
        assert not step_page.has_translation_warning()
Example #2
0
    def test_show_warning_when_adding_new_translation(self):

        user = self.create_new_user(email='*****@*****.**')

        new_page = SampleNewPage(self)
        new_page.open(login=True, user=user)

        # User sets the language to English and starts editing.
        new_page.change_language('en')
        new_page.click_edit_category('cat_1')

        # User does not see a translation warning (no object yet)
        step_page = SampleStepPage(self)
        assert not step_page.has_translation_warning()

        # User fills out a key and submits the step.
        step_page.get_el(step_page.LOC_FORM_INPUT_KEY_1).send_keys('Foo')
        step_page.submit_step()

        # User opens another step and does not see a translation warning
        new_page.click_edit_category('cat_1')
        assert not step_page.has_translation_warning()
        step_page.back_without_saving()

        # User now changes the language to French and wants to edit again.
        new_page.change_language('fr')
        new_page.click_edit_category('cat_1')

        # User sees a warning, telling him that he is about to add a new
        # translation.
        assert step_page.has_translation_warning()

        # User decides to go back to the overview.
        step_page.translation_warning_click_go_back()

        # User again wants to edit in French
        new_page.click_edit_category('cat_1')
        assert step_page.has_translation_warning()

        # This time, user continues and submits the step.
        step_page.translation_warning_click_continue()
        step_page.submit_step(confirm_add_translation=True)

        # When he opens the step again (in French), no warning is displayed
        # anymore.
        new_page.click_edit_category('cat_1')
        assert not step_page.has_translation_warning()
Example #3
0
    def test_show_only_one_linked_version(self):

        sample_title = 'This is the first key.'
        samplemulti_title = 'This is key 1a'
        samplemulti_changed_text = ' (changed)'
        samplemulti_title_changed = samplemulti_title + samplemulti_changed_text

        # Alice logs in
        # She goes to the SAMPLE questionnaire and sees the link
        user_1 = User.objects.get(pk=101)
        sample_detail_page = SampleDetailPage(self)
        sample_detail_page.route_kwargs = {'identifier': 'sample_1'}
        sample_detail_page.open(login=True, user=user_1)
        sample_detail_page.expand_details()

        expected_samplemulti_links = [
            {
                'title': samplemulti_title,
                'configuration': 'samplemulti',
            }
        ]
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)

        # She goes to the MULTISAMPLE questionnaire and sees the link
        sample_detail_page.click_linked_questionnaire(index=0)

        samplemulti_detail_page = SampleMultiDetailPage(self)
        samplemulti_detail_page.expand_details()

        expected_sample_links = [
            {
                'title': sample_title,
                'configuration': 'sample',
            }
        ]
        samplemulti_detail_page.check_linked_questionnaires(
            expected=expected_sample_links)

        # She edits the MULTISAMPLE questionnaire and sees only one
        # version is linked (still the same)
        samplemulti_detail_page.create_new_version()
        samplemulti_edit_page = SampleMultiEditPage(self)
        samplemulti_edit_page.click_edit_category('mcat_1')

        samplemulti_step_page = SampleMultiStepPage(self)
        samplemulti_step_page.enter_text(
            samplemulti_step_page.LOC_QUESTION_MQG01_MKEY01,
            samplemulti_changed_text)

        # She submits the step
        samplemulti_step_page.submit_step()

        # She sees that only one questionnaire is linked
        samplemulti_edit_page.expand_details()
        samplemulti_edit_page.check_linked_questionnaires(
            expected=expected_sample_links)

        # She goes to the SAMPLE questionnaire and sees only one version
        # is linked (the pending one)
        samplemulti_edit_page.click_linked_questionnaire(index=0)

        expected_samplemulti_links_changed = [
            {
                'title': samplemulti_title_changed,
                'configuration': 'samplemulti',
            }
        ]
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links_changed)

        # She even creates a new version and opens the form and sees there is
        # only one version
        sample_detail_page.create_new_version()
        sample_edit_page = SampleEditPage(self)
        sample_edit_page.click_edit_category('cat_5')
        sample_step_page = SampleStepPage(self)
        sample_step_page.check_links([samplemulti_title_changed])
        sample_step_page.back_without_saving()

        # She logs out and sees only one questionnaire is linked (the
        # active one)
        sample_detail_page.logout()
        sample_detail_page.open()
        sample_detail_page.expand_details()
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)

        # She logs in as a different user and sees only one version is
        # linked (the active one)
        user_2 = User.objects.get(pk=102)
        sample_detail_page.open(login=True, user=user_2)
        sample_detail_page.expand_details()
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)
Example #4
0
    def test_show_only_one_linked_version(self):

        sample_title = 'This is the first key.'
        samplemulti_title = 'This is key 1a'
        samplemulti_changed_text = ' (changed)'
        samplemulti_title_changed = samplemulti_title + samplemulti_changed_text

        # Alice logs in
        # She goes to the SAMPLE questionnaire and sees the link
        user_1 = User.objects.get(pk=101)
        sample_detail_page = SampleDetailPage(self)
        sample_detail_page.route_kwargs = {'identifier': 'sample_1'}
        sample_detail_page.open(login=True, user=user_1)
        sample_detail_page.expand_details()

        expected_samplemulti_links = [{
            'title': samplemulti_title,
            'configuration': 'samplemulti',
        }]
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)

        # She goes to the MULTISAMPLE questionnaire and sees the link
        sample_detail_page.click_linked_questionnaire(index=0)

        samplemulti_detail_page = SampleMultiDetailPage(self)
        samplemulti_detail_page.expand_details()

        expected_sample_links = [{
            'title': sample_title,
            'configuration': 'sample',
        }]
        samplemulti_detail_page.check_linked_questionnaires(
            expected=expected_sample_links)

        # She edits the MULTISAMPLE questionnaire and sees only one
        # version is linked (still the same)
        samplemulti_detail_page.create_new_version()
        samplemulti_edit_page = SampleMultiEditPage(self)
        samplemulti_edit_page.click_edit_category('mcat_1')

        samplemulti_step_page = SampleMultiStepPage(self)
        samplemulti_step_page.enter_text(
            samplemulti_step_page.LOC_QUESTION_MQG01_MKEY01,
            samplemulti_changed_text)

        # She submits the step
        samplemulti_step_page.submit_step()

        # She sees that only one questionnaire is linked
        samplemulti_edit_page.expand_details()
        samplemulti_edit_page.check_linked_questionnaires(
            expected=expected_sample_links)

        # She goes to the SAMPLE questionnaire and sees only one version
        # is linked (the pending one)
        samplemulti_edit_page.click_linked_questionnaire(index=0)

        expected_samplemulti_links_changed = [{
            'title': samplemulti_title_changed,
            'configuration': 'samplemulti',
        }]
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links_changed)

        # She even creates a new version and opens the form and sees there is
        # only one version
        sample_detail_page.create_new_version()
        sample_edit_page = SampleEditPage(self)
        sample_edit_page.click_edit_category('cat_5')
        sample_step_page = SampleStepPage(self)
        sample_step_page.check_links([samplemulti_title_changed])
        sample_step_page.back_without_saving()

        # She logs out and sees only one questionnaire is linked (the
        # active one)
        sample_detail_page.logout()
        sample_detail_page.open()
        sample_detail_page.expand_details()
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)

        # She logs in as a different user and sees only one version is
        # linked (the active one)
        user_2 = User.objects.get(pk=102)
        sample_detail_page.open(login=True, user=user_2)
        sample_detail_page.expand_details()
        sample_detail_page.check_linked_questionnaires(
            expected=expected_samplemulti_links)