MM-54514 fix for invite_id being updated on all changes (#24674)
* fix for invite_id being updated on all changes * lint fixes * update webapp unit tests * change fix to webapp * lint fixes * Update teams.ts * update tests * revert package-lock.json --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6125b0ca7f
Коммит
86812b9b9e
@@ -126,7 +126,10 @@ describe('components/TeamSettings', () => {
|
|||||||
wrapper.instance().handleAllowedDomainsSubmit();
|
wrapper.instance().handleAllowedDomainsSubmit();
|
||||||
|
|
||||||
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
||||||
expect(actions.patchTeam).toHaveBeenCalledWith(props.team);
|
expect(actions.patchTeam).toHaveBeenCalledWith({
|
||||||
|
allowed_domains: '',
|
||||||
|
id: props.team?.id,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should call actions.patchTeam on handleNameSubmit', () => {
|
test('should call actions.patchTeam on handleNameSubmit', () => {
|
||||||
@@ -141,7 +144,10 @@ describe('components/TeamSettings', () => {
|
|||||||
wrapper.instance().handleNameSubmit();
|
wrapper.instance().handleNameSubmit();
|
||||||
|
|
||||||
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
||||||
expect(actions.patchTeam).toHaveBeenCalledWith(props.team);
|
expect(actions.patchTeam).toHaveBeenCalledWith({
|
||||||
|
display_name: props.team?.display_name,
|
||||||
|
id: props.team?.id,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should call actions.patchTeam on handleInviteIdSubmit', () => {
|
test('should call actions.patchTeam on handleInviteIdSubmit', () => {
|
||||||
@@ -173,7 +179,10 @@ describe('components/TeamSettings', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
expect(actions.patchTeam).toHaveBeenCalledTimes(1);
|
||||||
expect(actions.patchTeam).toHaveBeenCalledWith(props.team);
|
expect(actions.patchTeam).toHaveBeenCalledWith({
|
||||||
|
description: newDescription,
|
||||||
|
id: props.team?.id,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should match snapshot when team is group constrained', () => {
|
test('should match snapshot when team is group constrained', () => {
|
||||||
|
|||||||
@@ -106,9 +106,10 @@ export class GeneralTab extends React.PureComponent<Props, State> {
|
|||||||
handleAllowedDomainsSubmit = async () => {
|
handleAllowedDomainsSubmit = async () => {
|
||||||
const state = {serverError: '', clientError: ''};
|
const state = {serverError: '', clientError: ''};
|
||||||
|
|
||||||
const data = {...this.props.team};
|
const data = {
|
||||||
data.allowed_domains = this.state.allowed_domains;
|
id: this.props.team?.id,
|
||||||
|
allowed_domains: this.state.allowed_domains,
|
||||||
|
};
|
||||||
const {error} = await this.props.actions.patchTeam(data);
|
const {error} = await this.props.actions.patchTeam(data);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -151,9 +152,10 @@ export class GeneralTab extends React.PureComponent<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {...this.props.team};
|
const data = {
|
||||||
data.display_name = this.state.name;
|
id: this.props.team?.id,
|
||||||
|
display_name: this.state.name,
|
||||||
|
};
|
||||||
const {error} = await this.props.actions.patchTeam(data);
|
const {error} = await this.props.actions.patchTeam(data);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -198,9 +200,10 @@ export class GeneralTab extends React.PureComponent<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {...this.props.team};
|
const data = {
|
||||||
data.description = this.state.description;
|
id: this.props.team?.id,
|
||||||
|
description: this.state.description,
|
||||||
|
};
|
||||||
const {error} = await this.props.actions.patchTeam(data);
|
const {error} = await this.props.actions.patchTeam(data);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -737,38 +737,77 @@ describe('Actions.Teams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('setTeamIcon', async () => {
|
it('setTeamIcon', async () => {
|
||||||
|
const team = {id: 'teamId', invite_id: ''};
|
||||||
|
store = configureStore({
|
||||||
|
entities: {
|
||||||
|
teams: {
|
||||||
|
teams: {
|
||||||
|
[team!.id]: {...team},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
TestHelper.mockLogin();
|
TestHelper.mockLogin();
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: UserTypes.LOGIN_SUCCESS,
|
type: UserTypes.LOGIN_SUCCESS,
|
||||||
});
|
});
|
||||||
await loadMe()(store.dispatch, store.getState);
|
await loadMe()(store.dispatch, store.getState);
|
||||||
|
|
||||||
const team = TestHelper.basicTeam;
|
let state = store.getState();
|
||||||
|
expect(state.entities.teams.teams[team!.id].invite_id).toEqual('');
|
||||||
|
|
||||||
const imageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
|
const imageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
|
||||||
|
|
||||||
nock(Client4.getTeamRoute(team!.id)).
|
nock(Client4.getTeamRoute(team!.id)).
|
||||||
post('/image').
|
post('/image').
|
||||||
reply(200, OK_RESPONSE);
|
reply(200, OK_RESPONSE);
|
||||||
|
|
||||||
|
nock(Client4.getTeamRoute(team!.id)).
|
||||||
|
get('').
|
||||||
|
reply(200, {...team, invite_id: 'inviteId'});
|
||||||
|
|
||||||
const {data} = await Actions.setTeamIcon(team!.id, imageData as any)(store.dispatch, store.getState) as ActionResult;
|
const {data} = await Actions.setTeamIcon(team!.id, imageData as any)(store.dispatch, store.getState) as ActionResult;
|
||||||
expect(data).toEqual(OK_RESPONSE);
|
expect(data).toEqual(OK_RESPONSE);
|
||||||
|
|
||||||
|
state = store.getState();
|
||||||
|
expect(state.entities.teams.teams[team!.id].invite_id).toEqual('inviteId');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removeTeamIcon', async () => {
|
it('removeTeamIcon', async () => {
|
||||||
|
const team = {id: 'teamId', invite_id: ''};
|
||||||
|
store = configureStore({
|
||||||
|
entities: {
|
||||||
|
teams: {
|
||||||
|
teams: {
|
||||||
|
[team!.id]: {...team},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
TestHelper.mockLogin();
|
TestHelper.mockLogin();
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: UserTypes.LOGIN_SUCCESS,
|
type: UserTypes.LOGIN_SUCCESS,
|
||||||
});
|
});
|
||||||
await loadMe()(store.dispatch, store.getState);
|
await loadMe()(store.dispatch, store.getState);
|
||||||
|
|
||||||
const team = TestHelper.basicTeam;
|
let state = store.getState();
|
||||||
|
expect(state.entities.teams.teams[team!.id].invite_id).toEqual('');
|
||||||
|
|
||||||
nock(Client4.getTeamRoute(team!.id)).
|
nock(Client4.getTeamRoute(team!.id)).
|
||||||
delete('/image').
|
delete('/image').
|
||||||
reply(200, OK_RESPONSE);
|
reply(200, OK_RESPONSE);
|
||||||
|
|
||||||
|
nock(Client4.getTeamRoute(team!.id)).
|
||||||
|
get('').
|
||||||
|
reply(200, {...team, invite_id: 'inviteId'});
|
||||||
|
|
||||||
const {data} = await Actions.removeTeamIcon(team!.id)(store.dispatch, store.getState) as ActionResult;
|
const {data} = await Actions.removeTeamIcon(team!.id)(store.dispatch, store.getState) as ActionResult;
|
||||||
expect(data).toEqual(OK_RESPONSE);
|
expect(data).toEqual(OK_RESPONSE);
|
||||||
|
|
||||||
|
state = store.getState();
|
||||||
|
expect(state.entities.teams.teams[team!.id].invite_id).toEqual('inviteId');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updateTeamScheme', async () => {
|
it('updateTeamScheme', async () => {
|
||||||
|
|||||||
@@ -737,22 +737,27 @@ export function joinTeam(inviteId: string, teamId: string): ActionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setTeamIcon(teamId: string, imageData: File): ActionFunc {
|
export function setTeamIcon(teamId: string, imageData: File): ActionFunc {
|
||||||
return bindClientFunc({
|
return async (dispatch: DispatchFunc) => {
|
||||||
clientFunc: Client4.setTeamIcon,
|
await Client4.setTeamIcon(teamId, imageData);
|
||||||
params: [
|
const team = await Client4.getTeam(teamId);
|
||||||
teamId,
|
dispatch({
|
||||||
imageData,
|
type: TeamTypes.PATCHED_TEAM,
|
||||||
],
|
data: team,
|
||||||
});
|
});
|
||||||
|
return {data: {status: 'OK'}};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeTeamIcon(teamId: string): ActionFunc {
|
export function removeTeamIcon(teamId: string): ActionFunc {
|
||||||
return bindClientFunc({
|
return async (dispatch: DispatchFunc) => {
|
||||||
clientFunc: Client4.removeTeamIcon,
|
await Client4.removeTeamIcon(teamId);
|
||||||
params: [
|
const team = await Client4.getTeam(teamId);
|
||||||
teamId,
|
dispatch({
|
||||||
],
|
type: TeamTypes.PATCHED_TEAM,
|
||||||
});
|
data: team,
|
||||||
|
});
|
||||||
|
return {data: {status: 'OK'}};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateTeamScheme(teamId: string, schemeId: string): ActionFunc {
|
export function updateTeamScheme(teamId: string, schemeId: string): ActionFunc {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user