-
-
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
88 changed files
with
1,517 additions
and
917 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
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,4 +1,7 @@ | ||
module.exports = { | ||
stories: ['../src/**/*.stories.@(js|mdx|json)'], | ||
stories: ['../src/**/*.stories.@(js|mdx|json|tsx)'], | ||
addons: ['@storybook/preset-create-react-app', '@storybook/addon-essentials'], | ||
typescript: { | ||
reactDocgen: 'react-docgen', | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const withSuccess = <T>(data?: T) => ({ | ||
success: true, | ||
data, | ||
}); | ||
|
||
export const withError = (errors: string[]) => ({ | ||
success: false, | ||
errors, | ||
}); |
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,28 @@ | ||
import { User } from '../../../../src/types/models'; | ||
|
||
const defaults: User = { | ||
_id: '1', | ||
title: 'One of the best', | ||
name: 'Brent M Clark', | ||
email: '[email protected]', | ||
roles: ['Mentor'], | ||
avatar: | ||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtBAMAAADINP+pAAAAG1BMVEXMzMyWlpa+vr6xsbG3t7fFxcWqqqqjo6OcnJzvcxCxAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAANElEQVQ4jWNgGAUjGDCZpcBJZMBsgiCRgat5M4OJAohEBYlCigzhYBINGCcD1YPIUTCsAADs9gb4p4yG2QAAAABJRU5ErkJggg==', | ||
spokenLanguages: ['en', 'he'], | ||
country: 'US', | ||
tags: ['cypress', 'react', 'typescript'], | ||
available: false, | ||
channels: [ | ||
{ | ||
id: '[email protected]', | ||
type: 'email', | ||
}, | ||
], | ||
}; | ||
|
||
export const userBuilder = (user: Partial<User> = {}) => { | ||
return { | ||
...defaults, | ||
...user, | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { User } from '../../../src/types/models'; | ||
import { withSuccess } from '../../builders/response'; | ||
import { userBuilder } from '../../builders/users/current/get'; | ||
|
||
const driverFactory = () => { | ||
let user: Partial<User> = {}; | ||
|
||
return { | ||
given: { | ||
user: (_user: Partial<User>) => { | ||
user = _user; | ||
}, | ||
}, | ||
init() { | ||
cy.intercept('GET', '/users/current', withSuccess(userBuilder(user))); | ||
cy.intercept('PUT', '/users/1', withSuccess()); | ||
cy.login(); | ||
cy.visit('/me'); | ||
openEditModal(); | ||
}, | ||
}; | ||
}; | ||
|
||
const openEditModal = () => { | ||
cy.get('button') | ||
.should('have.text', 'Edit') | ||
.click(); | ||
}; | ||
|
||
describe('Me / edit profile', () => { | ||
let driver: ReturnType<typeof driverFactory>; | ||
|
||
beforeEach(() => { | ||
driver = driverFactory(); | ||
}); | ||
|
||
it('should form has the user details', () => { | ||
driver.init(); | ||
cy.get('input[name="name"]').should('have.value', 'Brent M Clark'); | ||
}); | ||
|
||
it('should show validation message when missing required fields', () => { | ||
driver.given.user({ title: '' }); | ||
driver.init(); | ||
|
||
cy.contains('button', 'Save').click(); | ||
|
||
cy.get('div').should( | ||
'include.text', | ||
'The following fields is missing or invalid' | ||
); | ||
}); | ||
|
||
it('should show success toast upon successful submit', () => { | ||
driver.init(); | ||
|
||
cy.contains('button', 'Save').click(); | ||
|
||
cy.get('.Toastify').should( | ||
'include.text', | ||
'Your details updated successfully' | ||
); | ||
}); | ||
}); |
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,25 @@ | ||
import { withSuccess } from '../../builders/response'; | ||
import { userBuilder } from '../../builders/users/current/get'; | ||
|
||
describe('Me / home', () => { | ||
before(() => { | ||
cy.intercept('GET', '/users/current', withSuccess(userBuilder())); | ||
cy.login(); | ||
cy.visit('/me'); | ||
}); | ||
|
||
describe('Avatar', () => { | ||
it('should present user avatar', () => { | ||
cy.get(`img[alt="[email protected]"]`); | ||
}); | ||
}); | ||
|
||
describe('Details', () => { | ||
it('should present user details', () => { | ||
cy.getByTestId('email-label').should( | ||
'have.text', | ||
'[email protected]' | ||
); | ||
}); | ||
}); | ||
}); |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"isolatedModules": true, | ||
// be explicit about types included | ||
// to avoid clashing with Jest types | ||
"types": ["cypress"] | ||
}, | ||
"include": [ | ||
"../node_modules/cypress", | ||
"./**/*.ts", | ||
"../src/types/models.d.ts" | ||
] | ||
} |
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,4 +1,3 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Header from './Header'; | ||
|
||
|
File renamed without changes.
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.