Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gleb avrorin #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Gleb avrorin #6

wants to merge 5 commits into from

Conversation

GlebAvr
Copy link

@GlebAvr GlebAvr commented Sep 10, 2024

Setup Instructions

1. Prerequisites

Ensure you have Node.js installed (version 20 is recommended).
Ensure npm is installed (it comes with Node.js).
Install Dependencies

Install all required dependencies by running:

cd sdet-assignment
npm install

Running Tests Locally

1. Execute Cypress Tests

Run Cypress tests locally using the following command:

npm run test

2. Run Cypress Tests from the UI

To open the Cypress Test Runner and run tests interactively, use:
npx cypress open

This command launches the Cypress Test Runner, allowing you to manually run and debug your tests.

Running Tests in GitHub Actions

1.GitHub Actions Workflow

The GitHub Actions workflow is set up to automatically run Cypress tests on code push, pull requests, and manual triggers. The configuration is found in .github/workflows/cypress.yml.

name: Cypress Tests

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  cypress-e2e:
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Install dependencies
        run: npm install

      - name: Run e2e Tests
        run: npx cypress run --spec 'cypress/e2e/' --reporter mochawesome --reporter-options "reportDir=cypress/reports,overwrite=false,html=false,json=true"

      - name: Upload Mochawesome Reports as Artifact
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: mochawesome-reports
          path: cypress/reports/*.json

      - name: Download Mochawesome Reports Artifact
        uses: actions/download-artifact@v4
        with:
          name: mochawesome-reports
          path: ./downloaded-reports
      
      - name: Zip the downloaded reports
        run: |
          zip -r ./downloaded-reports/mochawesome-reports.zip ./downloaded-reports
  
      - name: Upload ZIP file to Uploadcare
        env: 
          UPLOADCARE_PUB_KEY: ${{ secrets.UPLOADCARE_PUBLIC_KEY }}
        run: |
          curl -F "UPLOADCARE_PUB_KEY=${UPLOADCARE_PUB_KEY}" \
               -F "file=@./downloaded-reports/mochawesome-reports.zip" \
               -F "UPLOADCARE_STORE=auto" \
               "https://upload.uploadcare.com/base/"

Changes Introduced

1. New Tests

profilePage.spec.cy.js: Verifies that users can update their avatar with either JPG or PNG formats and that only image files are accepted.
registrationPage.spec.cy.js:

  • Should Sign Up using valid data as Owner/Property Manager
  • Should be able to Login with existing/created account and Logout
  • Should see error messages when signing up with empty data
  • Should Not sign up with invalid email format(no '@' symbol)
  • Should Not sign up with invalid amount of password chars (less then 12)
  • Should Not Log in with invalid user data

searchPage.spec.cy.js:

  • Should search by Keyword
  • Should search by City using helper
  • Should turn the map on/off
  • Should search by Property type
  • Should filter search by Price

profilePage.spec.cy.js:

  • Should change Profile Photo with Valid PNG format
  • Should change Profile Photo with Valid JPG format
  • Should throw error if using wrong format (MP4)

2. Custom Configuration

  • Customize Cypress settings in cypress.config.js. Includes retry logic for test failures (retries: 3).
  • Current viewport is set to
     viewportWidth: 1920,
    viewportHeight: 1080,

3. Mochaawesome Reporting
Added Mochaawesome reporter to generate comprehensive test reports and upload them to Uploadcare website (https://uploadcare.com/)

4. Additional Libraries:
Integrated the realcypress library for more reliable element interactions, such as clicking, mouse hover and other interactions.

5. Other:

  • Intercepts: Used cy.intercept for more precise waiting and control over network requests.
  • Page Object Model (POM): Implemented the Page Object Model pattern to organize test code and enhance maintainability.
  • API Integration: Added an API for login to reduce test execution time and streamline the login process.
  • Each beforeEach has clearCookies and clearLocalStorage to enuse that env is clean for every new test.
  • All data like credentials, verification messages are kept within /cypress/fixtures folder

additional comments:
@sviataslau

  • if I would have access to API documentation , I would use after hooks to delete data after any data creation tests (to keep DB clean)
  • if there would be access to DB I would confirm that user/listing successfully created and is kept within DB.
  • all sensitive data would be saved under env or secrets (whatever if preferred)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant