feat(e2e): Verify Test Notification on Desktop (#3162)
This commit is contained in:
@@ -167,7 +167,7 @@ jobs:
|
|||||||
|
|
||||||
## Windows Dependencies
|
## Windows Dependencies
|
||||||
- name: e2e/install-dependencies-windows
|
- name: e2e/install-dependencies-windows
|
||||||
if: steps.cache-node-modules.outputs.cache-hit != 'true' && runner.os == 'Windows'
|
if: runner.os == 'windows'
|
||||||
env:
|
env:
|
||||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||||
run: |
|
run: |
|
||||||
@@ -180,6 +180,7 @@ jobs:
|
|||||||
cd e2e
|
cd e2e
|
||||||
npm ci
|
npm ci
|
||||||
npx electron-rebuild --platform=win32 -f -t prod,optional,dev -w robotjs --module-dir ../
|
npx electron-rebuild --platform=win32 -f -t prod,optional,dev -w robotjs --module-dir ../
|
||||||
|
npm install mochawesome-report-generator
|
||||||
|
|
||||||
- name: e2e/run-playright-tests-${{ runner.os }}
|
- name: e2e/run-playright-tests-${{ runner.os }}
|
||||||
run: |
|
run: |
|
||||||
|
30
e2e/specs/notification_trigger/helpers.js
Normal file
30
e2e/specs/notification_trigger/helpers.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
|
|
||||||
|
export async function triggerTestNotification(firstServer) {
|
||||||
|
await firstServer.click('div#CustomizeYourExperienceTour > button');
|
||||||
|
const sendNotificationButton = await firstServer.waitForSelector('.sectionNoticeButton.btn-primary');
|
||||||
|
await sendNotificationButton.scrollIntoViewIfNeeded();
|
||||||
|
const textBeforeClick = await sendNotificationButton.textContent();
|
||||||
|
textBeforeClick.should.equal('Send a test notification');
|
||||||
|
await sendNotificationButton.click();
|
||||||
|
await asyncSleep(3000);
|
||||||
|
const textAfterClick = await sendNotificationButton.textContent();
|
||||||
|
textAfterClick.should.equal('Test notification sent');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function verifyNotificationRecievedinDM(firstServer) {
|
||||||
|
await firstServer.click('#accountSettingsHeader > button.close');
|
||||||
|
const sidebarLink = await firstServer.locator('a.SidebarLink:has-text("system-bot")');
|
||||||
|
const badgeElement = await sidebarLink.locator('span.badge');
|
||||||
|
const badgeCount = await badgeElement.textContent();
|
||||||
|
badgeCount.should.equal('1');
|
||||||
|
|
||||||
|
sidebarLink.click();
|
||||||
|
await asyncSleep(1000);
|
||||||
|
|
||||||
|
const lastPostBody = await firstServer.locator('div.post__body').last();
|
||||||
|
const textContent = await lastPostBody.textContent();
|
||||||
|
textContent.should.equal('If you received this test notification, it worked!');
|
||||||
|
}
|
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
import {triggerTestNotification, verifyNotificationRecievedinDM} from './helpers';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const env = require('../../modules/environment');
|
||||||
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
|
|
||||||
|
describe('Trigger Notification From desktop', function desc() {
|
||||||
|
this.timeout(400000);
|
||||||
|
|
||||||
|
const config = env.demoMattermostConfig;
|
||||||
|
let firstServer;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
env.cleanDataDir();
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
|
await asyncSleep(1000);
|
||||||
|
this.app = await env.getApp();
|
||||||
|
this.serverMap = await env.getServerMap(this.app);
|
||||||
|
|
||||||
|
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
|
||||||
|
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
|
||||||
|
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
|
||||||
|
await env.loginToMattermost(firstServer);
|
||||||
|
const textbox = await firstServer.waitForSelector('#post_textbox');
|
||||||
|
textbox.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
// This support to getBadge is only available for MacOS
|
||||||
|
env.shouldTest(it, process.platform === 'darwin')('should receive a notification on macOS', async () => {
|
||||||
|
await triggerTestNotification(firstServer);
|
||||||
|
const badgeValue = await this.app.evaluate(async ({app}) => {
|
||||||
|
return app.dock.getBadge();
|
||||||
|
});
|
||||||
|
badgeValue.should.equal('1');
|
||||||
|
await verifyNotificationRecievedinDM(firstServer);
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user