From 32e3e50f2c23cc1869c8f22c5b0b97f97cca3caa Mon Sep 17 00:00:00 2001 From: Vir Kothari <73329256+Vir-8@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:38:32 +0530 Subject: [PATCH] [GSoC'24] Run exploration translations acceptance test in CI (#20835) * Fix acceptance test * Revert accidental commit * Add acceptance test to run in CI * Remove timeout * Fix test * Update * Update * Test * Update * Test * Fix --- ...n-modify-translations-modal.component.html | 2 +- .../ci-test-suite-configs/acceptance.json | 4 +++ .../modify-translations-through-modal.spec.ts | 3 +- ...n-while-getting-feedback-and-hints.spec.ts | 3 +- .../utilities/user/exploration-editor.ts | 34 ++++++++++++++----- core/tests/root-files-config.json | 1 - .../modify-translations-through-modal.txt | 7 ++++ scripts/check_tests_are_captured_in_ci.py | 1 - 8 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 core/tests/test-modules-mappings/acceptance/exploration-editor/modify-translations-through-modal.txt diff --git a/core/templates/pages/exploration-editor-page/modal-templates/exploration-modify-translations-modal.component.html b/core/templates/pages/exploration-editor-page/modal-templates/exploration-modify-translations-modal.component.html index 5bade4bbc672..a491adb39acd 100644 --- a/core/templates/pages/exploration-editor-page/modal-templates/exploration-modify-translations-modal.component.html +++ b/core/templates/pages/exploration-editor-page/modal-templates/exploration-modify-translations-modal.component.html @@ -26,7 +26,7 @@
- diff --git a/core/tests/ci-test-suite-configs/acceptance.json b/core/tests/ci-test-suite-configs/acceptance.json index 232ea6b3f22b..18d7cfe8ce42 100644 --- a/core/tests/ci-test-suite-configs/acceptance.json +++ b/core/tests/ci-test-suite-configs/acceptance.json @@ -32,6 +32,10 @@ "name": "exploration-editor/create-exploration-and-change-basic-settings", "module": "core/tests/puppeteer-acceptance-tests/specs/exploration-editor/create-exploration-and-change-basic-settings.spec.ts" }, + { + "name": "exploration-editor/modify-translations-through-modal", + "module": "core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts" + }, { "name": "exploration-editor/publish-the-exploration-with-an-interaction", "module": "core/tests/puppeteer-acceptance-tests/specs/exploration-editor/publish-the-exploration-with-an-interaction.spec.ts" diff --git a/core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts b/core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts index 172ecd316522..47efa87dad79 100644 --- a/core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts +++ b/core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts @@ -131,7 +131,8 @@ describe('Exploration Editor', function () { await explorationEditor.editDefaultResponseFeedback('Wrong.'); await explorationEditor.addSolutionToState( 'minus', - 'Minus is the opposite of plus.' + 'Minus is the opposite of plus.', + false ); await explorationEditor.saveExplorationDraft(); diff --git a/core/tests/puppeteer-acceptance-tests/specs/logged-out-user/play-through-lesson-while-getting-feedback-and-hints.spec.ts b/core/tests/puppeteer-acceptance-tests/specs/logged-out-user/play-through-lesson-while-getting-feedback-and-hints.spec.ts index e35ee2614063..8ae474cbb6c8 100644 --- a/core/tests/puppeteer-acceptance-tests/specs/logged-out-user/play-through-lesson-while-getting-feedback-and-hints.spec.ts +++ b/core/tests/puppeteer-acceptance-tests/specs/logged-out-user/play-through-lesson-while-getting-feedback-and-hints.spec.ts @@ -92,7 +92,8 @@ describe('Logged-out User', function () { ); await explorationEditor.addSolutionToState( '-99', - 'The number -99 is a negative number.' + 'The number -99 is a negative number.', + true ); await explorationEditor.saveExplorationDraft(); diff --git a/core/tests/puppeteer-acceptance-tests/utilities/user/exploration-editor.ts b/core/tests/puppeteer-acceptance-tests/utilities/user/exploration-editor.ts index b180d7e78ba4..e519010e2faf 100644 --- a/core/tests/puppeteer-acceptance-tests/utilities/user/exploration-editor.ts +++ b/core/tests/puppeteer-acceptance-tests/utilities/user/exploration-editor.ts @@ -94,7 +94,7 @@ const uploadImageButton = '.e2e-test-upload-image'; const useTheUploadImageButton = '.e2e-test-use-image'; const imageRegionSelector = '.e2e-test-svg'; const correctAnswerInTheGroupSelector = '.e2e-test-editor-correctness-toggle'; -const addNewResponseButton = '.e2e-test-add-new-response'; +const addNewResponseButton = 'button.e2e-test-add-new-response'; const floatFormInput = '.e2e-test-float-form-input'; const modifyExistingTranslationsButton = '.e2e-test-modify-translations-button'; const activeTranslationTab = '.e2e-test-active-translation-tab'; @@ -115,7 +115,9 @@ const saveOutcomeFeedbackButton = 'button.e2e-test-save-outcome-feedback'; const addHintButton = 'button.e2e-test-oppia-add-hint-button'; const saveHintButton = 'button.e2e-test-save-hint'; const addSolutionButton = 'button.e2e-test-oppia-add-solution-button'; -const solutionInput = 'oppia-add-or-update-solution-modal input'; +const solutionInputNumeric = 'oppia-add-or-update-solution-modal input'; +const solutionInputTextArea = + 'oppia-add-or-update-solution-modal textarea.e2e-test-description-box'; const submitSolutionButton = 'button.e2e-test-submit-solution-button'; const dismissTranslationWelcomeModalSelector = @@ -454,6 +456,10 @@ export class ExplorationEditor extends BaseUser { }); await this.clickOn(textInputInteractionButton); await this.clickOn(saveInteractionButton); + await this.page.waitForSelector(addInteractionModalSelector, { + hidden: true, + }); + showMessage('Text input interaction has been added successfully.'); } /** @@ -1066,10 +1072,17 @@ export class ExplorationEditor extends BaseUser { await this.clickOn(correctAnswerInTheGroupSelector); } if (isLastResponse) { - await this.clickOn(addNewResponseButton); - await this.page.waitForSelector(responseModalHeaderSelector, { - hidden: true, + await this.page.waitForSelector(addNewResponseButton, { + visible: true, }); + await this.clickOn(addNewResponseButton); + await this.page + .waitForSelector(responseModalHeaderSelector, { + hidden: true, + }) + .catch(async () => { + await this.clickOn(addNewResponseButton); + }); } else { await this.clickOn(addAnotherResponseButton); } @@ -1114,14 +1127,19 @@ export class ExplorationEditor extends BaseUser { * Function to add a solution for a state interaction. * @param {string} answer - The solution of the current state card. * @param {string} answerExplanation - The explanation for this state card's solution. + * @param {boolean} isSolutionNumericInput - Whether the solution is for a numeric input interaction. */ async addSolutionToState( answer: string, - answerExplanation: string + answerExplanation: string, + isSolutionNumericInput: boolean ): Promise { + const solutionSelector = isSolutionNumericInput + ? solutionInputNumeric + : solutionInputTextArea; await this.clickOn(addSolutionButton); - await this.page.waitForSelector(solutionInput, {visible: true}); - await this.type(solutionInput, answer); + await this.page.waitForSelector(solutionSelector, {visible: true}); + await this.type(solutionSelector, answer); await this.page.waitForSelector(`${submitAnswerButton}:not([disabled])`); await this.clickOn(submitAnswerButton); await this.type(stateContentInputField, answerExplanation); diff --git a/core/tests/root-files-config.json b/core/tests/root-files-config.json index bb756e9140a3..b9c5178170fe 100644 --- a/core/tests/root-files-config.json +++ b/core/tests/root-files-config.json @@ -59,7 +59,6 @@ "core/templates/AppSpec.ts", "core/templates/domain/skill/MisconceptionObjectFactorySpec.ts", "core/templates/domain/exploration/AnswerGroupObjectFactorySpec.ts", - "core/tests/puppeteer-acceptance-tests/specs/exploration-editor/modify-translations-through-modal.spec.ts", "core/tests/puppeteer-acceptance-tests/specs/exploration-editor/manage-exploration-misconceptions.spec.ts" ], "RUN_ALL_TESTS_ROOT_FILES": [ diff --git a/core/tests/test-modules-mappings/acceptance/exploration-editor/modify-translations-through-modal.txt b/core/tests/test-modules-mappings/acceptance/exploration-editor/modify-translations-through-modal.txt new file mode 100644 index 000000000000..5a5340af178c --- /dev/null +++ b/core/tests/test-modules-mappings/acceptance/exploration-editor/modify-translations-through-modal.txt @@ -0,0 +1,7 @@ +core/templates/pages/creator-dashboard-page/creator-dashboard-page.import.ts +core/templates/pages/exploration-editor-page/exploration-editor-page.import.ts +core/templates/pages/release-coordinator-page/release-coordinator-page.module.ts +core/templates/pages/skill-editor-page/skill-editor-page.import.ts +core/templates/pages/story-editor-page/story-editor-page.import.ts +core/templates/pages/topic-editor-page/topic-editor-page.import.ts +core/templates/pages/topics-and-skills-dashboard-page/topics-and-skills-dashboard-page.import.ts diff --git a/scripts/check_tests_are_captured_in_ci.py b/scripts/check_tests_are_captured_in_ci.py index 64d43c90ab1e..4b16c4ad04e9 100644 --- a/scripts/check_tests_are_captured_in_ci.py +++ b/scripts/check_tests_are_captured_in_ci.py @@ -30,7 +30,6 @@ E2E_TEST_SUITES_THAT_ARE_NOT_RUN_IN_CI = ['full'] ACCEPTANCE_TEST_SUITES_THAT_ARE_NOT_RUN_IN_CI = [ - 'exploration-editor/modify-translations-through-modal', 'exploration-editor/manage-exploration-misconceptions' ]