-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pages review
#1695
Open
7alip
wants to merge
10
commits into
test/pages
Choose a base branch
from
test/pages-review
base: test/pages
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test
Pages review
#1695
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
af3af7a
Update switch language timeout
7alip 32dbb69
Update packages
7alip d671cbc
Update packages
7alip 0bee720
Fix data-testid
7alip ced6dd5
Merge branch 'dev' into test/pages
7alip 0d4e641
Add data-testid
7alip 52ab004
Commit
7alip b9b7ad4
Add contact form data-testid
7alip 48d9a1e
Merge branch 'dev' into test/pages-review
7alip e67bff5
Add Contact POM
7alip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,63 @@ | ||
import { expect } from '@playwright/test' | ||
|
||
import { test } from '../fixtures' | ||
import { getUrl, checkExternalLink } from '../utils' | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(getUrl('kunsthalte')) | ||
await page.waitForTimeout(1000) | ||
await page.click('button:has-text("EN")') | ||
import { checkExternalLink } from '../utils' | ||
|
||
test.beforeEach(async ({ page, layoutPage }) => { | ||
await layoutPage.gotoHome('kunsthalte') | ||
await layoutPage.gotoPage('contact') | ||
await page.waitForLoadState() | ||
}) | ||
|
||
test.describe('08. Contact required field control', () => { | ||
test('TC-01: should Contact', async ({ page, layoutPage }) => { | ||
await layoutPage.gotoPage('contact') | ||
await page.getByTestId('input-fullname').click() | ||
await page.getByTestId('input-email').click() | ||
await page.getByTestId('input-message').click() | ||
await page.getByTestId('input-fullname').click() | ||
const fullNameErrorMessage = await page.locator( | ||
'[data-testid="error-text-fullname"]', | ||
) | ||
const isDivVisible = await fullNameErrorMessage.isVisible() | ||
await expect(isDivVisible).toBe(true) // 03. Is Your Full Name a required field? // bakılacak | ||
|
||
const requiredTextEmail = page.getByTestId('error-text-email') | ||
await expect(requiredTextEmail).toBeVisible() // 04. Is email a required field? | ||
|
||
const emailInput = await page.locator('[data-testid="input-email"]') | ||
const testEmailError = 'test_example.com' | ||
await emailInput.fill(testEmailError) | ||
const requiredTextEmailError = await page.locator( | ||
'[data-testid="error-text-email"]', | ||
) | ||
|
||
const isTextVisibleEmailError = await requiredTextEmailError.isVisible() | ||
await expect(isTextVisibleEmailError).toBe(true) | ||
const testEmail = '[email protected]' | ||
await emailInput.fill(testEmail) | ||
const emailValue = await emailInput.inputValue() | ||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ | ||
|
||
const isValidEmail = emailRegex.test(emailValue) | ||
expect(isValidEmail).toBe(true) // 05. Assert that the email is valid | ||
const requiredTextMessage = await page.locator( | ||
'[data-testid="error-text-message"]', | ||
) | ||
const isTextVisibleMessage = await requiredTextMessage.isVisible() | ||
await expect(isTextVisibleMessage).toBe(true) // 06. Is Message a required field? | ||
test('TC-01: should Contact', async ({ page, contactPage }) => { | ||
await contactPage.fullnameInput.focus() | ||
await contactPage.emailInput.focus() | ||
await contactPage.messageInput.focus() | ||
await contactPage.messageInput.blur() | ||
|
||
const fullNameErrorMessage = page.getByTestId('error-text-fullname') | ||
const emailErrorMessage = page.getByTestId('error-text-email') | ||
const messageErrorMessage = page.getByTestId('error-text-message') | ||
|
||
await expect(fullNameErrorMessage).toBeVisible() // 03. Is Your Full Name a required field? // bakılacak | ||
await expect(emailErrorMessage).toBeVisible() // 04. Is email a required field? | ||
await expect(messageErrorMessage).toBeVisible() // 05. Assert that message is required | ||
|
||
const invalidEmail = 'test_example.com' | ||
await contactPage.emailInput.fill(invalidEmail) | ||
contactPage.emailInput.blur() | ||
await expect(emailErrorMessage).toBeVisible() // 06. Assert that the email is invalid | ||
}) | ||
|
||
test('TC-02: should send message via contact form', async ({ | ||
page, | ||
layoutPage, | ||
contactPage, | ||
}) => { | ||
await layoutPage.gotoPage('contact') | ||
await page.waitForTimeout(1000) | ||
await page.getByPlaceholder('Your Full Name').fill('Test Mustafa BUDAK') | ||
|
||
const emailInput = await page.locator('[data-testid="input-email"]') | ||
const testEmail = '[email protected]' | ||
await emailInput.fill(testEmail) | ||
|
||
await page.getByPlaceholder('Message').fill('This is a Test Message.') | ||
await page.waitForTimeout(5000) | ||
await page.getByRole('button', { name: 'Send message' }).click() | ||
await page.waitForTimeout(2000) | ||
const successDiv = await page.textContent('div[data-status="success"]') | ||
expect(successDiv).toBe('Thank you. Your message has been delivered.') // 07. Can the user send the message successfully ? | ||
await contactPage.sendContactMessage() | ||
// It may not always work because of the captcha protection | ||
await expect(contactPage.successAlert).toBeVisible() // 07. Can the user send the message successfully ? | ||
}) | ||
test('TC-03: should Check if it is redirected to another page ', async ({ | ||
page, | ||
layoutPage, | ||
}) => { | ||
await layoutPage.gotoPage('contact') | ||
const emaillink = page.locator('a[href^="mailto:"]') | ||
await expect(emaillink).toBeVisible() // 08. When clicking on the email address icon, the user should be directed to the Outlook application. | ||
const xElement = page.getByLabel('X').first() | ||
await checkExternalLink(xElement, 'https://x.com/kunsthalte') // 09. When clicking on the xcom icon, the user should be directed to another page. | ||
test('TC-03: should social links work', async ({ contactPage }) => { | ||
await expect(contactPage.socialLinks.email).toBeVisible() // 08. When clicking on the email address icon, the user should be directed to the Outlook application. | ||
|
||
const WhatsAppElement = page.getByLabel('WhatsApp').first() | ||
await checkExternalLink( | ||
WhatsAppElement, | ||
contactPage.socialLinks.x, | ||
'https://x.com/kunsthalte', | ||
) // 09. When clicking on the xcom icon, the user should be directed to another page. | ||
|
||
await checkExternalLink( | ||
contactPage.socialLinks.whatsapp, | ||
'https://api.whatsapp.com/send?phone=31685221308', | ||
) // 10. When clicking on the WhatsApp icon, the user should be directed to another page. | ||
|
||
const InstagramElement = page.getByLabel('Instagram').first() | ||
await checkExternalLink( | ||
InstagramElement, | ||
contactPage.socialLinks.instagram, | ||
'https://instagram.com/kunsthalte', | ||
) // 11. When clicking on the Instagram icon, the user should be directed to another page. | ||
const YoutubeElement = page.getByLabel('Youtube').first() | ||
|
||
await checkExternalLink( | ||
YoutubeElement, | ||
contactPage.socialLinks.youtube, | ||
'https://www.youtube.com/@Kunsthalte', | ||
) // 12. When clicking on the Youtube icon, the user should be directed to another page. | ||
await page.click('button:has-text("EN")') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect, Locator, Page } from '@playwright/test' | ||
|
||
import { generateRandomUser } from '../utils' | ||
|
||
const { name, email } = generateRandomUser() | ||
|
||
export class ContactPage { | ||
readonly page: Page | ||
|
||
readonly fullnameInput: Locator | ||
readonly emailInput: Locator | ||
readonly messageInput: Locator | ||
readonly submitButton: Locator | ||
|
||
readonly errorAlert: Locator | ||
readonly successAlert: Locator | ||
|
||
readonly socialLinks: { | ||
email: Locator | ||
facebook: Locator | ||
instagram: Locator | ||
linkedin: Locator | ||
x: Locator | ||
whatsapp: Locator | ||
youtube: Locator | ||
} | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
|
||
this.fullnameInput = page.getByTestId('input-fullname') | ||
this.emailInput = page.getByTestId('input-email') | ||
this.messageInput = page.getByTestId('input-message') | ||
this.submitButton = page.getByRole('button', { name: 'Send message' }) | ||
|
||
this.errorAlert = page.getByTestId('error-contact-form') | ||
this.successAlert = page.getByTestId('success-contact-form') | ||
|
||
this.socialLinks = { | ||
email: page.locator('a[href^="mailto:"]'), | ||
x: page.getByLabel('X').first(), | ||
facebook: page.getByLabel('Facebook').first(), | ||
instagram: page.getByLabel('Instagram').first(), | ||
linkedin: page.getByLabel('LinkedIn').first(), | ||
whatsapp: page.getByLabel('WhatsApp').first(), | ||
youtube: page.getByLabel('YouTube').first(), | ||
} | ||
} | ||
|
||
async sendContactMessage() { | ||
// Locator.fill sometimes doesn't work as expected | ||
// Timeout was needed to fix the issue | ||
this.fullnameInput.fill(name) | ||
await this.page.waitForTimeout(1000) | ||
|
||
this.emailInput.fill(email) | ||
await this.page.waitForTimeout(1000) | ||
|
||
this.messageInput.focus() | ||
this.messageInput.fill('This is a Test Message.') | ||
|
||
await this.submitButton.click() | ||
await this.page.waitForTimeout(1000) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new ContactPage to the text fixture so that it will be available in test blocks like other pages