2022-03-29 21:53:07 +08:00
|
|
|
const { default: test } = require('@playwright/test');
|
2022-11-08 00:18:52 +08:00
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
2022-03-29 21:53:07 +08:00
|
|
|
const { getSettings } = require('../core/settings');
|
2022-07-21 03:44:09 +08:00
|
|
|
const e = require('../core/elements');
|
2023-02-16 14:52:27 +08:00
|
|
|
const { startSharedNotes, getNotesLocator, getShowMoreButtonLocator, getExportButtonLocator, getExportPlainTextLocator, getSharedNotesUserWithoutPermission, getExportHTMLLocator, getExportEtherpadLocator } = require('./util');
|
2022-07-21 03:44:09 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
2023-02-14 21:59:46 +08:00
|
|
|
const { ELEMENT_WAIT_TIME } = require('../core/constants');
|
2022-07-21 03:44:09 +08:00
|
|
|
const { sleep } = require('../core/helpers');
|
2023-02-10 02:10:50 +08:00
|
|
|
const { readFileSync } = require('fs');
|
|
|
|
const { checkTextContent } = require('../core/util');
|
|
|
|
const { domainToASCII } = require('url');
|
2021-11-30 02:39:52 +08:00
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
class SharedNotes extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
2021-11-30 02:39:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async openSharedNotes() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { sharedNotesEnabled } = getSettings();
|
|
|
|
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
|
2022-11-08 00:18:52 +08:00
|
|
|
await startSharedNotes(this.modPage);
|
2023-02-14 21:59:46 +08:00
|
|
|
const sharedNotesContent = await getNotesLocator(this.modPage);
|
|
|
|
await expect(sharedNotesContent).toBeEditable({ timeout: ELEMENT_WAIT_TIME });
|
2021-11-30 02:39:52 +08:00
|
|
|
}
|
2022-07-21 03:44:09 +08:00
|
|
|
|
2023-02-14 21:59:46 +08:00
|
|
|
async editMessage() {
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.down('Shift');
|
2022-07-21 03:44:09 +08:00
|
|
|
let i = 7;
|
2023-02-14 21:59:46 +08:00
|
|
|
while (i > 0) {
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
i--;
|
|
|
|
}
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.up('Shift');
|
|
|
|
await this.modPage.press('Backspace');
|
2022-07-21 03:44:09 +08:00
|
|
|
i = 5;
|
2023-02-14 21:59:46 +08:00
|
|
|
while (i > 0) {
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
i--;
|
|
|
|
}
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('!');
|
2022-07-21 03:44:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async typeInSharedNotes() {
|
|
|
|
const { sharedNotesEnabled } = getSettings();
|
|
|
|
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
|
2022-11-08 00:18:52 +08:00
|
|
|
await startSharedNotes(this.modPage);
|
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
2022-07-21 03:44:09 +08:00
|
|
|
await notesLocator.type(e.message);
|
2023-02-14 21:59:46 +08:00
|
|
|
await this.editMessage(notesLocator);
|
2022-07-21 03:44:09 +08:00
|
|
|
const editedMessage = '!Hello';
|
2023-02-14 21:59:46 +08:00
|
|
|
await expect(notesLocator).toContainText(editedMessage, { timeout: ELEMENT_WAIT_TIME });
|
2022-07-21 03:44:09 +08:00
|
|
|
}
|
|
|
|
|
2023-02-14 21:59:46 +08:00
|
|
|
async formatMessage() {
|
2022-07-21 03:44:09 +08:00
|
|
|
// U for '!'
|
2022-11-08 00:18:52 +08:00
|
|
|
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');
|
2022-07-21 03:44:09 +08:00
|
|
|
|
|
|
|
// B for 'World'
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.down('Shift');
|
2022-07-21 03:44:09 +08:00
|
|
|
let i = 5;
|
2023-02-14 21:59:46 +08:00
|
|
|
while (i > 0) {
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
i--;
|
|
|
|
}
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.up('Shift');
|
|
|
|
await this.modPage.press('Control+B');
|
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
|
|
|
|
// I for 'Hello'
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.down('Shift');
|
2022-07-21 03:44:09 +08:00
|
|
|
i = 5;
|
2023-02-14 21:59:46 +08:00
|
|
|
while (i > 0) {
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
i--;
|
|
|
|
}
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.up('Shift');
|
|
|
|
await this.modPage.press('Control+I');
|
|
|
|
await this.modPage.press('ArrowLeft');
|
2022-07-21 03:44:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async formatTextInSharedNotes() {
|
|
|
|
const { sharedNotesEnabled } = getSettings();
|
|
|
|
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
|
2022-11-08 00:18:52 +08:00
|
|
|
await startSharedNotes(this.modPage);
|
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
2022-07-21 03:44:09 +08:00
|
|
|
await notesLocator.type(e.message);
|
2023-02-10 02:10:50 +08:00
|
|
|
|
|
|
|
await notesLocator.press('Control+Z');
|
|
|
|
await expect(notesLocator).toBeEmpty();
|
|
|
|
await notesLocator.press('Control+Y');
|
|
|
|
await expect(notesLocator).toContainText(e.message);
|
|
|
|
|
2022-11-17 02:18:03 +08:00
|
|
|
await this.formatMessage(notesLocator);
|
2022-07-21 03:44:09 +08:00
|
|
|
const html = await notesLocator.innerHTML();
|
|
|
|
|
|
|
|
const uText = '<u>!</u>';
|
|
|
|
await expect(html.includes(uText)).toBeTruthy();
|
|
|
|
|
|
|
|
const bText = '<b>World</b>';
|
|
|
|
await expect(html.includes(bText)).toBeTruthy();
|
|
|
|
|
|
|
|
const iText = '<i>Hello</i>'
|
2022-11-17 02:18:03 +08:00
|
|
|
await expect(html.includes(iText)).toBeTruthy();
|
2022-07-21 03:44:09 +08:00
|
|
|
}
|
|
|
|
|
2023-02-16 02:41:21 +08:00
|
|
|
async exportSharedNotes(testInfo) {
|
2022-07-21 03:44:09 +08:00
|
|
|
const { sharedNotesEnabled } = getSettings();
|
|
|
|
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
|
2022-11-08 00:18:52 +08:00
|
|
|
await startSharedNotes(this.modPage);
|
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
2022-07-21 03:44:09 +08:00
|
|
|
await notesLocator.type(e.message);
|
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
const showMoreButtonLocator = getShowMoreButtonLocator(this.modPage);
|
2022-07-21 03:44:09 +08:00
|
|
|
await showMoreButtonLocator.click();
|
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
const exportButtonLocator = getExportButtonLocator(this.modPage);
|
2022-07-21 03:44:09 +08:00
|
|
|
await exportButtonLocator.click();
|
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
const exportPlainTextLocator = getExportPlainTextLocator(this.modPage);
|
2023-02-10 02:10:50 +08:00
|
|
|
const exportHtmlLocator = getExportHTMLLocator(this.modPage);
|
|
|
|
const exportEtherpadLocator = getExportEtherpadLocator(this.modPage);
|
|
|
|
|
2023-02-13 22:39:04 +08:00
|
|
|
//.txt checks
|
2023-02-16 02:41:21 +08:00
|
|
|
const txt = await this.modPage.handleDownload(exportPlainTextLocator, testInfo);
|
|
|
|
const txtFileExtension = (txt.download._suggestedFilename).split('.').pop();
|
2023-02-10 21:50:48 +08:00
|
|
|
await checkTextContent(txtFileExtension, 'txt');
|
2023-02-16 02:41:21 +08:00
|
|
|
await checkTextContent(txt.content, e.message);
|
2023-02-10 02:10:50 +08:00
|
|
|
|
2023-02-13 22:39:04 +08:00
|
|
|
//.html checks
|
2023-02-16 02:41:21 +08:00
|
|
|
const html = await this.modPage.handleDownload(exportHtmlLocator, testInfo);
|
|
|
|
const htmlFileExtension = (html.download._suggestedFilename).split('.').pop();
|
2023-02-10 21:50:48 +08:00
|
|
|
await checkTextContent(htmlFileExtension, 'html');
|
2023-02-16 02:41:21 +08:00
|
|
|
await checkTextContent(html.content, e.message);
|
2023-02-10 02:10:50 +08:00
|
|
|
|
2023-02-13 22:39:04 +08:00
|
|
|
//.etherpad checks
|
2023-02-16 02:41:21 +08:00
|
|
|
const etherpad = await this.modPage.handleDownload(exportEtherpadLocator, testInfo);
|
|
|
|
const etherpadFileExtension = (etherpad.download._suggestedFilename).split('.').pop();
|
2023-02-10 21:50:48 +08:00
|
|
|
await checkTextContent(etherpadFileExtension, 'etherpad');
|
2023-02-16 02:41:21 +08:00
|
|
|
await checkTextContent(etherpad.content, e.message);
|
2022-07-21 03:44:09 +08:00
|
|
|
}
|
2022-11-08 00:18:52 +08:00
|
|
|
|
2022-11-17 02:18:03 +08:00
|
|
|
async convertNotesToWhiteboard() {
|
2022-11-08 00:18:52 +08:00
|
|
|
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);
|
|
|
|
|
2022-11-12 02:35:14 +08:00
|
|
|
await this.modPage.waitAndClick(e.notesOptions);
|
2022-11-08 00:18:52 +08:00
|
|
|
await this.modPage.waitAndClick(e.sendNotesToWhiteboard);
|
2023-02-14 21:59:46 +08:00
|
|
|
|
2022-11-08 00:18:52 +08:00
|
|
|
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!';
|
2023-02-14 21:59:46 +08:00
|
|
|
await expect(notesLocator).toContainText(editedMessage, { timeout: ELEMENT_WAIT_TIME });
|
|
|
|
await expect(notesLocatorUser).toContainText(editedMessage, { timeout: ELEMENT_WAIT_TIME });
|
2022-11-08 00:18:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async seeNotesWithoutEditPermission() {
|
|
|
|
const { sharedNotesEnabled } = getSettings();
|
|
|
|
test.fail(!sharedNotesEnabled, 'Shared notes is disabled');
|
|
|
|
|
|
|
|
await startSharedNotes(this.modPage);
|
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
2022-11-17 02:18:03 +08:00
|
|
|
await notesLocator.type('Hello');
|
2022-11-08 00:18:52 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-02-14 21:59:46 +08:00
|
|
|
const notesLocatorUser = getSharedNotesUserWithoutPermission(this.userPage);
|
|
|
|
await expect(notesLocatorUser).toContainText(/Hello/, { timeout: 20000 });
|
|
|
|
await this.userPage.wasRemoved(e.etherpadFrame);
|
2022-11-17 02:18:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2022-11-22 21:44:28 +08:00
|
|
|
|
2022-11-17 02:18:03 +08:00
|
|
|
const notesLocator = getNotesLocator(this.modPage);
|
|
|
|
await notesLocator.type('Hello');
|
2022-11-22 21:44:28 +08:00
|
|
|
const notesLocatorUser = getNotesLocator(this.userPage1);
|
2022-11-17 02:18:03 +08:00
|
|
|
|
2023-02-14 21:59:46 +08:00
|
|
|
await expect(notesLocator).toContainText(/Hello/, { timeout: 20000 });
|
2022-11-19 00:38:46 +08:00
|
|
|
await expect(notesLocatorUser).toContainText(/Hello/);
|
2022-11-08 00:18:52 +08:00
|
|
|
}
|
2021-11-30 02:39:52 +08:00
|
|
|
}
|
|
|
|
|
2023-04-04 04:21:24 +08:00
|
|
|
exports.SharedNotes = SharedNotes;
|