diff --git a/pages/perfil.js b/pages/perfil.js new file mode 100644 index 0000000..2f356ef --- /dev/null +++ b/pages/perfil.js @@ -0,0 +1,35 @@ +const { expect } = require('@playwright/test'); +const { PATH } = require('../utils/constants'); + +exports.PerfilPage = class PerfilPage { + constructor(page) { + this.page = page; + } + + async goto() { + await this.page.goto(PATH.perfil); + } + + async clicarExtenderBio() { + const extenderBioButton = "//button[contains(.,'Ver mais')]"; + await this.page.click(extenderBioButton); + } + + async clicarReduzirBio() { + const reduzirBioButton = "//button[contains(.,'Ver menos')]"; + await this.page.click(reduzirBioButton); + } + + async validarTitulo() { + await expect(this.page).toHaveTitle(/Tem Vaga Mestre/); + } + + async validarEstilosPreferidos() { + const estilosPreferidos = "(//h1[contains(.,'Estilos preferidos')])[1]"; + await expect(this.page.locator(estilosPreferidos)).toBeVisible(); + } + async validarConquistas() { + const conquistas = "(//h1[contains(.,'Conquistas')])[1]"; + await expect(this.page.locator(conquistas)).toBeVisible(); + } +}; diff --git a/tests/perfil.spec.js b/tests/perfil.spec.js index 10ef1e2..a5eb693 100644 --- a/tests/perfil.spec.js +++ b/tests/perfil.spec.js @@ -1,15 +1,12 @@ -const { test, expect } = require('@playwright/test'); -const { PATH } = require('../utils/constants'); - -test('acessar perfil', async ({ page }) => { - await page.goto(PATH.perfil); - - await expect(page).toHaveTitle(/Tem Vaga Mestre/); - - await expect( - page.getByRole('heading', { name: 'Estilos preferidos' }) - ).toBeVisible(); - await expect(page.getByRole('heading', { name: 'Conquistas' })).toBeVisible(); - - await page.getByRole('button', { name: 'Ver mais' }).click(); +const { test } = require('@playwright/test'); +import { PerfilPage } from '../pages/perfil.js'; + +test('Acessar perfil', async ({ page }) => { + const perfilPage = new PerfilPage(page); + await perfilPage.goto(); + await perfilPage.validarTitulo(); + await perfilPage.clicarExtenderBio(); + await perfilPage.clicarReduzirBio(); + await perfilPage.validarEstilosPreferidos(); + await perfilPage.validarConquistas(); });