Skip to content

Commit

Permalink
Merge pull request #478 from neonlabsorg/add-dockerize-ui-tests-for-a…
Browse files Browse the repository at this point in the history
…ll-branches

Add dockerize UI tests for all branches
  • Loading branch information
e-b-e-d-a authored Jan 20, 2025
2 parents b95023d + 909e31f commit 5ba0891
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
60 changes: 44 additions & 16 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,46 @@ on:
- cron: "0 3 * * 0,1,2,3,4"
workflow_dispatch:

env:
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
IMAGE_NAME: ${{ github.repository_owner }}/neon_tests
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
CONTAINER_NAME: neon_tests
NETWORK: "devnet"

jobs:
test:
dockerize:
name: Dockerize neon tests
if: ${{ github.ref_name != 'develop' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dockerize neon tests
uses: ./.github/actions/dockerize-neon-tests
with:
image_tag: ${{ github.sha }}
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
image_name: ${{ env.IMAGE_NAME }}
docker_hub_org_name: ${{ env.DOCKER_HUB_ORG_NAME }}
- name: "Define image tag"
id: image_tag
uses: ./.github/actions/define-image-tag
outputs:
tag: ${{ steps.image_tag.outputs.tag }}

env:
IMAGE_NAME: ${{ github.repository_owner }}/neon_tests
CHROME_EXT_PASSWORD: ${{ secrets.CHROME_EXT_PASSWORD }}
CONTAINER_NAME: neon_tests
NETWORK: "devnet"
test:
needs: dockerize
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set IMAGE_TAG
id: image-tag
run: |
GITHUB_REF="${{ github.ref }}"
IMAGE_TAG="${GITHUB_REF#refs/heads/}"
echo "IMAGE_TAG=$IMAGE_TAG" | tee -a $GITHUB_OUTPUT
- name: Run tests container
id: run-container
run: |
IMAGE=${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.IMAGE_TAG }}
IMAGE=${{ env.IMAGE_NAME }}:${{ needs.dockerize.outputs.tag }}
docker run -d --name ${{ env.CONTAINER_NAME }} $IMAGE tail -f /dev/null
- name: Install Chrome
Expand All @@ -46,7 +61,7 @@ jobs:
- name: Run tests
id: run-tests
run:
run: |
docker exec -i ${{ env.CONTAINER_NAME }} bash -c "CHROME_EXT_PASSWORD=${{ secrets.CHROME_EXT_PASSWORD }} python3 clickfile.py run ui --network ${{ env.NETWORK }}"
- name: "Generate allure report"
Expand All @@ -57,4 +72,17 @@ jobs:
network: ${{ env.NETWORK }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
tests_name: ui
tests_name: ui

notify:
name: Send notification on failure
needs: test
if: failure() && github.ref_name == 'develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Notify on failure"
run: |
docker exec -i ${{ env.CONTAINER_NAME }} \
python3 ./clickfile.py send-notification -u ${{ secrets.SLACK_QA_CHANNEL_URL }} \
-b ${{ env.BUILD_URL }} --network ${{ env.NETWORK }} --test-group ui
6 changes: 6 additions & 0 deletions ui/tests/website_tests/test_MainPage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pytest
from sqlalchemy.testing import skip_test

from ui.tests.website_tests.conftest import google_forms_page, menu_page, developers_page, main_page, \
ecosystem_page, quick_start_page

Expand All @@ -19,12 +22,14 @@ def test_logo_footer(self,main_page, menu_page, developers_page):
def test_click_build_on_neon_button(self, main_page, menu_page, developers_page):
main_page.click_on_build_on_neon_button()
main_page.switch_window(1)
main_page.assert_windows_count(2)
developers_page.assert_page_url()
developers_page.assert_text_on_build_on_neon_block_link()

def test_click_start_building_button(self, main_page, quick_start_page):
main_page.click_start_building_button()
main_page.switch_window(1)
main_page.assert_windows_count(2)
quick_start_page.assert_page_url()
quick_start_page.assert_text_on_quick_start_page_title()

Expand All @@ -41,5 +46,6 @@ def test_explore_developer_hub_button(self, main_page, developers_page):
def test_add_your_dapp_button(self, main_page, google_forms_page):
main_page.click_add_your_dapp_button()
main_page.switch_window(1)
main_page.assert_windows_count(2)
google_forms_page.assert_page_url()
google_forms_page.assert_text_on_googleform_title()
9 changes: 8 additions & 1 deletion utils/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ def assert_page_url(self,url=None):
assert url == current_url, f"The url is {current_url}"

def switch_window(self,index:int):
self.driver.switch_to.window(self.driver.window_handles[index])
WebDriverWait(self.driver, 10).until(
lambda driver: len(driver.window_handles) > index
)
self.driver.switch_to.window(self.driver.window_handles[index])

def assert_windows_count(self,expected_windows_count:int):
assert len(self.driver.window_handles) == expected_windows_count, \
f"Expected {expected_windows_count} windows, but found {len(self.driver.window_handles)}"

0 comments on commit 5ba0891

Please sign in to comment.