diff --git a/pages/perfilpage.js b/pages/perfilpage.js new file mode 100644 index 0000000..6f24ede --- /dev/null +++ b/pages/perfilpage.js @@ -0,0 +1,22 @@ +import { expect } from "@playwright/test" + +class PerfilPage{ + + constructor(page){ + this.page = page + this.extenderBio = "//button[contains(.,'Ver mais')]" + this.reduzirBio = "//button[contains(.,'Ver menos')]" + this.estilosPreferidos = "(//h1[contains(.,'Estilos preferidos')])[1]" + this.conquistas = "(//h1[contains(.,'Conquistas')])[1]" + } + + async conferirElementosTela(){ + await this.page.click(this.extenderBio) + await this.page.click(this.reduzirBio) + + await expect(this.page.locator(this.estilosPreferidos)).toBeVisible() + await expect(this.page.locator(this.conquistas)).toBeVisible() + } +}; + +export default PerfilPage; \ No newline at end of file diff --git a/tests/perfil.spec.js b/tests/perfil.spec.js index 778728a..7451954 100644 --- a/tests/perfil.spec.js +++ b/tests/perfil.spec.js @@ -1,13 +1,10 @@ const { test, expect } = require('@playwright/test'); +import PerfilPage from '../pages/PerfilPage'; -test('acessar perfil', async ({ page }) => { +test('Acessar Perfil', async ({ page }) => { await page.goto('https://frontend-nnf7bytugq-uc.a.run.app/user/profile?show=profile'); - 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 perfilPage = new PerfilPage(page) + await perfilPage.conferirElementosTela() +}); \ No newline at end of file