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

Feature/tests ci #8

Merged
merged 11 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE_URL=https://team8-2022brno.herokuapp.com
[email protected]
ADMIN_PASSWORD=${ADMIN_PASSWORD}
29 changes: 29 additions & 0 deletions .github/workflows/playwright-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Playwright Tests
on:
push:
branches:
- main
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.49.1-noble
options: --user 1001
env:
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Run Playwright tests
run: npx playwright test --grep @ci
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
24 changes: 12 additions & 12 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "automation-playwright",
"version": "1.0.0",
"devDependencies": {
"@playwright/test": "^1.47.2",
"@playwright/test": "^1.49.1",
"@types/node": "^20.14.11",
"dotenv": "^16.4.5",
"eslint": "^9.9.1",
"playwright-bdd": "^7.5.0"
},
"scripts": {}
}
}
8 changes: 3 additions & 5 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// @ts-check
require('dotenv').config();

require('dotenv').config({ path: '.env.testing' });
const { defineConfig, devices } = require('@playwright/test');
const { BASE_URL } = process.env;

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './src/tests',
testDir: "./src/examples",
// testDir: './src/examples',
/* Run tests in files in parallel */
fullyParallel: false,
Expand All @@ -19,7 +18,7 @@ module.exports = defineConfig({
/* 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',
reporter: [["html", { outputFolder: "playwright-report", open: "never" }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
Expand Down Expand Up @@ -74,4 +73,3 @@ module.exports = defineConfig({
// reuseExistingServer: !process.env.CI,
// },
});

14 changes: 7 additions & 7 deletions src/examples/08-page-objects/login.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Lesson 8: Code organization: Page Object Model - Exercise 1
*/
import {username, password, userFullName, ApplicationTexts} from '../../fixtures/fixtures.js'
import {expect, test} from "@playwright/test";
import {LoginPage} from "./pages/login.page";
import { expect, test } from "@playwright/test";
import { ApplicationTexts, password, userFullName, username } from '../../fixtures/fixtures.js';
import { LoginPage } from "./pages/login.page";

test.describe('Login Page', async () => {

Expand All @@ -13,7 +13,7 @@ test.describe('Login Page', async () => {
await test.expect(page).toHaveTitle(ApplicationTexts.loginPage.title);
});

test('should show login form', async ({ page }) => {
test('should show login form', { tag: "@ci" }, async ({ page }) => {
const loginPage = new LoginPage(page);

await expect(loginPage.emailField, 'email field should be visible').toBeVisible();
Expand All @@ -26,7 +26,7 @@ test.describe('Login Page', async () => {
await expect(loginPage.loginButton, 'login button text should have text').toHaveText('Přihlásit');
});

test('should login with valid credentials', async ({page}) => {
test('should login with valid credentials', { tag: "@ci" }, async ({page}) => {
const loginPage = new LoginPage(page);

// await loginPage.emailField.fill(username);
Expand All @@ -38,7 +38,7 @@ test.describe('Login Page', async () => {
await expect(loginPage.usernameDropdown).toHaveText(userFullName);
});

test('should not login with invalid credentials', async ({ page }) => {
test('should not login with invalid credentials',{ tag: "@ci" }, async ({ page }) => {
const loginPage = new LoginPage(page);
// const emailField = getEmailField(page);
// const passwordField = getPasswordField(page);
Expand All @@ -58,7 +58,7 @@ test.describe('Login Page', async () => {
await expect(loginPage.loginButton).toBeVisible();
});

test('should logout', async ({ page }) => {
test('should logout', { tag: "@ci" }, async ({ page }) => {
const loginPage = new LoginPage(page);

// await loginPage.emailField.fill(username);
Expand Down