Skip to content

Commit

Permalink
tests(user-profile): integration (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
moshfeu authored Oct 20, 2021
1 parent 750df51 commit 171b50e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cypress/fixtures/mentors/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
]
},
{
"available": true,
"spokenLanguages": ["es", "en"],
"tags": ["python", "reactjs", "html", "css", "graphql"],
"tags": ["python", "reactjs", "html", "css", "graphql", "android"],
"_id": "1",
"name": "Brent M. Clark",
"avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWBAMAAADOL2zRAAAAG1BMVEXMzMyWlpaqqqq3t7fFxcW+vr6xsbGjo6OcnJyLKnDGAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABAElEQVRoge3SMW+DMBiE4YsxJqMJtHOTITPeOsLQnaodGImEUMZEkZhRUqn92f0MaTubtfeMh/QGHANEREREREREREREtIJJ0xbH299kp8l8FaGtLdTQ19HjofxZlJ0m1+eBKZcikd9PWtXC5DoDotRO04B9YOvFIXmXLy2jEbiqE6Df7DTleA5socLqvEFVxtJyrpZFWz/pHM2CVte0lS8g2eDe6prOyqPglhzROL+Xye4tmT4WvRcQ2/m81p+/rdguOi8Hc5L/8Qk4vhZzy08DduGt9eVQyP2qoTM1zi0/uf4hvBWf5c77e69Gf798y08L7j0RERERERERERH9P99ZpSVRivB/rgAAAABJRU5ErkJggg==",
Expand Down
35 changes: 30 additions & 5 deletions cypress/integration/mentors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ describe('Mentor Filtering', () => {
});
cy.visit('/');
});
afterEach(() => {
cy.clearNameFilter();
});

it('can filter by technology', () => {
cy.filterByName('Brent M Clark')
.getByTestId('technology-filter-autocomplete')
Expand Down Expand Up @@ -73,13 +77,34 @@ describe('Mentor Filtering', () => {
.contains('US');
});

it('logged users can click on mentors channel', () => {
cy.filterByName('Brent M Clark');
cy.getAllByTestId('mentor-card')
.first()
it(`user can't approach non available mentor`, () => {
cy.filterByName('S');
cy.getByTestId('mentor-card')
.get('div.channels')
.contains('This mentor is not taking new mentees for now');
});

it(`user navigates to mentor profile`, () => {
cy.filterByName('B');
cy.get('.tags')
.children()
.filter('button')
.should('have.length', 5);
// user has 6 tags and 5 are shown +1
cy.getByText('+1');
cy.getByTestId('mentor-card')
.get('div.channels')
.first()
.click();

cy.location().should(loc => {
expect(loc.pathname).to.eq('/u/1');
});

cy.get('.tags')
.children()
.filter('button')
.should('have.length', 6);
cy.getByText('github');
});

it.skip('user can like mentor', () => {
Expand Down
10 changes: 7 additions & 3 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import '@testing-library/cypress/add-commands';

Cypress.Commands.add('filterByName', name => {
cy.getByTestId('name-filter-autocomplete')
.type(name)
.type('{enter}');
cy.getByTestId('name-filter-autocomplete').type(name);

cy.get('.ac-menu').click();
});

Cypress.Commands.add('clearNameFilter', () => {
cy.getByText('clear').click();
});

Cypress.Commands.add('login', () => {
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ declare global {
interface Chainable {
login(): Chainable<Element>;
getByTestId(testId: string): Chainable<Element>;
getByText(text: string): Chainable<Element>;
getAllByText(text: string): Chainable<Element>;
}
}
}
Expand Down

0 comments on commit 171b50e

Please sign in to comment.