Merge pull request #5945 from emilghittasv/playwright-dispatch-event-improvements

Playwright - Enabling specific test suite run for workflow dispatch
This commit is contained in:
Ryan Johnson 2024-04-05 11:14:10 -07:00 коммит произвёл GitHub
Родитель c0ee92dc3b 37aef3c58c
Коммит f84a2f2c36
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 65 добавлений и 13 удалений

68
.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

Просмотреть файл

@ -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(