From 37aef3c58c39e3e9518fb686bf402ae6b9cc01b6 Mon Sep 17 00:00:00 2001 From: Emil Ghitta Date: Tue, 2 Apr 2024 14:05:49 +0300 Subject: [PATCH] - Enabling the capability of triggering specific test suites run on workflow dispatch --- .github/workflows/playwright.yml | 68 ++++++++++++++++--- .../aaq_tests/test_posted_questions.py | 10 ++- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4008d6c4f..0111224ed 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -13,6 +13,27 @@ on: options: - firefox - chrome + TestSuite: + description: Test Suite to run + required: true + default: All + type: choice + options: + - All + - homePageTests + - topNavbarTests + - footerSectionTests + - contributePagesTests + - messagingSystem + - User Pages + - contactSupportPage + - productSolutionsPage + - productTopicsPage + - AAQ + - KB Articles + - KB Restricted Visibility + - recentRevisionsDashboard + - kbDashboard env: TEST_ACCOUNT_12: ${{secrets.AUTOMATION_TEST_ACCOUNT_12}} @@ -66,20 +87,47 @@ jobs: working-directory: playwright_tests run: | poetry run pytest -m loginSessions --browser ${{ env.BROWSER }} --reruns 1 - - name: Run Playwright Tests + - name: Run ${{inputs.TestSuite}} Playwright Tests working-directory: playwright_tests if: success() || failure() && steps.create-sessions.outcome == 'success' run: | - declare -a tests=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "restrictedArticleCreation" "kbRestrictedVisibilitySingleGroup" "whitelistingDifferentGroup" "kbRestrictedVisibilityMultipleGroups" "removingAllArticleRestrictions" "kbRemovedRestrictions" "deleteAllRestrictedTestArticles") - for test in "${tests[@]}"; do - num_processes=2 - if [[ "$test" =~ ^(beforeThreadTests|afterThreadTests|restrictedArticleCreation|whitelistingDifferentGroup|removingAllArticleRestrictions|deleteAllRestrictedTestArticles)$ ]]; then - num_processes=1 + declare dispatch_test_suite="${{inputs.TestSuite}}" + declare all_test_suites=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "restrictedArticleCreation" "kbRestrictedVisibilitySingleGroup" "whitelistingDifferentGroup" "kbRestrictedVisibilityMultipleGroups" "removingAllArticleRestrictions" "kbRemovedRestrictions" "deleteAllRestrictedTestArticles") + if [ "$dispatch_test_suite" == "All" ] || [ "${{ github.event_name}}" == "schedule" ] ; then + for test in "${all_test_suites[@]}"; do + if ! poetry run pytest -m $test --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true + fi + done + elif [ "$dispatch_test_suite" == "User Pages" ]; then + for test in "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions"; do + if ! poetry run pytest -m ${test} --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true + fi + done + elif [ "$dispatch_test_suite" == "AAQ" ]; then + for test in "aaqPage" "postedQuestions"; do + if ! poetry run pytest -m ${test} --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true + fi + done + elif [ "$dispatch_test_suite" == "KB Articles" ]; then + for test in "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory"; do + if ! poetry run pytest -m ${test} --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true + fi + done + elif [ "$dispatch_test_suite" == "KB Restricted Visibility" ]; then + for test in "restrictedArticleCreation" "kbRestrictedVisibilitySingleGroup" "whitelistingDifferentGroup" "kbRestrictedVisibilityMultipleGroups" "removingAllArticleRestrictions" "kbRemovedRestrictions" "deleteAllRestrictedTestArticles"; do + if ! poetry run pytest -m ${test} --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true + fi + done + else + if ! poetry run pytest -m $dispatch_test_suite --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then + any_failures=true fi - if ! poetry run pytest -m $test --numprocesses $num_processes --browser ${{ env.BROWSER }} --reruns 1; then - any_failures=true - fi - done + fi echo "TESTS_FAILED=$any_failures" >> $GITHUB_ENV - name: Generating Allure Report working-directory: playwright_tests diff --git a/playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py b/playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py index 06e622ea8..23225a91f 100644 --- a/playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py +++ b/playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py @@ -4,7 +4,7 @@ import allure import pytest from pytest_check import check from playwright_tests.core.testutilities import TestUtilities -from playwright.sync_api import expect +from playwright.sync_api import expect,TimeoutError from playwright_tests.messages.contribute_messages.con_tools.moderate_forum_messages import ( ModerateForumContentPageMessages) @@ -2049,8 +2049,12 @@ class TestPostedQuestions(TestUtilities): with check, allure.step("Clicking on the Insert Response, post reply and verifying that " "the reply was successfully posted and contains the correct data"): self.sumo_pages.question_page._click_on_common_responses_insert_response_button() - reply_id = self.sumo_pages.question_page._click_on_post_reply_button(username) - assert self.sumo_pages.question_page._get_text_content_of_reply(reply_id) in response + try: + reply_id = self.sumo_pages.question_page._click_on_post_reply_button(username) + except TimeoutError: + reply_id = self.sumo_pages.question_page._click_on_post_reply_button(username) + assert self.sumo_pages.question_page._get_text_content_of_reply( + reply_id).strip() in response.strip() with allure.step("Signing in with an admin account and deleting the posted question"): self.start_existing_session(super().username_extraction_from_email(