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

Test/create account #1698

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
159 changes: 106 additions & 53 deletions packages/playwright/src/e2e/01-create-account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,119 @@
import { expect } from '@playwright/test'
import { faker } from '@faker-js/faker'
import { expect, test } from '@playwright/test'

import { test } from '../fixtures'
import { generateRandomUser } from '../utils'
import { RegisterPage } from '../pages/Register'

test.describe('01. Create Account', () => {
test('TC-01: should register', async ({ registerPage, layoutPage }) => {
// Function that generates random user information
function generateRandomUser() {
const name = faker.person.firstName()
const username = faker.internet.userName()
const email = faker.internet.email()
const password = '2Wsx.2Wsx.' // Sabit şifre

return { name, username, email, password }
}

// Go to the registration page before each test
test.beforeEach(async ({ page }) => {
const registerPage = new RegisterPage(page)
await registerPage.navigateToRegister('kunsthalte')
})

test.describe('01.create-account ', () => {
test('TC-01: should Happy flow ', async ({ page }) => {
const registerPage = new RegisterPage(page)
const { name, username, email, password } = generateRandomUser()

await registerPage.navigateToRegister('kunsthalte')
await registerPage.register({ name, username, email, password })

await layoutPage.logout()
await page.getByRole('button', { name }).click() // Click on the button named "name"
const buttonText = await page
.getByTestId('button-m-profile-menu')
.innerText()
await expect(buttonText).toContain(name)
await page.click('[data-testid="button-d-logout"]') // Log out
})
})

test('TC-02: should not register with empty email', async ({
page,
registerPage,
}) => {
const { name, username, password } = generateRandomUser()
test('TC-02: should Negative flow (Leave Email Field Blank)', async ({
page,
}) => {
const registerPage = new RegisterPage(page)
const { name, username, password } = generateRandomUser()

await registerPage.navigateToRegister('kunsthalte')
await registerPage.register({ name, username, email: '', password })
await registerPage.register({ name, username, email: '', password }) // Leave email field blank

await expect(page.getByTestId('error-text-email')).toBeVisible()
await page.waitForTimeout(1000)
})
await expect(page.getByTestId('error-text-email')).toBeVisible() // Error message checking
})

test('TC-03: should not register with invalid email', async ({
page,
registerPage,
}) => {
const { name, username, password } = generateRandomUser()

await registerPage.navigateToRegister('kunsthalte')
await registerPage.register({
name,
username,
email: 'invalid-email',
password,
})

await expect(page.getByTestId('error-text-email')).toBeVisible()
await page.waitForTimeout(1000)
})
test('TC-03: should Negative flow (Invalid e-mail address)', async ({
page,
}) => {
const registerPage = new RegisterPage(page)
const { name, username, password } = generateRandomUser()

test('TC-04: should not register with invalid password', async ({
page,
registerPage,
}) => {
const { name, username, email } = generateRandomUser()

await registerPage.navigateToRegister('kunsthalte')
const INVALID_PASSWORD = '123'
await registerPage.register({
name,
username,
email,
password: INVALID_PASSWORD,
})

await expect(page.getByTestId('error-text-password')).toBeVisible()
await page.waitForTimeout(1000)
page.close()
})
await registerPage.register({
name,
username,
email: 'invalid-email',
password,
}) // Invalid email
await expect(page.getByTestId('error-text-email')).toBeVisible() // Error message checking
})

test('TC-04: should Negative flow (login with invalid information)', async ({
page,
}) => {
const registerPage = new RegisterPage(page)
const { name, username, email, password } = generateRandomUser()

await registerPage.register({ name, username, email, password })
await page.click('button:has-text("TR")')

await page.getByTestId('link-d/login').click() // Go to login page

await page.getByTestId('input-identifier').click()
await page.getByTestId('input-identifier').fill(email) // Nonexistent email

await page.getByTestId('input-password').click()
await page.getByTestId('input-password').fill(password + 'aaa') // Invalid password

await page.getByTestId('button-submit-login').click() // Click "Log in" button

await expect(page.getByTestId('error-auth')).toBeVisible() // Error message checking
})
test('TC-05: should Negative flow (Invalid name field)', async ({ page }) => {
const registerPage = new RegisterPage(page)

const invalidName = 'Jo1?!@' // 2. 'name' field with invalid characters (numbers, question marks and special characters)
const { username, email, password } = generateRandomUser()

await registerPage.register({
name: invalidName,
username,
email,
password,
}) // Invalid 'name' field

await expect(page.getByTestId('error-text-name')).toBeVisible() // Error message checking
})
test('TC-06: should Negative flow (Name field with less than 3 characters)', async ({
page,
}) => {
const registerPage = new RegisterPage(page)

const shortName = 'Jo' // 'name' field with less than 3 characters
const { username, email, password } = generateRandomUser()

// await registerPage.navigateToRegister('kunsthalte')
await registerPage.register({
name: shortName,
username,
email,
password,
}) // 'name' field with less than 3 characters

await expect(page.getByTestId('error-text-name')).toBeVisible() // Error message checking

page.close()
})
1 change: 0 additions & 1 deletion packages/playwright/src/pages/Register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class RegisterPage {
await this.usernameInput.fill(username)
await this.emailInput.fill(email)
await this.passwordInput.fill(password)

await this.submitButton.click()
}
}