Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into e2e-speed-imporove…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
szymon-kellton committed Nov 14, 2024
2 parents 84e17b5 + b100f3e commit f3d0996
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 18 deletions.
49 changes: 43 additions & 6 deletions tests/selenium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,31 @@ sh -c "cd .. && docker build . -f ./docker/Dockerfile --target dev --tag unicef/

<b><h2>How to run tests locally on Macs with M1/M2/M3:</h2></b>

<b><h3>Preconditions:</h3></b>
- Check your arch
```bash
arch
```
The result should be **arm64**.


<b><h3>Installation:</h3></b>
```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"
Expand All @@ -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 -
Expand All @@ -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
```

<b><h3>Hints:</h3></b>
- 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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 11 additions & 6 deletions tests/selenium/payment_module/test_payment_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f3d0996

Please sign in to comment.