Skip to content

Commit

Permalink
home assignment solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayLevi committed Aug 1, 2024
1 parent 33d7d8d commit b57c5c3
Show file tree
Hide file tree
Showing 13 changed files with 493 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
.env
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# shay-automation-task
# shay-automation-task

This project is the automation home assignment - https://docs.google.com/document/d/1ixrNCz_rgYYVfeGnUi9ZnBL-OUsqvsP4IaxIAuguRWk/edit

## Prerequisites

Before you begin, ensure you have met the following requirements:

- Node.js (version 18.x or later)
- pnpm (version 8.x or later)
- Access to Cloudinary account credentials

## Setup

1. **Clone this Repository**
2. Install the project dependencies using pnpm:
pnpm install
3. Create a .env file in the root directory of the project and add your Cloudinary credentials:
EMAIL=your-email
PASSWORD=your-password
**Make sure to replace your-email and your-password with your actual Cloudinary credentials**
4. Install Playwright:
pnpm exec playwright install
5. To run the tests, use the following command:
pnpm exec playwright test
69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "shay-automation-task",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.5",
"playwright": "^1.45.3",
"uuid": "^10.0.0"
},
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/node": "^22.0.0"
}
}
82 changes: 82 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Set timeout to 50 sec */
timeout: 60000,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
headless: false,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
74 changes: 74 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tests/pom/assetManagePage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Locator, Page} from '@playwright/test';

const ASSET_TITLE_SELECTOR = "//*[@data-test='manage-top-bar']//*[@data-test='asset-title']";;


/**
* Asset manage page object
*/
export class AssetManagePage {
public page: Page;
public assetTitle: Locator

constructor(page: Page) {
this.page = page;
this.assetTitle = page.locator(ASSET_TITLE_SELECTOR);
}
}
37 changes: 37 additions & 0 deletions tests/pom/loginPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Locator, Page} from '@playwright/test';

const EMAIL_FIELD_SELECTOR = "//*[@id='user_session_email']";
const PASSWORD_FIELD_SELECTOR = "//*[@id='user_session_password']";
const LOGIN_BUTTON_SELECTOR = "//*[@id='sign-in']";


/**
* Login page object
*/
export class LoginPage {
public page: Page;
public emailInput: Locator;
public passwordInput: Locator;
public loginButton: Locator;


constructor(page: Page) {
this.page = page;
this.emailInput = page.locator(EMAIL_FIELD_SELECTOR);
this.passwordInput = page.locator(PASSWORD_FIELD_SELECTOR);
this.loginButton = page.locator(LOGIN_BUTTON_SELECTOR);
}

/**
* Make login
*/
public async login(email: string, password: string) {
await this.emailInput.fill(email);
await this.passwordInput.fill(password);
await this.loginButton.click();
}

public async goto(): Promise<void> {
await this.page.goto('https://console-staging.cloudinary.com/users/login');
}
}
Loading

0 comments on commit b57c5c3

Please sign in to comment.