Skip to content

Commit 0303df2

Browse files
committed
Mantém os filtros ao voltar da visualização de detalhes do cliente
1 parent a87ef42 commit 0303df2

File tree

8 files changed

+131
-20
lines changed

8 files changed

+131
-20
lines changed

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"semi": true,
32
"singleQuote": true,
43
"trailingComma": "es5",
54
"printWidth": 80,
65
"tabWidth": 2,
76
"useTabs": false,
87
"bracketSpacing": true,
98
"arrowParens": "always"
10-
}
9+
}

cypress.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const { defineConfig } = require("cypress");
22

33
module.exports = defineConfig({
44
e2e: {
5-
baseUrl: 'http://localhost:3000',
5+
baseUrl: "http://localhost:3000",
6+
supportFile: false,
7+
fixturesFolder: false,
8+
env: {
9+
apiUrl: "http://localhost:3001"
10+
},
611
},
7-
})
12+
})

cypress/e2e/api/engageAPI.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('EngageSphere API - Customers', () => {
22
it('Successfully retrieves customers with default filters', () => {
33
cy.request(
4-
'http://localhost:3000/customers?page=1&limit=10&size=All&industry=All'
4+
`${Cypress.env("apiUrl")}/customers`
55
).as('api');
66

77
cy.get('@api').should((response) => {

cypress/e2e/e2e/engageGUI.cy.js

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
describe('EngageSphere - Customer Management UI', () => {
2+
beforeEach(() => {
3+
cy.visit('/');
4+
//cy.setCookie('cookieConsent', 'accepted')
5+
cy.contains('button', 'Accep').click();
6+
});
7+
8+
it('Maintains selected filter after returning from customer details', () => {
9+
cy.get('[data-testid="size-filter"]').as('sizeFilter');
10+
cy.get('@sizeFilter').select('Small');
11+
cy.contains('button', 'View').click();
12+
cy.contains('button', 'Back').click();
13+
cy.get('@sizeFilter').should('have.value', 'Small');
14+
});
15+
16+
it('Verify footer links', () => {
17+
cy.contains('p', 'Copyright 2025 - Talking About Testing').should(
18+
'be.visible'
19+
);
20+
cy.contains('a', 'Podcast')
21+
.should('be.visible')
22+
.and(
23+
'have.attr',
24+
'href',
25+
'https://open.spotify.com/show/5HFlqWkk6qtgJquUixyuKo'
26+
)
27+
.and('have.attr', 'target', '_blank')
28+
.and('have.attr', 'rel', 'noopener noreferrer');
29+
cy.contains('a', 'Courses')
30+
.should('be.visible')
31+
.and('have.attr', 'href', 'https://talking-about-testing.vercel.app/')
32+
.and('have.attr', 'target', '_blank')
33+
.and('have.attr', 'rel', 'noopener noreferrer');
34+
cy.contains('a', 'Blog')
35+
.should('be.visible')
36+
.and('have.attr', 'href', 'https://talkingabouttesting.com')
37+
.and('have.attr', 'target', '_blank')
38+
.and('have.attr', 'rel', 'noopener noreferrer');
39+
cy.contains('a', 'YouTube')
40+
.should('be.visible')
41+
.and('have.attr', 'href', 'https://youtube.com/@talkingabouttesting')
42+
.and('have.attr', 'target', '_blank')
43+
.and('have.attr', 'rel', 'noopener noreferrer');
44+
});
45+
46+
it('Empty Hi there', () => {
47+
cy.get('[data-testid="name"]').should('have.value', '');
48+
cy.contains('h2', 'Hi there').should('be.visible');
49+
});
50+
51+
it('Hi Joe there', () => {
52+
cy.get('[data-testid="name"]').type('Joe');
53+
cy.contains('h2', 'Hi Joe').should('be.visible');
54+
});
55+
56+
it('Exibe o cabeçalho com um título, alternador de tema e um campo de entrada de texto', () => {
57+
cy.contains('h1', 'EngageSphere').should('be.visible');
58+
cy.get('[class^="ThemeToggle_button"]').should('be.visible');
59+
cy.get('[data-testid="name"]').should('be.visible');
60+
});
61+
62+
it('Verificar que o preenchimento do campo nome é obrigatório', () => {
63+
cy.get('[class^="Messenger_openCloseButton"]').click();
64+
cy.get('#messenger-name').should('have.attr', 'required');
65+
});
66+
67+
it('Garante que todos os campos do messenger são obrigatórios e que o primeiro está focado', () => {
68+
cy.get('[class^="Messenger_openCloseButton"]').click();
69+
cy.get('#messenger-name').should('be.focused');
70+
cy.get('#messenger-name').should('have.attr', 'required');
71+
cy.get('#email').should('have.attr', 'required');
72+
cy.get('#message').should('have.attr', 'required');
73+
});
74+
75+
it('Mostra e oculta uma mensagem de sucesso ao enviar o formulário do messenger', () => {
76+
cy.clock();
77+
cy.get('[class^="Messenger_openCloseButton"]').click();
78+
cy.get('#messenger-name').should('be.visible');
79+
cy.get('#messenger-name').type('John Doe');
80+
cy.get('#email').type('john.doe@example.com');
81+
cy.get('#message').type('Hello, I need support!');
82+
cy.get('[class^="Messenger_sendButton"]').click();
83+
cy.get('[class^="Messenger_success"]')
84+
.should('be.visible')
85+
.and('contain', 'Your message has been sent.');
86+
cy.tick(3000);
87+
cy.get('[class^="Messenger_success"]').should('not.exist');
88+
});
89+
90+
it('Limpa todos os campos do formulário ao fechar e reabrir o messenger', () => {
91+
cy.get('[class^="Messenger_openCloseButton"]').click();
92+
cy.get('#messenger-name').should('be.visible');
93+
cy.get('#messenger-name').type('John Doe');
94+
cy.get('#email').type('john.doe@example.com');
95+
cy.get('#message').type('Hello, I need support!');
96+
cy.get('[class^="Messenger_openCloseButton"]').click();
97+
cy.get('[class^="Messenger_openCloseButton"]').click();
98+
cy.get('#messenger-name').should('have.value', '');
99+
cy.get('#email').should('have.value', '');
100+
cy.get('#message').should('have.value', '');
101+
});
102+
103+
it('Mostra as colunas Nome da Empresa e Ação, e oculta as outras em viewport móvel', () => {
104+
cy.viewport(375, 667);
105+
cy.get('[data-testid="table"]').should('be.visible');
106+
cy.contains('th', 'Company name').should('be.visible');
107+
cy.contains('th', 'Action').should('be.visible');
108+
cy.contains('th', 'ID').should('not.be.visible');
109+
cy.contains('th', 'Industry').should('not.be.visible');
110+
cy.contains('th', 'Number of employees').should('not.be.visible');
111+
cy.contains('th', 'Size').should('not.be.visible');
112+
});
113+
});

frontend/src/components/Button/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ const Button = ({
44
primary = true,
55
icon = null,
66
text = '',
7-
onClick = () => {},
8-
dataTestId = ''
7+
onClick = () => {}
98
}) => {
109
return (
1110
<div className={styles.buttonContainer}>
12-
<button
13-
className={primary ? styles.button : styles.secondaryButton}
14-
onClick={onClick}
15-
data-testid={dataTestId}
16-
>
11+
<button className={primary ? styles.button : styles.secondaryButton} onClick={onClick}>
1712
{icon}
1813
{text}
1914
</button>

frontend/src/components/CookieConsent/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styles from './CookieConsent.module.css'
2+
23
import Button from '../Button'
34

45
const CookieConsent = ({ giveConsentClickHandler, declineConsentClickHandler }) => {
@@ -12,13 +13,11 @@ const CookieConsent = ({ giveConsentClickHandler, declineConsentClickHandler })
1213
primary={true}
1314
text="Accept"
1415
onClick={giveConsentClickHandler}
15-
dataTestId="accept-button"
1616
/>
1717
<Button
1818
primary={false}
1919
text="Decline"
2020
onClick={declineConsentClickHandler}
21-
dataTestId="decline-button"
2221
/>
2322
</div>
2423
</div>

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"homepage": "https://github.com/wlsf82/EngageSphere-Test-Design-Masterclass-Turma-4/blob/main/README.md",
1919
"devDependencies": {
2020
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
21-
"cypress": "^14.1.0"
21+
"cypress": "^14.2.0"
2222
},
2323
"browserslist": {
2424
"production": [

0 commit comments

Comments
 (0)