This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-27802 Cypress test for MM-T40 (1.0) Plugin remains enabled when up…
…graded (#6294) * test for plugin enabled after second upload * remove new test and revert to original. test was added to incorrect location * add new plugin upgrade test * update nits * remove v.0.2.0 demo plugin after test finishes * pass in filename to attachFile fuction as 'filename' parameter * remove the plugin with inside the "after" hook
- Loading branch information
Showing
1 changed file
with
115 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// 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: @system_console @plugin | ||
|
||
/** | ||
* Note : This test requires two demo plugin tar files under fixtures folder. | ||
* Download version 0.1.0 from : | ||
* https://github.com/mattermost/mattermost-plugin-demo/releases/download/v0.1.0/com.mattermost.demo-plugin-0.1.0.tar.gz | ||
* Copy to : ./e2e/cypress/fixtures/com.mattermost.demo-plugin-0.1.0.tar.gz | ||
* | ||
* Download version 0.2.0 from : | ||
* https://github.com/mattermost/mattermost-plugin-demo/releases/download/v0.2.0/com.mattermost.demo-plugin-0.2.0.tar.gz | ||
* Copy to : ./e2e/cypress/fixtures/com.mattermost.demo-plugin-0.2.0.tar.gz | ||
*/ | ||
|
||
import * as TIMEOUTS from '../../fixtures/timeouts'; | ||
|
||
describe('Plugin remains enabled when upgraded', () => { | ||
const pluginIdDemo = 'com.mattermost.demo-plugin'; | ||
|
||
before(() => { | ||
// # Initialize setup and visit town-square | ||
cy.apiInitSetup().then(({team}) => { | ||
cy.visit(`/${team.name}/channels/town-square`); | ||
|
||
// #If Demo plugin is already enabled , uninstall it | ||
cy.apiRemovePluginById(pluginIdDemo); | ||
cy.visit('/admin_console/plugins/plugin_management'); | ||
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Plugin Management'); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.apiRemovePluginById(pluginIdDemo); | ||
}); | ||
|
||
it('MT40 Plugin remains enabled when upgraded', () => { | ||
// * Upload Demo plugin from the browser | ||
const fileName1 = 'com.mattermost.demo-plugin-0.1.0.tar.gz'; | ||
const fileName2 = 'com.mattermost.demo-plugin-0.2.0.tar.gz'; | ||
const mimeType = 'application/gzip'; | ||
cy.fixture(fileName1, 'binary'). | ||
then(Cypress.Blob.binaryStringToBlob). | ||
then((fileContent) => { | ||
cy.get('input[type=file]').attachFile({fileContent, fileName: fileName1, mimeType}); | ||
}); | ||
|
||
cy.get('#uploadPlugin').scrollIntoView().should('be.visible').click().wait(TIMEOUTS.HALF_SEC); | ||
|
||
// * Verify that the button shows correct text while uploading | ||
cy.findByText('Uploading...', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); | ||
|
||
// * Verify that the button shows correct text and is disabled after upload | ||
cy.findByText('Upload', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); | ||
cy.get('#uploadPlugin').and('be.disabled'); | ||
|
||
// # Enable demo plugin | ||
doTaskOnPlugin(pluginIdDemo, () => { | ||
// * Verify Demo Plugin title is shown | ||
cy.waitUntil(() => cy.get('strong').scrollIntoView().should('be.visible').then((title) => { | ||
return title[0].innerText === 'Demo Plugin'; | ||
})); | ||
|
||
// # Click on Enable link | ||
cy.findByText('Enable').click(); | ||
}); | ||
|
||
// * Verify V0.1.0 of plugin | ||
cy.findByText(/0.1.0/).scrollIntoView().should('be.visible'); | ||
|
||
cy.get('#uploadPlugin').scrollIntoView().should('be.visible'); | ||
|
||
// # Upgrade plugin | ||
cy.fixture(fileName2, 'binary'). | ||
then(Cypress.Blob.binaryStringToBlob). | ||
then((fileContent) => { | ||
cy.get('input[type=file]').attachFile({fileContent, fileName: fileName2, mimeType}); | ||
}); | ||
|
||
// * Verify that the button shows correct text while uploading | ||
cy.get('#uploadPlugin').should('be.visible').click().wait(TIMEOUTS.HALF_SEC); | ||
|
||
// # Confirm overwrite of plugin with same name | ||
cy.get('#confirmModalButton').should('be.visible').click(); | ||
|
||
doTaskOnPlugin(pluginIdDemo, () => { | ||
// * Verify plugin is running | ||
waitForAlert('This plugin is running.'); | ||
}); | ||
|
||
// * Verify v0.2.0 of plugin | ||
cy.findByText(/0.2.0/).scrollIntoView().should('be.visible'); | ||
}); | ||
}); | ||
|
||
function waitForAlert(message) { | ||
cy.waitUntil(() => cy.get('.alert').scrollIntoView().should('be.visible').then((alert) => { | ||
return alert[0].innerText === message; | ||
})); | ||
} | ||
|
||
function doTaskOnPlugin(pluginId, taskCallback) { | ||
cy.findByText(/Installed Plugins/).scrollIntoView().should('be.visible'); | ||
cy.findByTestId(pluginId).scrollIntoView().should('be.visible').within(() => { | ||
// # Perform task | ||
taskCallback(); | ||
}); | ||
} |