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-22825 Add E2E on skipping Slack-compatible interactive message res…
…ponse (mattermost#5183) * add E2E on skipping Slack-compatible response * update test description
- Loading branch information
1 parent
9997596
commit d653ba9
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
e2e/cypress/integration/interactive_menu/slack_parsing_message_button_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,110 @@ | ||
// 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. | ||
// *************************************************************** | ||
|
||
/** | ||
* Note: This test requires webhook server running. Initiate `npm run start:webhook` to start. | ||
*/ | ||
|
||
import TIMEOUTS from '../../fixtures/timeouts'; | ||
|
||
let channel; | ||
let incomingWebhook; | ||
|
||
describe('Interactive Menu', () => { | ||
before(() => { | ||
cy.requireWebhookServer(); | ||
|
||
// # Login as sysadmin | ||
cy.apiLogin('sysadmin'); | ||
|
||
// Set required ServiceSettings | ||
const newSettings = { | ||
ServiceSettings: { | ||
AllowedUntrustedInternalConnections: 'localhost', | ||
EnablePostUsernameOverride: true, | ||
EnablePostIconOverride: true, | ||
}, | ||
}; | ||
cy.apiUpdateConfig(newSettings); | ||
|
||
// # Update teammate name display setting is set to default 'username' | ||
cy.apiSaveTeammateNameDisplayPreference('username'); | ||
cy.apiSaveMessageDisplayPreference('clean'); | ||
|
||
// # Create and visit new channel and create incoming webhook | ||
cy.createAndVisitNewChannel().then((data) => { | ||
channel = data; | ||
|
||
const newIncomingHook = { | ||
channel_id: channel.id, | ||
channel_locked: true, | ||
description: 'Incoming webhook interactive menu', | ||
display_name: 'menuIn' + Date.now(), | ||
}; | ||
|
||
cy.apiCreateWebhook(newIncomingHook).then((hook) => { | ||
incomingWebhook = hook; | ||
}); | ||
}); | ||
}); | ||
|
||
it('should parse text into Slack-compatible markdown depending on "skip_slack_parsing" property on response', () => { | ||
const payload = getPayload(Cypress.env().webhookBaseUrl); | ||
|
||
// # Post an incoming webhook | ||
cy.postIncomingWebhook({url: incomingWebhook.url, data: payload}); | ||
|
||
// # Click on "Skip Parsing" button | ||
cy.findByText('Skip Parsing').should('be.visible').click({force: true}); | ||
cy.wait(TIMEOUTS.TINY); | ||
|
||
// * Verify that it renders original "spoiler" text | ||
cy.getLastPostId().then((postId) => { | ||
cy.get(`#postMessageText_${postId}`).should('have.html', '<p>a < a | b > a</p>'); | ||
}); | ||
|
||
// # Click on "Do Parsing" button | ||
cy.findByText('Do Parsing').should('be.visible').click({force: true}); | ||
cy.wait(TIMEOUTS.TINY); | ||
|
||
// * Verify that it renders markdown with link | ||
cy.getLastPostId().then((postId) => { | ||
cy.get(`#postMessageText_${postId}`).should('have.html', '<p>a <a class="theme markdown__link" href="https://a" rel="noreferrer" target="_blank"> b </a> a</p>'); | ||
}); | ||
}); | ||
}); | ||
|
||
function getPayload(webhookBaseUrl) { | ||
return { | ||
attachments: [{ | ||
pretext: 'Slack-compatible interactive message response', | ||
actions: [{ | ||
name: 'Skip Parsing', | ||
integration: { | ||
url: `${webhookBaseUrl}/slack_compatible_message_response`, | ||
context: { | ||
action: 'show_spoiler', | ||
spoiler: 'a < a | b > a', | ||
skipSlackParsing: true, | ||
}, | ||
} | ||
}, { | ||
name: 'Do Parsing', | ||
integration: { | ||
url: `${webhookBaseUrl}/slack_compatible_message_response`, | ||
context: { | ||
action: 'show_spoiler', | ||
spoiler: 'a < a | b > a', | ||
skipSlackParsing: 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