Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inna-ianko committed Oct 15, 2024
1 parent 3499dc1 commit 29c6ae3
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# qa_pw_visibility_assertions
Playwright: practice working with expect(locator).toBeVisible() assertion.
106 changes: 106 additions & 0 deletions package-lock.json

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

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "qa_pw_intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"fsevents": "^2.3.2",
"playwright-core": "^1.46.1"
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@types/node": "^22.5.2"
},
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC"
}
68 changes: 68 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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: false,
/* 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 ? 0 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : 1,
/* 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: {
/* 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',
},

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

/* 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,
// },
});
21 changes: 21 additions & 0 deletions tests/signInFormElements.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from '@playwright/test';

test('`Sign in` form elements presence', async ({ page }) => {
/*
1. Go to the Conduit Sign-in page https://conduit.mate.academy/user/login
2. Assert that the header 'Sign in' is visible
3. Assert that the link 'Need an account?' is visible
4. Assert that the input field 'Email' is visible
5. Assert that the input field 'Password' is visible
6. Assert that the button 'Sign in' is visible
*/

await page.goto('https://conduit.mate.academy/user/login');

await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Need an account?' })).toBeVisible();
await expect(page.getByPlaceholder('Email')).toBeVisible();
await expect(page.getByPlaceholder('Password')).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible();

});
14 changes: 14 additions & 0 deletions tests/signUpFormElements.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test, expect } from '@playwright/test';

test('`Sign up` form elements presence', async ({ page }) => {
/*
1. Go to the Conduit Sign-up page https://conduit.mate.academy/user/register
2. Assert that the header 'Sign up' is visible
3. Assert that the link 'Have an account?' is visible
4. Assert that the input field 'Username' is visible
5. Assert that the input field 'Email' is visible
6. Assert that the input field 'Password' is visible
7. Assert that the button 'Sign up' is visible
*/

});

0 comments on commit 29c6ae3

Please sign in to comment.