Skip to content
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

Update class perfil page #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 49 additions & 17 deletions pages/perfil.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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 {
constructor(page) {
Expand Down Expand Up @@ -33,10 +36,21 @@ exports.PerfilPage = class PerfilPage {
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 validarTituloEstilosPreferidos() {
const tituloEstilosPreferidos =
"(//h1[contains(.,'Estilos preferidos')])[1]";
await expect(this.page.locator(tituloEstilosPreferidos)).toBeVisible();
}

async validarEstilosDeJogoEscolhidos(estilos) {
estilos.forEach(async (estilo) => {
const localizador = "//span[@title='" + estilo + "']";
await expect(this.page.locator(localizador)).toBeVisible();

await expect(this.page.locator(localizador)).toHaveText(estilo);
});
}

async validarTituloConquistas() {
const conquistas = { role: 'heading', name: 'Conquistas' };
await expect(
Expand All @@ -54,25 +68,43 @@ exports.PerfilPage = class PerfilPage {
}

async validarNome(nome) {
const nomeUsuario = "//h2[contains(.,'Lucas Marcelo')]";
await expect(this.page.locator(nomeUsuario)).toBeVisible();
await expect(this.page.locator(nomeUsuario)).toHaveText(nome);
const nomeUsuario = { role: 'heading', name: nome };
await expect(
this.page.getByRole(nomeUsuario.role, { name: nomeUsuario.name })
).toBeVisible();
await expect(
this.page.getByRole(nomeUsuario.role, { name: nomeUsuario.name })
).toHaveText(nome);
}

async validarPronome() {
const pronomeUsuario = "//h2[contains(.,'(Ele - Dele)')]";
await expect(this.page.locator(pronomeUsuario)).toBeVisible();
async validarPronome(pronome) {
const pronomeUsuario = { role: 'heading', name: `(${pronome})` };
await expect(
this.page.getByRole(pronomeUsuario.role, { name: pronomeUsuario.name })
).toBeVisible();
await expect(
this.page.getByRole(pronomeUsuario.role, { name: pronomeUsuario.name })
).toHaveText(pronomeUsuario.name);
}

async validarUsername() {
const username = "//h2[contains(.,'@mestremarcelo')]";
await expect(this.page.locator(username)).toBeVisible();
async validarUsername(username) {
const usernamePerfil = { role: 'heading', name: username };
await expect(
this.page.getByRole(usernamePerfil.role, { name: usernamePerfil.name })
).toBeVisible();
await expect(
this.page.getByRole(usernamePerfil.role, { name: usernamePerfil.name })
).toHaveText(username);
}

async validarUserTitle() {
const userTitle =
"//h2[contains(.,'Mestre D&D com 15 anos de experiência')]";
await expect(this.page.locator(userTitle)).toBeVisible();
async validarUserTitle(titulo) {
const userTitle = { role: 'heading', name: titulo };
await expect(
this.page.getByRole(userTitle.role, { name: userTitle.name })
).toBeVisible();
await expect(
this.page.getByRole(userTitle.role, { name: userTitle.name })
).toHaveText(titulo);
}

async validarLocalResidencia(cidade, pais) {
Expand Down
11 changes: 5 additions & 6 deletions tests/perfil.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ test('Validar dados do usuário', async ({ page }) => {
const perfilPage = new PerfilPage(page);
await perfilPage.goto();
await perfilPage.validarNome(PERFIL.jogador.nome);
await perfilPage.validarPronome();
await perfilPage.validarUsername();
await perfilPage.validarUserTitle();
await perfilPage.validarPronome(PERFIL.jogador.pronome);
await perfilPage.validarUsername(PERFIL.jogador.username);
await perfilPage.validarUserTitle(PERFIL.jogador.titulo);
await perfilPage.validarLocalResidencia(
PERFIL.jogador.cidade,
PERFIL.jogador.pais
Expand All @@ -24,11 +24,10 @@ test('Validar dados do usuário', async ({ page }) => {

test('Validar Estilos de jogo e Conquistas', async ({ page }) => {
const perfilPage = new PerfilPage(page);
const conquistas = [CONQUISTAS.reiDasRolagens, CONQUISTAS.mestreRaiz];
await perfilPage.goto();
await perfilPage.validarEstilosPreferidos();
await perfilPage.validarEstilosPreferidos(PERFIL.jogador.estilosPreferidos);
await perfilPage.validarTituloConquistas();
await perfilPage.validarInsigniasRecebidas(conquistas);
await perfilPage.validarInsigniasRecebidas(PERFIL.jogador.conquistas);
});

test('Validar Bio', async ({ page }) => {
Expand Down
2 changes: 1 addition & 1 deletion utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ export const PERFIL = {
bio: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantiumearum perferendis asperiores itaque culpa ratione nihil optio,temporibus omnis doloremque dolor consequuntur, accusamus suscipitlabore quisquam, eum laudantium dolorum explicate.e dolor consequuntur, accusamus suscipitlabore quisquam, temporibus omnis doloremque dolor consequuntur, accusamus suscipitlabore quisquam, eum laudantium dolorum explicate.e dolor consequuntur, accusamus suscipitlabore quisquam',
},
mestre: {},
};
};
Loading