Skip to content

Commit 171b50e

Browse files
authored
tests(user-profile): integration (#860)
1 parent 750df51 commit 171b50e

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

cypress/fixtures/mentors/get.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
]
6363
},
6464
{
65+
"available": true,
6566
"spokenLanguages": ["es", "en"],
66-
"tags": ["python", "reactjs", "html", "css", "graphql"],
67+
"tags": ["python", "reactjs", "html", "css", "graphql", "android"],
6768
"_id": "1",
6869
"name": "Brent M. Clark",
6970
"avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWBAMAAADOL2zRAAAAG1BMVEXMzMyWlpaqqqq3t7fFxcW+vr6xsbGjo6OcnJyLKnDGAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABAElEQVRoge3SMW+DMBiE4YsxJqMJtHOTITPeOsLQnaodGImEUMZEkZhRUqn92f0MaTubtfeMh/QGHANEREREREREREREtIJJ0xbH299kp8l8FaGtLdTQ19HjofxZlJ0m1+eBKZcikd9PWtXC5DoDotRO04B9YOvFIXmXLy2jEbiqE6Df7DTleA5socLqvEFVxtJyrpZFWz/pHM2CVte0lS8g2eDe6prOyqPglhzROL+Xye4tmT4WvRcQ2/m81p+/rdguOi8Hc5L/8Qk4vhZzy08DduGt9eVQyP2qoTM1zi0/uf4hvBWf5c77e69Gf798y08L7j0RERERERERERH9P99ZpSVRivB/rgAAAABJRU5ErkJggg==",

cypress/integration/mentors.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ describe('Mentor Filtering', () => {
1616
});
1717
cy.visit('/');
1818
});
19+
afterEach(() => {
20+
cy.clearNameFilter();
21+
});
22+
1923
it('can filter by technology', () => {
2024
cy.filterByName('Brent M Clark')
2125
.getByTestId('technology-filter-autocomplete')
@@ -73,13 +77,34 @@ describe('Mentor Filtering', () => {
7377
.contains('US');
7478
});
7579

76-
it('logged users can click on mentors channel', () => {
77-
cy.filterByName('Brent M Clark');
78-
cy.getAllByTestId('mentor-card')
79-
.first()
80+
it(`user can't approach non available mentor`, () => {
81+
cy.filterByName('S');
82+
cy.getByTestId('mentor-card')
83+
.get('div.channels')
84+
.contains('This mentor is not taking new mentees for now');
85+
});
86+
87+
it(`user navigates to mentor profile`, () => {
88+
cy.filterByName('B');
89+
cy.get('.tags')
90+
.children()
91+
.filter('button')
92+
.should('have.length', 5);
93+
// user has 6 tags and 5 are shown +1
94+
cy.getByText('+1');
95+
cy.getByTestId('mentor-card')
8096
.get('div.channels')
81-
.first()
8297
.click();
98+
99+
cy.location().should(loc => {
100+
expect(loc.pathname).to.eq('/u/1');
101+
});
102+
103+
cy.get('.tags')
104+
.children()
105+
.filter('button')
106+
.should('have.length', 6);
107+
cy.getByText('github');
83108
});
84109

85110
it.skip('user can like mentor', () => {

cypress/support/commands.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import '@testing-library/cypress/add-commands';
22

33
Cypress.Commands.add('filterByName', name => {
4-
cy.getByTestId('name-filter-autocomplete')
5-
.type(name)
6-
.type('{enter}');
4+
cy.getByTestId('name-filter-autocomplete').type(name);
5+
6+
cy.get('.ac-menu').click();
7+
});
8+
9+
Cypress.Commands.add('clearNameFilter', () => {
10+
cy.getByText('clear').click();
711
});
812

913
Cypress.Commands.add('login', () => {

cypress/support/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ declare global {
77
interface Chainable {
88
login(): Chainable<Element>;
99
getByTestId(testId: string): Chainable<Element>;
10+
getByText(text: string): Chainable<Element>;
11+
getAllByText(text: string): Chainable<Element>;
1012
}
1113
}
1214
}

0 commit comments

Comments
 (0)