diff --git a/cypress/fixtures/mentors/get.json b/cypress/fixtures/mentors/get.json index fb0f9b233..9938987f0 100644 --- a/cypress/fixtures/mentors/get.json +++ b/cypress/fixtures/mentors/get.json @@ -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==", diff --git a/cypress/integration/mentors.js b/cypress/integration/mentors.js index df225d9bc..c2400fb47 100644 --- a/cypress/integration/mentors.js +++ b/cypress/integration/mentors.js @@ -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') @@ -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', () => { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index b952a0c07..e8c907898 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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', () => { diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 167ee9e6c..bf8417764 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -7,6 +7,8 @@ declare global { interface Chainable { login(): Chainable; getByTestId(testId: string): Chainable; + getByText(text: string): Chainable; + getAllByText(text: string): Chainable; } } }