forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-T638 Webhook posts when webhook creator is not a member of the cha…
…nnel (mattermost#7091) * wip * wip * wip * wip * added check * small fix * fix Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
...tegration/integrations/incoming_webhook/webhook_posts_when_creator_not_in_channel_spec.js
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,95 @@ | ||
|
||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
// *************************************************************** | ||
// - [#] indicates a test step (e.g. # Go to a page) | ||
// - [*] indicates an assertion (e.g. * Check the title) | ||
// - Use element ID when selecting an element. Create one if none. | ||
// *************************************************************** | ||
|
||
// Group: @integrations | ||
|
||
import {getRandomId} from '../../../utils'; | ||
|
||
describe('Integrations', () => { | ||
let testUser; | ||
let secondUser; | ||
let testTeam; | ||
let testChannel; | ||
let incomingWebhook; | ||
|
||
before(() => { | ||
// # Create new setup | ||
cy.apiInitSetup().then(({user}) => { | ||
testUser = user; | ||
|
||
// # Create a second user | ||
cy.apiCreateUser().then(({user: user2}) => { | ||
secondUser = user2; | ||
}); | ||
|
||
// # Login as the new user | ||
cy.apiLogin(testUser).then(() => { | ||
// # Create a new team with the new user | ||
cy.apiCreateTeam('test-team', 'Team Testers').then(({team}) => { | ||
testTeam = team; | ||
|
||
// # Add second user to the test team | ||
cy.apiAddUserToTeam(testTeam.id, secondUser.id); | ||
|
||
// # Create a new test channel for the team | ||
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Testers Channel').then(({channel}) => { | ||
testChannel = channel; | ||
|
||
const newIncomingHook = { | ||
channel_id: testChannel.id, | ||
channel_locked: true, | ||
description: 'Test Webhook Description', | ||
display_name: 'Test Webhook Name', | ||
}; | ||
|
||
//# Create a new webhook | ||
cy.apiCreateWebhook(newIncomingHook).then((hook) => { | ||
incomingWebhook = hook; | ||
}); | ||
|
||
// # Add second user to the test channel | ||
cy.apiAddUserToChannel(testChannel.id, secondUser.id).then(() => { | ||
// # Remove the first user from the channel | ||
cy.apiDeleteUserFromTeam(testTeam.id, testUser.id).then(({data}) => { | ||
expect(data.status).to.equal('OK'); | ||
}); | ||
|
||
// # Login as the second user | ||
cy.apiLogin(secondUser); | ||
|
||
// # Visit the test channel | ||
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
it('MM-T638 Webhook posts when webhook creator is not a member of the channel', () => { | ||
const payload = getPayload(testChannel); | ||
|
||
// # Post the webhook message | ||
cy.postIncomingWebhook({url: incomingWebhook.url, data: payload}); | ||
|
||
// * Assert that the message was posted even though webhook author has been removed | ||
cy.uiWaitUntilMessagePostedIncludes(payload.text); | ||
cy.getLastPostId().then((postId) => { | ||
cy.get(`#postMessageText_${postId}`).should('have.text', `${payload.text}`); | ||
}); | ||
}); | ||
}); | ||
|
||
function getPayload(testChannel) { | ||
return { | ||
channel: testChannel.name, | ||
text: `${getRandomId()} - this webhook was set up by a user that is no longer in this channel`, | ||
}; | ||
} |