Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e): Verify Test Notification on Desktop #3162

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/e2e-functional-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:

## Windows Dependencies
- name: e2e/install-dependencies-windows
if: steps.cache-node-modules.outputs.cache-hit != 'true' && runner.os == 'Windows'
if: runner.os == 'windows'
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
Expand All @@ -180,6 +180,7 @@ jobs:
cd e2e
npm ci
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 }}
run: |
Expand Down
6 changes: 3 additions & 3 deletions e2e/modules/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const downloadsLocation = path.join(userDataDir, 'Downloads');
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
const appUpdatePath = path.join(userDataDir, 'app-update.yml');
const exampleURL = 'http://example.com/';
const mattermostURL = process.env.MM_TEST_SERVER_URL || 'http://localhost:8065/';
const mattermostURL = 'https://mattermost-pr-28334.test.mattermost.cloud/'; // process.env.MM_TEST_SERVER_URL || 'http://localhost:8065/';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this wasn't intended to be merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah @devinbinnie .

sorry, I should have added a note. I'll remove it once the Dev PR gets into master


if (process.platform === 'win32') {
const robot = require('robotjs');
Expand Down Expand Up @@ -266,8 +266,8 @@ module.exports = {
await window.waitForSelector('#input_password-input');
await window.waitForSelector('#saveSetting');

await window.type('#input_loginId', process.env.MM_TEST_USER_NAME);
await window.type('#input_password-input', process.env.MM_TEST_PASSWORD);
await window.type('#input_loginId', 'sysadmin');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

await window.type('#input_password-input', 'Sys@dmin123');
await window.click('#saveSetting');
},

Expand Down
28 changes: 28 additions & 0 deletions e2e/specs/notification_trigger/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const {asyncSleep} = require('../../modules/utils');

Check failure on line 1 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

missing header

Check failure on line 1 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-linux

missing header

Check failure on line 1 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

missing header

export async function triggerTestNotification(firstServer) {
devinbinnie marked this conversation as resolved.
Show resolved Hide resolved
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()

Check failure on line 22 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

Missing semicolon

Check failure on line 22 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-linux

Missing semicolon

Check failure on line 22 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

Missing semicolon
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!");

Check failure on line 27 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

Strings must use singlequote

Check failure on line 27 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-linux

Strings must use singlequote

Check failure on line 27 in e2e/specs/notification_trigger/helpers.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

Strings must use singlequote
}
42 changes: 42 additions & 0 deletions e2e/specs/notification_trigger/notification_badge_in_dock.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {triggerTestNotification, verifyNotificationRecievedinDM} from './helpers';

Check failure on line 4 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

There should be at least one empty line between import groups

Check failure on line 4 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-linux

There should be at least one empty line between import groups

Check failure on line 4 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

There should be at least one empty line between import groups
const fs = require('fs');

Check failure on line 5 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

There should be at least one empty line between import groups

Check failure on line 5 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-linux

There should be at least one empty line between import groups

Check failure on line 5 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

There should be at least one empty line between import groups
const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils');


Check failure on line 9 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-mac-no-dmg

More than 1 blank line not allowed

Check failure on line 9 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-linux

More than 1 blank line not allowed

Check failure on line 9 in e2e/specs/notification_trigger/notification_badge_in_dock.test.js

View workflow job for this annotation

GitHub Actions / build-win-no-installer

More than 1 blank line not allowed
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);
});
});
2 changes: 1 addition & 1 deletion e2e/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const webpack = require('webpack');
module.exports = {
mode: 'development',
entry: {
e2e: glob.sync('./specs/**/*.js'),
e2e: glob.sync('./specs/**/notification_tri*.test.js'),
},
output: {
path: path.resolve(__dirname, 'dist/'),
Expand Down
Loading