Commit 99d193bf authored by Francisco Lisboa's avatar Francisco Lisboa
Browse files

merge com a dev

Showing with 3699 additions and 609 deletions
+3699 -609
CYPRESS_BASE_URL=https://globo-aplausos-frontend.vercel.app
USER_EMAIL=guilherme.stefani@edu.pucrs.br
USER_PASSWORD=Senh@123
\ No newline at end of file
CYPRESS_BASE_URL=
USER_EMAIL=
USER_PASSWORD=
\ No newline at end of file
CYPRESS_BASE_URL=https://globo-aplausos-frontend.vercel.app/
USER_EMAIL="seuemail@teste.com"
USER_PASSWORD="Senh@123"
\ No newline at end of file
image: node:alpine
stages:
- build
- lint
- test
- test-prod
before_script:
- npm install
build:
stage: build
script:
- npm run build
lint:
stage: lint
script:
- npm run lint
- npm run lint:fix
test-prod:
stage: test-prod
test:
stage: test
image: cypress/browsers:latest
script:
- npm run test
## Link da Tarefa
[Inserir link da tarefa do Trello]
## Descrição
[Descreva brevemente o propósito e as principais mudanças e adições que foram feitas nesta solicitação de Merge]
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
#!/bin/sh
current_branch=$(git symbolic-ref --short HEAD)
if [[ "$current_branch" =~ ^(feature|fix)/US-[0-9]+ ]] || [[ "$current_branch" =~ ^(feature|fix)/NOUS ]]; then
echo "Nome da branch de acordo com o formato: 'feature/US-Número-descrição' ou 'fix/US-Número-descrição' ou 'feature/NOUS' ou 'fix/NOUS' - Push realizado com sucesso"
if npm run test; then
echo "Testes realizados com sucesso."
else
echo "Testes falharam."
exit 1
fi
else
echo "Erro: Nome da branch não está de acordo com o formato solicitado.'"
exit 1
fi
exit 0
{
"*.ts": [
"prettier --write",
"eslint"
]
}
describe('Feedbacks', () => {
beforeEach(() => {
cy.login();
});
it('should send feedback correctly with message', () => {
cy.get('#userInfoCard').click();
cy.get('#feedbackRecipientWrapper').click();
cy.get('#react-select-2-option-3').click();
cy.get('#message').click().type('Essa é uma mensagem de teste');
cy.get('.feedbackModal_applauseWrapper__OfT_l > input').type('1');
cy.get('#sendFeedbackButton').click();
cy.contains('Sucesso').should('be.visible');
cy.get('.MuiSvgIcon-root[data-testid="HighlightOffIcon"]').click();
});
it('should send feedback correctly with empty message', () => {
cy.get('#userInfoCard').click();
cy.get('#feedbackRecipientWrapper').click();
cy.get('#react-select-2-option-3').click();
cy.get('.feedbackModal_applauseWrapper__OfT_l > input').type('1');
cy.get('#sendFeedbackButton').click();
cy.contains('Sucesso').should('be.visible');
cy.get('.MuiSvgIcon-root[data-testid="HighlightOffIcon"]').click();
});
it('should not send feedback if value is invalid', () => {
cy.get('#userInfoCard').click();
cy.get('#feedbackRecipientWrapper').click();
cy.get('#react-select-2-option-3').click();
cy.get('#message').click().type('Essa é uma mensagem de teste');
cy.get('.feedbackModal_applauseWrapper__OfT_l > input').type('0');
cy.get('#sendFeedbackButton').click();
cy.get('.feedbackModal_sendClapFooterWrapper__poR_T > span')
.should('be.visible')
.should('have.text', 'Por favor, selecione a quantidade de aplausos');
});
it('should not send feedback if there is no receiver', () => {
cy.get('#userInfoCard').click();
cy.get('#message').click().type('Essa é uma mensagem de teste');
cy.get('.feedbackModal_applauseWrapper__OfT_l > input').type('1');
cy.get('#sendFeedbackButton').click();
cy.get('#feedbackRecipientWrapper > span')
.should('be.visible')
.should(
'have.text',
'Por favor, selecione um destinatário para o feedback',
);
});
});
describe('login user', () => {
it('should login and go to home', () => {
const baseUrl = Cypress.env('CYPRESS_BASE_URL');
const userEmail = Cypress.env('USER_EMAIL');
const userPassword = Cypress.env('USER_PASSWORD');
const loginUrl = `${baseUrl}/login`;
describe('Login page', () => {
const baseUrl = Cypress.env('CYPRESS_BASE_URL');
cy.login(userEmail, userPassword, loginUrl);
it('should login and go to home', () => {
cy.login();
cy.url({ timeout: 10000 }).should('eq', `${baseUrl}/`);
});
......@@ -18,22 +15,9 @@ describe('login admin',() => {
const userPassword = Cypress.env('USER_PASSWORD');
const loginUrl = `${baseUrl}/login`;
cy.login(adminEmail, userPassword, loginUrl);
cy.url({ timeout: 10000 }).should('eq', `${baseUrl}/admin`);
});
})
cy.login();
describe('login invalid password',() => {
it('should not login', () => {
const baseUrl = Cypress.env('CYPRESS_BASE_URL');
const adminEmail = Cypress.env('ADMIN_EMAIL')
const userPassword = '1';
const loginUrl = `${baseUrl}/login`;
cy.login(adminEmail, userPassword, loginUrl);
cy.url({ timeout: 10000 }).should('eq', `${baseUrl}/login`);
cy.get('.login_errorContainer__C6Hgp').should('be.visible')
cy.url().should('eq', `${baseUrl}/`);
});
})
......@@ -44,7 +28,7 @@ describe('login invalid email',() => {
const userPassword = Cypress.env('USER_PASSWORD');
const loginUrl = `${baseUrl}/login`;
cy.login(adminEmail, userPassword, loginUrl);
cy.login();
cy.url({ timeout: 10000 }).should('eq', `${baseUrl}/login`);
cy.get('.login_errorContainer__C6Hgp').should('be.visible');
cy.get('#outlined-email-input-helper-text').should('be.visible');
......
declare namespace Cypress {
interface Chainable {
login(username: string, password: string, loginUrl: string): void;
login(): void;
}
}
Cypress.Commands.add('login', (username, password, loginUrl) => {
Cypress.Commands.add('login', () => {
const baseUrl = Cypress.env('CYPRESS_BASE_URL');
const userEmail = Cypress.env('USER_EMAIL');
const userPassword = Cypress.env('USER_PASSWORD');
const loginUrl = `${baseUrl}/login`;
cy.visit(loginUrl);
cy.get('input#outlined-email-input').type(username);
cy.get('input#outlined-password-input').type(password);
cy.get('input#outlined-email-input').type(userEmail);
cy.get('input#outlined-password-input').type(userPassword);
cy.get('button#loginButton').click();
});
This diff is collapsed.
......@@ -3,18 +3,22 @@
"lint:fix": "eslint --fix .",
"format": "prettier --write .",
"test": "cypress run --browser chrome ",
"start:local": "cypress open"
"start:local": "cypress open",
"prepare": "husky install"
},
"devDependencies": {
"@types/cypress": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"cypress": "^13.3.3",
"eslint": "^8.51.0",
"eslint-plugin-cypress": "^2.15.1",
"husky": "^8.0.0",
"prettier": "^3.0.3",
"typescript": "^4.9.5"
},
"dependencies": {
"dotenv": "^16.3.1"
"dotenv": "^16.3.1",
"lint-staged": "^15.0.2"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment