Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4097 from withspectrum/2.4.48
Browse files Browse the repository at this point in the history
2.4.48
  • Loading branch information
brianlovin authored Oct 23, 2018
2 parents 50a4389 + 7e11aa1 commit 07ae79b
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 32 deletions.
20 changes: 10 additions & 10 deletions api/mutations/user/editUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ export default requireAuth(
}
}

return editUser(args, user.id).then(async res => {
await updateCookieUserData({
...res,
}).catch(err => {
Raven.captureException(
new Error(`Error updating cookie user data: ${err.message}`)
);
return res;
});
const editedUser = await editUser(args, user.id);

return res;
await updateCookieUserData({
...editedUser,
}).catch(err => {
Raven.captureException(
new Error(`Error updating cookie user data: ${err.message}`)
);
return editedUser;
});

return editedUser;
}
);
54 changes: 54 additions & 0 deletions cypress/integration/user/edit_user_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import data from '../../../shared/testing/data';

const user = data.users[0];

const NEW_NAME = 'Brian Edited';
const NEW_DESCRIPTION = 'Description Edited';
const NEW_WEBSITE = 'Website Edited';
const NEW_USERNAME = 'brian-edited';

describe('edit a user', () => {
beforeEach(() => {
cy.auth(user.id);
cy.visit(`/me/settings`);
});

it('should edit a user', () => {
cy.get('[data-cy="user-edit-form"]').should('be.visible');

cy.get('[data-cy="user-name-input"]')
.should('be.visible')
.click()
.clear()
.type(NEW_NAME);

cy.get('[data-cy="user-username-input"]')
.should('be.visible')
.click()
.clear()
.type(NEW_USERNAME);

cy.get('[data-cy="user-description-input"]')
.should('be.visible')
.click()
.clear()
.type(NEW_DESCRIPTION);

cy.get('[data-cy="user-website-input"]')
.should('be.visible')
.click()
.clear()
.type(NEW_WEBSITE);

cy.get('[data-cy="save-button"]')
.should('be.visible')
.click();

cy.visit(`/users/${NEW_USERNAME}`);
cy.get('[data-cy="user-view"]').should('be.visible');
cy.get('[data-cy="user-view"]').contains(NEW_NAME);
cy.get('[data-cy="user-view"]').contains(NEW_DESCRIPTION);
cy.get('[data-cy="user-view"]').contains(NEW_WEBSITE);
cy.get('[data-cy="user-view"]').contains(NEW_USERNAME);
});
});
1 change: 1 addition & 0 deletions hyperion/renderer/browser-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ global.window = {
host: 'spectrum.chat',
hash: '',
},
addEventListener: () => {},
};
global.localStorage = {
getItem: () => null,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@
"raf": "^3.4.0",
"raven": "^2.6.4",
"raven-js": "^3.27.0",
"react": "^16.4.0",
"react": "^16.5.2",
"react-apollo": "^2.2.4",
"react-app-rewire-styled-components": "^3.0.0",
"react-app-rewired": "^1.6.2",
"react-clipboard.js": "^2.0.1",
"react-dom": "^16.4.0",
"react-dom": "^16.5.2",
"react-flip-move": "^3.0.2",
"react-helmet-async": "^0.1.0",
"react-image": "^1.5.1",
Expand Down
8 changes: 3 additions & 5 deletions shared/db/create-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,13 @@ type CreateWriteQueryInput<I, O> = $Exact<{
}>;

export const createWriteQuery = <I: Array<*>, O: *>(callback: any) => {
return callback;
/*
return async (...args: I) => {
const input = callback(...args);
const result = await input.query;
if (typeof result.run === 'function') throw new Error(WRITE_RUN_ERROR);

const tags = input.invalidateTags(result).filter(Boolean);
await queryCache.invalidate(...tags);
// const tags = input.invalidateTags(result).filter(Boolean);
// await queryCache.invalidate(...tags);
return result;
};*/
};
};
10 changes: 1 addition & 9 deletions src/actions/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ export const saveUserDataToLocalStorage = (user: Object) => async dispatch => {
}
// construct a clean object that doesn't include any metadata from apollo
// like __typename
obj['currentUser'] = {
id: user.id,
name: user.name,
username: user.username,
profilePhoto: user.profilePhoto,
coverPhoto: user.coverPhoto,
website: user.website,
totalReputation: user.totalReputation,
};
obj['currentUser'] = user;

// logs user id to analytics
const response = await fetch(
Expand Down
4 changes: 3 additions & 1 deletion src/components/usernameSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Props = {
size: string,
onValidationResult: ({ error: string, success: string }) => void,
onError: ?(err: Error) => void,
dataCy?: string,
};

type State = {
Expand Down Expand Up @@ -135,13 +136,14 @@ class UsernameSearch extends React.Component<Props, State> {

render() {
const { username, isSearching } = this.state;
const { label, size } = this.props;
const { label, size, dataCy } = this.props;
return (
<React.Fragment>
<Input
{...this.props}
defaultValue={username}
onChange={this.handleChange}
dataCy={dataCy}
>
{label && label}
{isSearching && (
Expand Down
4 changes: 3 additions & 1 deletion src/components/usernameSearch/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ export const StyledInput = styled.input`
`;

export const Input = props => {
const { dataCy, ...rest } = props;
return (
<StyledLabel {...props}>
<StyledLabel {...rest}>
{props.children}
<StyledInput
id={props.id}
Expand All @@ -83,6 +84,7 @@ export const Input = props => {
autoFocus={props.autoFocus}
disabled={props.disabled}
size={props.size}
data-cy={dataCy}
/>
</StyledLabel>
);
Expand Down
12 changes: 10 additions & 2 deletions src/views/userSettings/components/editForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class UserWithData extends React.Component<Props, State> {
const postAuthRedirectPath = `?r=${CLIENT_URL}/users/${username}/settings`;

return (
<SectionCard>
<SectionCard data-cy="user-edit-form">
<Location>
<Icon glyph="view-back" size={16} />
<Link to={`/users/${username}`}>Return to Profile</Link>
Expand Down Expand Up @@ -313,6 +313,7 @@ class UserWithData extends React.Component<Props, State> {
defaultValue={name}
onChange={this.changeName}
placeholder={"What's your name?"}
dataCy="user-name-input"
>
Name
</Input>
Expand All @@ -326,6 +327,7 @@ class UserWithData extends React.Component<Props, State> {
username={username}
onValidationResult={this.handleUsernameValidation}
onError={this.handleOnError}
dataCy="user-username-input"
/>

{usernameError && (
Expand All @@ -336,13 +338,18 @@ class UserWithData extends React.Component<Props, State> {
defaultValue={description}
onChange={this.changeDescription}
placeholder={'Introduce yourself to the class...'}
dataCy="user-description-input"
>
Bio
</TextArea>

{descriptionError && <Error>Bios can be up to 140 characters.</Error>}

<Input defaultValue={website} onChange={this.changeWebsite}>
<Input
defaultValue={website}
onChange={this.changeWebsite}
dataCy="user-website-input"
>
Optional: Add your website
</Input>

Expand Down Expand Up @@ -382,6 +389,7 @@ class UserWithData extends React.Component<Props, State> {
}
loading={isLoading}
onClick={this.save}
dataCy="save-button"
>
Save
</Button>
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9219,7 +9219,7 @@ react-dev-utils@^5.0.2:
strip-ansi "3.0.1"
text-table "0.2.0"

react-dom@^16.4.0:
react-dom@^16.5.2:
version "16.5.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
dependencies:
Expand Down Expand Up @@ -9415,7 +9415,7 @@ react-visibility-sensor@^5.0.1:
dependencies:
prop-types "^15.6.2"

react@*, react@^16.4.0:
react@*, react@^16.5.2:
version "16.5.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
dependencies:
Expand Down

0 comments on commit 07ae79b

Please sign in to comment.