From 3dc261ab00658e1736a555c1639f404a626f2a30 Mon Sep 17 00:00:00 2001 From: jessica Date: Thu, 16 May 2024 16:14:39 +0100 Subject: [PATCH 1/3] Atualizei a URL do perfil no arquivo constants --- utils/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/constants.js b/utils/constants.js index 72ce782..9d77920 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -1,3 +1,3 @@ export const PATH = { - perfil: '/user/profile?show=profile', + perfil: '/user/profile', }; From 99fe11629f6c3d5cc328c82f883012a92eb0fef1 Mon Sep 17 00:00:00 2001 From: jessica Date: Thu, 16 May 2024 16:20:20 +0100 Subject: [PATCH 2/3] Adicionei novos metodos no arquivo perfil --- pages/perfil.js | 60 +++++++++++++++++++++++++++++++++----------- tests/perfil.spec.js | 14 +++++++---- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/pages/perfil.js b/pages/perfil.js index 2f356ef..dc81605 100644 --- a/pages/perfil.js +++ b/pages/perfil.js @@ -2,6 +2,10 @@ const { expect } = require('@playwright/test'); const { PATH } = require('../utils/constants'); exports.PerfilPage = class PerfilPage { + + VER_MAIS_BTN = "//button[contains(.,'Ver mais')]" + + constructor(page) { this.page = page; } @@ -10,26 +14,54 @@ exports.PerfilPage = class PerfilPage { await this.page.goto(PATH.perfil); } - async clicarExtenderBio() { - const extenderBioButton = "//button[contains(.,'Ver mais')]"; - await this.page.click(extenderBioButton); + async validarTituloDaPagina() { + await expect(this.page).toHaveTitle(/Tem Vaga Mestre/); } - async clicarReduzirBio() { - const reduzirBioButton = "//button[contains(.,'Ver menos')]"; - await this.page.click(reduzirBioButton); + async validarTituloBio() { + const bioTitlle = "//h2[contains(.,'Bio')]"; + await expect(this.page.locator(bioTitlle)).toBeVisible(); } - async validarTitulo() { - await expect(this.page).toHaveTitle(/Tem Vaga Mestre/); + async validarBotaoExtenderBio() { + await expect(this.page.locator(this.VER_MAIS_BTN)).toBeVisible(); + } + + async clicarBotaoExtenderBio() { + await this.page.click(this.VER_MAIS_BTN); } - async validarEstilosPreferidos() { - const estilosPreferidos = "(//h1[contains(.,'Estilos preferidos')])[1]"; - await expect(this.page.locator(estilosPreferidos)).toBeVisible(); + async validarEClicarBotaoReduzirBio() { + const botaoReduzirBio = "//button[contains(.,'Ver menos')]"; + await expect(this.page.locator(botaoReduzirBio)).toBeVisible(); + await this.page.click(botaoReduzirBio); } - async validarConquistas() { + + async validarTituloEstilosPreferidos() { + const tituloEstilosPreferidos = "(//h1[contains(.,'Estilos preferidos')])[1]"; + await expect(this.page.locator(tituloEstilosPreferidos)).toBeVisible(); + } + + async validarEstilosDeJogoEscolhidos() { + const FantasiaHeroica = "//span[@title='Fantasia heroica']"; + const NinjaVsSamurai = "//span[@title='Ninja vs Samurai']"; + const EspadaEFeiticaria = "//span[@title='Espada e feitiçaria']"; + + await expect(this.page.locator(FantasiaHeroica)).toBeVisible(); + await expect(this.page.locator(NinjaVsSamurai)).toBeVisible(); + await expect(this.page.locator(EspadaEFeiticaria)).toBeVisible(); + }; + + async validarTituloConquistas() { const conquistas = "(//h1[contains(.,'Conquistas')])[1]"; await expect(this.page.locator(conquistas)).toBeVisible(); - } -}; + }; + + async validarConquistasAdquiridas() { + const ReiDasRolagens = "//p[contains(.,'Rei das rolagens')]"; + const NinjaVsSamurai = "//p[contains(.,'Mestre raiz')]"; + + await expect(this.page.locator(ReiDasRolagens)).toBeVisible(); + await expect(this.page.locator(NinjaVsSamurai)).toBeVisible(); + }; +} \ No newline at end of file diff --git a/tests/perfil.spec.js b/tests/perfil.spec.js index a5eb693..afea60c 100644 --- a/tests/perfil.spec.js +++ b/tests/perfil.spec.js @@ -4,9 +4,13 @@ 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(); + await perfilPage.validarTituloDaPagina(); + await perfilPage.validarTituloBio(); + await perfilPage.validarBotaoExtenderBio(); + await perfilPage.clicarBotaoExtenderBio(); + await perfilPage.validarEClicarBotaoReduzirBio(); + await perfilPage.validarTituloEstilosPreferidos(); + await perfilPage.validarEstilosDeJogoEscolhidos(); + await perfilPage.validarTituloConquistas(); + await perfilPage.validarConquistasAdquiridas(); }); From c8e26691759198035345eb0e53207b80640f4ada Mon Sep 17 00:00:00 2001 From: jessica Date: Fri, 31 May 2024 15:29:32 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Cria=C3=A7=C3=A3o=20arquivo=20de=20constant?= =?UTF-8?q?es=20e=20refatora=C3=A7=C3=A3o=20do=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/perfil.js | 41 +++++++++++++++++++---------------------- tests/perfil.spec.js | 7 ++++--- utils/constants.js | 13 +++++++++++++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/pages/perfil.js b/pages/perfil.js index dc81605..5dc5512 100644 --- a/pages/perfil.js +++ b/pages/perfil.js @@ -1,11 +1,11 @@ const { expect } = require('@playwright/test'); -const { PATH } = require('../utils/constants'); +const { PATH, ESTILOS_PREFERIDOS } = require('../utils/constants'); +const { TIMEOUT } = require('dns'); +const { error } = require('console'); +const exp = require('constants'); exports.PerfilPage = class PerfilPage { - VER_MAIS_BTN = "//button[contains(.,'Ver mais')]" - - constructor(page) { this.page = page; } @@ -19,19 +19,17 @@ exports.PerfilPage = class PerfilPage { } async validarTituloBio() { - const bioTitlle = "//h2[contains(.,'Bio')]"; - await expect(this.page.locator(bioTitlle)).toBeVisible(); + const bioTitle = "//h2[contains(.,'Bio')]"; + await expect(this.page.locator(bioTitle)).toBeVisible(); } async validarBotaoExtenderBio() { - await expect(this.page.locator(this.VER_MAIS_BTN)).toBeVisible(); - } - - async clicarBotaoExtenderBio() { - await this.page.click(this.VER_MAIS_BTN); + const botaoExtenderBio = "//button[contains(.,'Ver mais')]"; + await expect(this.page.locator(botaoExtenderBio)).toBeVisible(); + await this.page.click(botaoExtenderBio); } - async validarEClicarBotaoReduzirBio() { + async validarBotaoReduzirBio() { const botaoReduzirBio = "//button[contains(.,'Ver menos')]"; await expect(this.page.locator(botaoReduzirBio)).toBeVisible(); await this.page.click(botaoReduzirBio); @@ -42,16 +40,15 @@ exports.PerfilPage = class PerfilPage { await expect(this.page.locator(tituloEstilosPreferidos)).toBeVisible(); } - async validarEstilosDeJogoEscolhidos() { - const FantasiaHeroica = "//span[@title='Fantasia heroica']"; - const NinjaVsSamurai = "//span[@title='Ninja vs Samurai']"; - const EspadaEFeiticaria = "//span[@title='Espada e feitiçaria']"; + async validarEstilosDeJogoEscolhidos(estilos) { + estilos.forEach(async(estilo) => { + const localizador = "//span[@title='"+estilo+"']"; + await expect(this.page.locator(localizador)).toBeVisible(); - await expect(this.page.locator(FantasiaHeroica)).toBeVisible(); - await expect(this.page.locator(NinjaVsSamurai)).toBeVisible(); - await expect(this.page.locator(EspadaEFeiticaria)).toBeVisible(); + await expect(this.page.locator(localizador)).toHaveText(estilo); + }) }; - + async validarTituloConquistas() { const conquistas = "(//h1[contains(.,'Conquistas')])[1]"; await expect(this.page.locator(conquistas)).toBeVisible(); @@ -59,9 +56,9 @@ exports.PerfilPage = class PerfilPage { async validarConquistasAdquiridas() { const ReiDasRolagens = "//p[contains(.,'Rei das rolagens')]"; - const NinjaVsSamurai = "//p[contains(.,'Mestre raiz')]"; + const MestreRaiz = "//p[contains(.,'Mestre raiz')]"; await expect(this.page.locator(ReiDasRolagens)).toBeVisible(); - await expect(this.page.locator(NinjaVsSamurai)).toBeVisible(); + await expect(this.page.locator(MestreRaiz)).toBeVisible(); }; } \ No newline at end of file diff --git a/tests/perfil.spec.js b/tests/perfil.spec.js index afea60c..7769e35 100644 --- a/tests/perfil.spec.js +++ b/tests/perfil.spec.js @@ -1,16 +1,17 @@ const { test } = require('@playwright/test'); import { PerfilPage } from '../pages/perfil.js'; +import { ESTILOS_PREFERIDOS } from '../utils/constants.js'; test('Acessar perfil', async ({ page }) => { + const estilos = [ESTILOS_PREFERIDOS.fantasiaHeroica, ESTILOS_PREFERIDOS.ninjaVsSamurai, ESTILOS_PREFERIDOS.espadaEFeiticaria] const perfilPage = new PerfilPage(page); await perfilPage.goto(); await perfilPage.validarTituloDaPagina(); await perfilPage.validarTituloBio(); await perfilPage.validarBotaoExtenderBio(); - await perfilPage.clicarBotaoExtenderBio(); - await perfilPage.validarEClicarBotaoReduzirBio(); + await perfilPage.validarBotaoReduzirBio(); await perfilPage.validarTituloEstilosPreferidos(); - await perfilPage.validarEstilosDeJogoEscolhidos(); + await perfilPage.validarEstilosDeJogoEscolhidos(estilos); await perfilPage.validarTituloConquistas(); await perfilPage.validarConquistasAdquiridas(); }); diff --git a/utils/constants.js b/utils/constants.js index 9d77920..064d485 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -1,3 +1,16 @@ export const PATH = { perfil: '/user/profile', }; + +export const ESTILOS_PREFERIDOS = { + fantasiaHeroica: "Fantasia heroica", + ninjaVsSamurai: "Ninja vs Samurai", + espadaEFeiticaria: "Espada e feitiçaria", + fantasiaEpica: "Fantasia épica", + fantasiaMitica: "Fantasia mítica", + fantasiaSombria: "Fantasia sombria", + intriga: "Intriga", + misterio: "Mistério", + guerra: "Guerra", + naveMae: "Nave Mãe" +} \ No newline at end of file