-
-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
2,818 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ cypress/screenshots | |
|
||
# ESLint | ||
.eslintcache | ||
|
||
#debug | ||
debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"videoUploadOnPasses": false, | ||
"defaultCommandTimeout": 15000 | ||
"defaultCommandTimeout": 60000, | ||
"responseTimeout": 60000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"success": true, | ||
"data": [ | ||
{ | ||
"id": 123, | ||
"mentee": { | ||
"id": "001", | ||
"name": "User 001", | ||
"avatar": "https://avatars0.githubusercontent.com/u/219207?s=88&v=4", | ||
"title": "J web dev" | ||
}, | ||
"status": "Approved", | ||
"date": 1609748339000, | ||
"message": "hi", | ||
"background": "yes", | ||
"expectation": "the world", | ||
"isMine": false | ||
}, | ||
{ | ||
"id": 456, | ||
"mentee": { | ||
"id": "002", | ||
"name": "User 002", | ||
"avatar": "https://avatars0.githubusercontent.com/u/219207?s=88&v=4", | ||
"title": "J web dev" | ||
}, | ||
"status": "Rejected", | ||
"date": 1604013539000, | ||
"message": "Hi, I’m JD and I’m looking for a mentor who can help me find my first job as a software developer. I’ve been learning JavaScript for the last 6 months and I think I’m ready.", | ||
"background": "I’ve been working as an accountant for the last 2 years, but ever since I wrote my first line of code I enjoyed so much.", | ||
"expectation": "Would be nice to have weekly meetings, but I know you might be busy so please let me know if this works for you.", | ||
"isMine": false | ||
}, | ||
{ | ||
"id": 789, | ||
"mentee": { | ||
"id": "003", | ||
"name": "User 003", | ||
"avatar": "https://avatars0.githubusercontent.com/u/219207?s=88&v=4", | ||
"title": "J web dev" | ||
}, | ||
"status": "New", | ||
"date": 1609283939000, | ||
"message": "Hi, I’m JD and I’m looking for a mentor who can help me find my first job as a software developer. I’ve been learning JavaScript for the last 6 months and I think I’m ready.", | ||
"background": "I’ve been working as an accountant for the last 2 years, but ever since I wrote my first line of code I enjoyed so much.", | ||
"expectation": "Would be nice to have weekly meetings, but I know you might be busy so please let me know if this works for you.", | ||
"isMine": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"success": true, | ||
"mentorship": { | ||
"status": "Viewed" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* eslint-disable no-undef */ | ||
import userData from '../fixtures/users/current/get.json'; | ||
import reqData from '../fixtures/mentorship-requests/get.json'; | ||
import { STATUS } from '../../src/helpers/mentorship'; | ||
|
||
const { cy } = global; | ||
|
||
const { data: user } = userData; | ||
const { data: requests } = reqData; | ||
const reqType = { | ||
approved: requests.find(({ status }) => status === STATUS.approved), | ||
rejected: requests.find(({ status }) => status === STATUS.rejected), | ||
new: requests.find(({ status }) => status === STATUS.new), | ||
}; | ||
|
||
const regex = ({ mentee: { id } }) => new RegExp(`User ${id}`); | ||
|
||
describe('Mentorship Requests', () => { | ||
before(function() { | ||
cy.login(); | ||
cy.intercept('GET', '/users/current', { fixture: 'users/current/get' }); | ||
cy.intercept('GET', `/mentorships/${user._id}/requests`, { | ||
fixture: 'mentorship-requests/get', | ||
}); | ||
cy.intercept('PUT', `/mentorships/${user._id}/requests/${reqType.new.id}`, { | ||
fixture: 'mentorship-requests/put', | ||
}); | ||
cy.visit(`/me/requests`); | ||
}); | ||
|
||
// TODO enable it if possible | ||
// it('Should show spinner while loading requests', () => { | ||
// cy.findAllByRole('status').should('exist'); | ||
// }); | ||
// it('got 3 requests', () => { | ||
// cy.findByText('Mentorship Requests') | ||
// .get('ul') | ||
// .findAllByText(/User.*/) | ||
// .should('exist') | ||
// .should('have.length', 3); | ||
// }); | ||
|
||
describe('Mentorship Content', () => { | ||
it('Should expand and show more details on request item click', () => { | ||
const errorMessage = | ||
'Unable to find an element by: [data-testid="request-content"]'; | ||
|
||
cy.on('fail', err => { | ||
expect(err.message).to.contain(errorMessage); | ||
}); | ||
|
||
cy.findAllByTestId('request-content'); | ||
}); | ||
it('Should toggle item on Click', () => { | ||
cy.findByText('Mentorship Requests') | ||
.get('ul') | ||
.findByText(regex(reqType.new)) | ||
.click(); | ||
|
||
cy.findAllByTestId('request-content'); | ||
}); | ||
it('Should only expand one item at a time', () => { | ||
const { message } = reqType.new; | ||
const errorMessage = `Unable to find an element with the text: ${message}`; | ||
cy.on('fail', err => { | ||
expect(err.message).to.contain(errorMessage); | ||
}); | ||
|
||
cy.findByText('Mentorship Requests') | ||
.get('ul') | ||
.findByText(regex(reqType.rejected)) | ||
.click(); | ||
|
||
cy.findAllByTestId('request-content').within(() => { | ||
cy.findByText(message).should('not.exist'); | ||
}); | ||
}); | ||
it('Should have Message, Background and Expectation', () => { | ||
cy.findAllByTestId('request-content') | ||
.findAllByText(/Message|Background|Expectations/) | ||
.should('have.length', 9); | ||
cy.findAllByTestId('request-content') | ||
.get('p') | ||
.then($ps => { | ||
// 3 for each mentorship request + 1 no My Mentorship Requests | ||
expect($ps).to.have.length(10); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.