Merge pull request #15958 from gabriellpr/shared-notes-tests

test: Shared notes
This commit is contained in:
Anton Georgiev 2022-12-01 09:50:32 -05:00 committed by GitHub
commit dbf5143941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 179 additions and 56 deletions

View File

@ -19,6 +19,7 @@ const PadContent = ({
<Styled.Iframe
title="shared notes viewing mode"
srcDoc={contentWithStyle}
data-test="sharedNotesViewingMode"
/>
</Styled.Wrapper>
);

View File

@ -152,6 +152,11 @@ exports.etherpadFrame = 'iframe[title="pad"]';
exports.etherpadOuter = 'iframe[title="Ether"]';
exports.etherpadInner = 'iframe[title="pad"]';
exports.etherpadEditable = 'body[id="innerdocbody"]';
exports.sendNotesToWhiteboard = 'li[data-test="moveNotesToWhiteboard"]';
exports.presentationUploadProgressToast = 'div[data-test="presentationUploadProgressToast"]';
exports.sharedNotesViewingMode = 'iframe[title="shared notes viewing mode"]';
exports.currentSlideText = 'span[id="currentSlideText"]';
exports.notesOptions = 'button[data-test="notesOptionsMenu"]';
// Notifications
exports.smallToastMsg = 'div[data-test="toastSmallMsg"]';
@ -378,6 +383,8 @@ exports.pencil = 'button[data-test="pencilTool"]';
exports.showMoreSharedNotesButton = 'span[class="show-more-icon-btn"]'
exports.exportSharedNotesButton = 'button[aria-label="Import/Export from/to different file formats"]';
exports.exportPlainButton = 'span[id="exportplain"]';
exports.pinNotes = 'li[data-test="pinNotes"]';
exports.unpinNotes = 'button[data-test="unpinNotes"]';
// About modal
exports.showAboutModalButton = 'li[data-test="aboutModal"]';

View File

@ -1,45 +1,46 @@
const { default: test } = require('@playwright/test');
const Page = require('../core/page');
const { MultiUsers } = require('../user/multiusers');
const { getSettings } = require('../core/settings');
const e = require('../core/elements');
const { startSharedNotes, getNotesLocator, getShowMoreButtonLocator, getExportButtonLocator, getExportPlainTextLocator } = require('./util');
const { startSharedNotes, getNotesLocator, getShowMoreButtonLocator, getExportButtonLocator, getExportPlainTextLocator, getMoveToWhiteboardLocator, getSharedNotesUserWithoutPermission } = require('./util');
const { expect } = require('@playwright/test');
const { ELEMENT_WAIT_TIME } = require('../core/constants');
const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_EXTRA_LONG_TIME } = require('../core/constants');
const { sleep } = require('../core/helpers');
class SharedNotes extends Page {
constructor(browser, page) {
super(browser, page);
class SharedNotes extends MultiUsers {
constructor(browser, context) {
super(browser, context);
}
async openSharedNotes() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this);
await startSharedNotes(this.modPage);
}
async editMessage(notesLocator) {
await this.down('Shift');
await this.modPage.down('Shift');
let i = 7;
while(i > 0) {
await this.press('ArrowLeft');
await this.modPage.press('ArrowLeft');
i--;
}
await this.up('Shift');
await this.press('Backspace');
await this.modPage.up('Shift');
await this.modPage.press('Backspace');
i = 5;
while(i > 0) {
await this.press('ArrowLeft');
await this.modPage.press('ArrowLeft');
i--;
}
await this.press('!');
await this.modPage.press('!');
}
async typeInSharedNotes() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this);
const notesLocator = getNotesLocator(this);
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type(e.message);
this.editMessage(notesLocator);
const editedMessage = '!Hello';
@ -49,44 +50,44 @@ class SharedNotes extends Page {
async formatMessage(notesLocator) {
// U for '!'
await this.down('Shift');
await this.press('ArrowLeft');
await this.up('Shift');
await this.press('Control+U');
await this.press('ArrowLeft');
await this.modPage.down('Shift');
await this.modPage.press('ArrowLeft');
await this.modPage.up('Shift');
await this.modPage.press('Control+U');
await this.modPage.press('ArrowLeft');
// B for 'World'
await this.down('Shift');
await this.modPage.down('Shift');
let i = 5;
while(i > 0) {
await this.press('ArrowLeft');
await this.modPage.press('ArrowLeft');
i--;
}
await this.up('Shift');
await this.press('Control+B');
await this.press('ArrowLeft');
await this.modPage.up('Shift');
await this.modPage.press('Control+B');
await this.modPage.press('ArrowLeft');
await this.press('ArrowLeft');
await this.modPage.press('ArrowLeft');
// I for 'Hello'
await this.down('Shift');
await this.modPage.down('Shift');
i = 5;
while(i > 0) {
await this.press('ArrowLeft');
await this.modPage.press('ArrowLeft');
i--;
}
await this.up('Shift');
await this.press('Control+I');
await this.press('ArrowLeft');
await this.modPage.up('Shift');
await this.modPage.press('Control+I');
await this.modPage.press('ArrowLeft');
}
async formatTextInSharedNotes() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this);
const notesLocator = getNotesLocator(this);
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type(e.message);
this.formatMessage(notesLocator);
await this.formatMessage(notesLocator);
const html = await notesLocator.innerHTML();
const uText = '<u>!</u>';
@ -96,27 +97,96 @@ class SharedNotes extends Page {
await expect(html.includes(bText)).toBeTruthy();
const iText = '<i>Hello</i>'
await expect(html.includes(bText)).toBeTruthy();
await expect(html.includes(iText)).toBeTruthy();
}
async exportSharedNotes(testInfo) {
async exportSharedNotes(page) {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this);
const notesLocator = getNotesLocator(this);
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type(e.message);
const showMoreButtonLocator = getShowMoreButtonLocator(this);
const showMoreButtonLocator = getShowMoreButtonLocator(this.modPage);
await showMoreButtonLocator.click();
const exportButtonLocator = getExportButtonLocator(this);
const exportButtonLocator = getExportButtonLocator(this.modPage);
await exportButtonLocator.click();
const exportPlainTextLocator = getExportPlainTextLocator(this);
this.page.waitForEvent('download');
const exportPlainTextLocator = getExportPlainTextLocator(this.modPage);
page.waitForEvent('download');
await exportPlainTextLocator.click();
await sleep(500);
}
async convertNotesToWhiteboard() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type('test');
await sleep(1000);
await this.modPage.waitAndClick(e.notesOptions);
await this.modPage.waitAndClick(e.sendNotesToWhiteboard);
await this.modPage.hasText(e.currentSlideText, /test/, 20000);
await this.userPage.hasText(e.currentSlideText, /test/);
}
async editSharedNotesWithMoreThanOneUSer() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type(e.message);
await startSharedNotes(this.userPage);
const notesLocatorUser = getNotesLocator(this.userPage);
await notesLocatorUser.press('Delete');
await notesLocatorUser.type('J');
const editedMessage = 'Jello World!';
await expect(notesLocator).toContainText(editedMessage, { timeout : ELEMENT_WAIT_TIME });
await expect(notesLocatorUser).toContainText(editedMessage, { timeout : ELEMENT_WAIT_TIME });
}
async seeNotesWithoutEditPermission() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this.modPage);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type('Hello');
await startSharedNotes(this.userPage);
await this.modPage.waitAndClick(e.manageUsers);
await this.modPage.waitAndClick(e.lockViewersButton);
await this.modPage.waitAndClickElement(e.lockEditSharedNotes);
await this.modPage.waitAndClick(e.applyLockSettings);
const notesLocatorUser = getSharedNotesUserWithoutPermission(this.userPage);
await expect(notesLocatorUser).toContainText(/Hello/, { timeout : 20000 });
await this.userPage.wasRemoved(e.etherpadFrame);
}
async pinNotesOntoWhiteboard() {
const { sharedNotesEnabled } = getSettings();
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
await startSharedNotes(this.modPage);
await this.modPage.waitAndClick(e.notesOptions);
await this.modPage.waitAndClick(e.pinNotes);
await this.modPage.hasElement(e.unpinNotes);
const notesLocator = getNotesLocator(this.modPage);
await notesLocator.type('Hello');
const notesLocatorUser = getNotesLocator(this.userPage1);
await expect(notesLocator).toContainText(/Hello/, { timeout : 20000 });
await expect(notesLocatorUser).toContainText(/Hello/);
}
}
exports.SharedNotes = SharedNotes;
exports.SharedNotes = SharedNotes;

View File

@ -1,28 +1,49 @@
const { test } = require('@playwright/test');
const { SharedNotes } = require('./sharednotes');
const { SharedNotes, SharedNotesMultiUsers } = require('./sharednotes');
test.describe.parallel('Shared Notes', () => {
test('Open Shared notes @ci', async ({ browser, page }) => {
const sharedNotes = new SharedNotes(browser, page);
await sharedNotes.init(true, true);
test('Open Shared notes @ci', async ({ browser, page, context }) => {
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initModPage(page);
await sharedNotes.openSharedNotes();
});
test('Type in shared notes', async ({ browser, page }) => {
test('Type in shared notes', async ({ browser, page, context }) => {
// https://docs.bigbluebutton.org/2.5/release-tests.html#using-shared-notes-panel
const sharedNotes = new SharedNotes(browser, page);
await sharedNotes.init(true, true);
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initModPage(page);
await sharedNotes.typeInSharedNotes();
});
test('Formate text in shared notes', async ({ browser, page }) => {
test('Formate text in shared notes', async ({ browser, page, context }) => {
// https://docs.bigbluebutton.org/2.5/release-tests.html#using-shared-notes-formatting-tools
const sharedNotes = new SharedNotes(browser, page);
await sharedNotes.init(true, true);
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initModPage(page);
await sharedNotes.formatTextInSharedNotes();
});
test('Export shared notes', async ({ browser, page }, testInfo) => {
test('Export shared notes', async ({ browser, page, context }, testInfo) => {
// https://docs.bigbluebutton.org/2.5/release-tests.html#exporting-shared-notes
const sharedNotes = new SharedNotes(browser, page);
await sharedNotes.init(true, true);
await sharedNotes.exportSharedNotes(testInfo);
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initModPage(page);
await sharedNotes.exportSharedNotes(page);
});
test('Convert notes to whiteboard', async ({ browser, page, context }) => {
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initPages(page);
await sharedNotes.convertNotesToWhiteboard();
});
test('Multi users edit', async ({ browser, page, context }) => {
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initPages(page);
await sharedNotes.editSharedNotesWithMoreThanOneUSer();
});
test('See notes without edit permission', async ({ browser, page, context }) => {
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initPages(page);
await sharedNotes.seeNotesWithoutEditPermission();
});
test('Pin notes onto whiteboard', async ({ browser, page, context }) => {
const sharedNotes = new SharedNotes(browser, context);
await sharedNotes.initModPage(page);
await sharedNotes.initUserPage1();
await sharedNotes.pinNotesOntoWhiteboard();
});
});

View File

@ -27,8 +27,19 @@ function getExportPlainTextLocator(test) {
return test.page.frameLocator(e.etherpadFrame).locator(e.exportPlainButton);
}
function getMoveToWhiteboardLocator(test) {
return test.page.locator(e.sendNotesToWhiteboard);
}
function getSharedNotesUserWithoutPermission(test) {
return test.page.frameLocator(e.sharedNotesViewingMode)
.locator('body');
}
exports.startSharedNotes = startSharedNotes;
exports.getNotesLocator = getNotesLocator;
exports.getShowMoreButtonLocator = getShowMoreButtonLocator;
exports.getExportButtonLocator = getExportButtonLocator;
exports.getExportPlainTextLocator = getExportPlainTextLocator;
exports.getMoveToWhiteboardLocator = getMoveToWhiteboardLocator;
exports.getSharedNotesUserWithoutPermission = getSharedNotesUserWithoutPermission;

View File

@ -1,4 +1,5 @@
const { expect, default: test } = require('@playwright/test');
const playwright = require("playwright");
const Page = require('../core/page');
const e = require('../core/elements');
const { waitAndClearDefaultPresentationNotification } = require('../notifications/util');
@ -56,6 +57,18 @@ class MultiUsers {
await this.userPage.init(false, shouldCloseAudioModal, options);
}
async initUserPage1(shouldCloseAudioModal = true, { fullName = 'Attendee', useModMeetingId = true, ...restOptions } = {}) {
const options = {
...restOptions,
fullName,
meetingId: (useModMeetingId) ? this.modPage.meetingId : undefined,
};
const page = await (await playwright.chromium.launch()).newPage();
this.userPage1 = new Page(this.browser, page);
await this.userPage1.init(false, shouldCloseAudioModal, options);
}
async initUserPage2(shouldCloseAudioModal = true, context = this.context, { fullName = 'Attendee2', useModMeetingId = true, ...restOptions } = {}) {
const options = {
...restOptions,