Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
7alip committed Jul 3, 2024
1 parent a227cdb commit 69d0b83
Showing 1 changed file with 48 additions and 47 deletions.
95 changes: 48 additions & 47 deletions packages/playwright/src/tests/upload-arts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,34 @@ import { faker } from '@faker-js/faker/locale/en'
import { expect, test } from '@playwright/test'

import { PASSWORD, USERNAME } from '../constants'
import { HomePage,LoginPage } from '../pages'
import { HomePage, LoginPage } from '../pages'
import { getVercelUrl } from '../utils'




test('should not upload art without logging in', async ({ page }) => {
await page.goto(getVercelUrl('kunsthalte'))

await page.getByRole('link', { name: 'Arts' }).first().click();
await page.getByText('Upload Art').click();
await page.getByRole('link', { name: 'Arts' }).first().click()
await page.getByText('Upload Art').click()
const warning = page.locator('.chakra-modal__body p')
await page.waitForTimeout(1000);
expect(warning).toContainText('You must be logged in in order to be able to upload an art!')
await page.waitForTimeout(1000)
expect(warning).toContainText(
'You must be logged in in order to be able to upload an art!',
)
})


test('should upload art with logging in', async ({ page }) => {
const loginPage = new LoginPage(page)
const homePage = new HomePage(page, 'kunsthalte')

await page.goto(homePage.url, { waitUntil: 'domcontentloaded' })
await homePage.gotoLogin()
await loginPage.login(USERNAME, PASSWORD)
await page.getByRole('link', { name: 'Arts' }).first().click();
await page.getByText('Upload Art').click();
await page.getByRole('link', { name: 'Arts' }).first().click()
await page.getByText('Upload Art').click()
await page.waitForTimeout(1000)
expect(page.locator('.uppy-Dashboard-AddFiles-title')).toBeVisible()

})


test('should fill required fields for upload art', async ({ page }) => {
const loginPage = new LoginPage(page)
const homePage = new HomePage(page, 'kunsthalte')
Expand All @@ -43,25 +39,28 @@ test('should fill required fields for upload art', async ({ page }) => {
await loginPage.login(USERNAME, PASSWORD)
await page.waitForTimeout(1000)

await page.getByRole('link', { name: 'Arts' }).first().click();
await page.getByText('Upload Art').click();
await page.getByRole('link', { name: 'Arts' }).first().click()
await page.getByText('Upload Art').click()
await page.waitForTimeout(1000)
const filePath = 'apps/kunsthalte/public/arts.jpeg'
await page.locator('.uppy-Dashboard-input').first().setInputFiles(filePath)
await page.waitForTimeout(1000)
const filePath= "apps/kunsthalte/public/arts.jpeg"
await page.locator('.uppy-Dashboard-input').first().setInputFiles(filePath);
await page.waitForTimeout(1000);

await page.locator('#title').click();
await page.locator('#description').click();
await page.locator('#title').click();


expect(page.locator('.chakra-form__error-message').first()).toContainText("title is a required field")
expect(page.locator('.chakra-form__error-message').last()).toContainText("description is a required field")
await page.locator('#title').click()
await page.locator('#description').click()
await page.locator('#title').click()

expect(page.locator('.chakra-form__error-message').first()).toContainText(
'title is a required field',
)
expect(page.locator('.chakra-form__error-message').last()).toContainText(
'description is a required field',
)
})


test('The uploaded image should be displayed in the pending arts section.', async ({ page }) => {
test('The uploaded image should be displayed in the pending arts section.', async ({
page,
}) => {
const loginPage = new LoginPage(page)
const homePage = new HomePage(page, 'kunsthalte')

Expand All @@ -70,35 +69,37 @@ test('The uploaded image should be displayed in the pending arts section.', asyn
await loginPage.login(USERNAME, PASSWORD)
await page.waitForTimeout(2000)

await page.getByRole('link', { name: 'Arts' }).first().click();
await page.getByText('Upload Art').click();
await page.getByRole('link', { name: 'Arts' }).first().click()
await page.getByText('Upload Art').click()
await page.waitForTimeout(1000)
const filePath= "apps/kunsthalte/public/arts.jpeg"
await page.locator('.uppy-Dashboard-input').first().setInputFiles(filePath);
await page.waitForTimeout(1000);
await page.locator(".uppy-DashboardContent-save").click();
const filePath = 'apps/kunsthalte/public/arts.jpeg'
await page.locator('.uppy-Dashboard-input').first().setInputFiles(filePath)
await page.waitForTimeout(1000)
await page.locator('.uppy-DashboardContent-save').click()

const title = faker.internet.userName().toString();
const title = faker.internet.userName().toString()

await page.locator('#title').fill(title);
await page.locator('#description').fill("Description Test");
expect(page.locator("//*[@type='submit']")).toBeEnabled();
await page.locator('#title').fill(title)
await page.locator('#description').fill('Description Test')
expect(page.locator("//*[@type='submit']")).toBeEnabled()

await page.locator("//*[@type='submit']").click();
await page.locator("//*[@type='submit']").click()

expect(page.getByText('Art successfully submitted')).toBeVisible();
expect(page.getByText('Art successfully submitted')).toBeVisible()

await page.waitForTimeout(1000);
await page.waitForTimeout(1000)

await page.getByText('Go to my profile').click();
await page.getByText('Go to my profile').click()

await page.locator('.chakra-tabs__tab').last().click();
await page.locator('.chakra-tabs__tab').last().click()

await page.waitForTimeout(5000);
await page.waitForTimeout(5000)

await page.getByText('Pending Arts').click();
await page.getByText('Pending Arts').click()

await page.waitForTimeout(5000);
await page.waitForTimeout(5000)

expect(page.locator('.chakra-aspect-ratio div div img').first()).toHaveAttribute('src');
})
expect(
page.locator('.chakra-aspect-ratio div div img').first(),
).toHaveAttribute('src')
})

0 comments on commit 69d0b83

Please sign in to comment.