diff --git a/tests/selenium/README.md b/tests/selenium/README.md index 6f972b19c2..1a9bf51477 100644 --- a/tests/selenium/README.md +++ b/tests/selenium/README.md @@ -13,13 +13,31 @@ sh -c "cd .. && docker build . -f ./docker/Dockerfile --target dev --tag unicef/

How to run tests locally on Macs with M1/M2/M3:

+

Preconditions:

+- Check your arch +```bash +arch +``` +The result should be **arm64**. + +

Installation:

```bash -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +- Check your brew config +```bash +brew config +``` +The result of HOMEBREW_PREFIX should be /opt/homebrew + +```bash curl https://pyenv.run | bash brew install pyenv vim ~/.zshrc ``` + Include the following in the file: ```bash export PYENV_ROOT="$HOME/.pyenv" @@ -30,8 +48,8 @@ eval "$(pyenv virtualenv-init -)" - In new terminal tab ```bash -pyenv install 3.11.7 -pyenv virtualenv 3.11.7 new-venv +pyenv install 3.12.7 +pyenv virtualenv 3.12.7 new-venv pyenv activate new-venv brew install pdm curl -sSL https://pdm-project.org/install-pdm.py | python - @@ -45,10 +63,29 @@ brew install wkhtmltopdf pango postgis gdal ```bash pyenv activate new-venv cd src -source ../development_tools/local_selenium_env.sh +brew install nvm +nano ~/.bash_profile +``` +- Include the following in the file: +```bash +export NVM_DIR=~/.nvm +source $(brew --prefix nvm)/nvm.sh +. "$HOME/.cargo/env" +``` +- In terminal: +```bash +source ~/.bash_profile +source ../development_tools/local_selenium_init.sh # second tab: -docker compose -f ../development_tools/compose.selenium.local.yml up --build +docker compose -f ./development_tools/compose.yml --profile services up --build # first tab: -python -m pytest -svvv ../tests/selenium --html-report=../tests/selenium/report/report.html +python -m pytest -n auto -rP --reuse-db -p no:warnings --cov-report= --capture=sys --html-report=$OUTPUT_DATA_ROOT/report/report.html tests/selenium +``` + +

Hints:

+- Uninstall brew from wrong path (in this case /usr/local): +```bash +curl -fsSLO https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh +/bin/bash uninstall.sh --path /usr/local ``` \ No newline at end of file diff --git a/tests/selenium/page_object/payment_module/payment_module_details.py b/tests/selenium/page_object/payment_module/payment_module_details.py index 748ee382f5..b1c3ce466f 100644 --- a/tests/selenium/page_object/payment_module/payment_module_details.py +++ b/tests/selenium/page_object/payment_module/payment_module_details.py @@ -73,7 +73,9 @@ def getButtonLockPlan(self) -> WebElement: return self.wait_for(self.buttonLockPlan) def getButtonSubmit(self) -> WebElement: - return self.wait_for(self.buttonSubmit) + submit_button = self.wait_for(self.buttonSubmit) + self.element_clickable(self.buttonSubmit) + return submit_button def getPageHeaderContainer(self) -> WebElement: return self.wait_for(self.pageHeaderContainer) @@ -237,21 +239,41 @@ def getButtonNextSave(self) -> WebElement: def getButtonSendForApproval(self) -> WebElement: return self.wait_for(self.buttonSendForApproval) + def clickButton(self, locator: str) -> None: + self.wait_for(locator) + self.element_clickable(locator) + sleep(5) + self.get(locator).click() + + def clickButtonSendForApproval(self) -> None: + self.clickButton(self.buttonSendForApproval) + def getButtonApprove(self) -> WebElement: return self.wait_for(self.buttonApprove) + def clickButtonApprove(self) -> None: + self.clickButton(self.buttonApprove) + + def clickButtonLockPlan(self) -> None: + self.clickButton(self.buttonLockPlan) + def getButtonAuthorize(self) -> WebElement: return self.wait_for(self.buttonAuthorize) + def clickButtonAuthorize(self) -> None: + self.clickButton(self.buttonAuthorize) + + def clickButtonMarkAsReleased(self) -> None: + self.clickButton(self.buttonMarkAsReleased) + + def clickButtonExportXlsx(self) -> None: + self.clickButton(self.buttonExportXlsx) + def getButtonMarkAsReleased(self) -> WebElement: return self.wait_for(self.buttonMarkAsReleased) def checkStatus(self, status: str) -> None: - for _ in range(30): - if status == self.getStatusContainer().text: - break - sleep(1) - assert status in self.getStatusContainer().text + self.wait_for_text(status, self.statusContainer) def getSupportingDocumentsTitle(self) -> WebElement: return self.wait_for(self.supportingDocumentsTitle) diff --git a/tests/selenium/payment_module/test_payment_plans.py b/tests/selenium/payment_module/test_payment_plans.py index b82c7cf99e..a381b9d080 100644 --- a/tests/selenium/payment_module/test_payment_plans.py +++ b/tests/selenium/payment_module/test_payment_plans.py @@ -492,21 +492,26 @@ def test_payment_plan_happy_path( pagePaymentModuleDetails.select_listbox_element("FSP_1") pagePaymentModuleDetails.getButtonNextSave().click() pagePaymentModuleDetails.checkStatus("LOCKED") - pagePaymentModuleDetails.getButtonLockPlan().click() + pagePaymentModuleDetails.clickButtonLockPlan() pagePaymentModuleDetails.getButtonSubmit().click() + pagePaymentModuleDetails.checkAlert("Payment Plan FSPs are locked.") pagePaymentModuleDetails.checkStatus("LOCKED FSP") - pagePaymentModuleDetails.getButtonSendForApproval().click() + pagePaymentModuleDetails.clickButtonSendForApproval() + pagePaymentModuleDetails.checkAlert("Payment Plan has been sent for approval.") pagePaymentModuleDetails.checkStatus("IN APPROVAL") - pagePaymentModuleDetails.getButtonApprove().click() + pagePaymentModuleDetails.clickButtonApprove() pagePaymentModuleDetails.getButtonSubmit().click() + pagePaymentModuleDetails.checkAlert("Payment Plan has been approved.") pagePaymentModuleDetails.checkStatus("IN AUTHORIZATION") - pagePaymentModuleDetails.getButtonAuthorize().click() + pagePaymentModuleDetails.clickButtonAuthorize() pagePaymentModuleDetails.getButtonSubmit().click() + pagePaymentModuleDetails.checkAlert("Payment Plan has been authorized") pagePaymentModuleDetails.checkStatus("IN REVIEW") - pagePaymentModuleDetails.getButtonMarkAsReleased().click() + pagePaymentModuleDetails.clickButtonMarkAsReleased() pagePaymentModuleDetails.getButtonSubmit().click() + pagePaymentModuleDetails.checkAlert("Payment Plan has been marked as reviewed.") pagePaymentModuleDetails.checkStatus("ACCEPTED") - pagePaymentModuleDetails.getButtonExportXlsx().click() + pagePaymentModuleDetails.clickButtonExportXlsx() pagePaymentModuleDetails.checkAlert("Exporting XLSX started") # ToDo: Refresh is workaround. Works on dev properly.