Merge pull request #13082 from antonbsa/test-allow-presentation-download
test: Presentation - adds test to allow and disallow presentation download and test to remove all presentations
This commit is contained in:
commit
d175fcf95d
@ -761,6 +761,7 @@ class Presentation extends PureComponent {
|
||||
<span className={styles.toastDownload}>
|
||||
<div className={toastStyles.separator} />
|
||||
<a
|
||||
data-test="toastDownload"
|
||||
className={styles.downloadBtn}
|
||||
aria-label={`${intl.formatMessage(intlMessages.downloadLabel)} ${currentPresentation.name}`}
|
||||
href={downloadPresentationUri}
|
||||
|
@ -37,6 +37,7 @@ const DownloadPresentationButton = ({
|
||||
return (
|
||||
<div className={wrapperClassName}>
|
||||
<Button
|
||||
data-test="presentationDownload"
|
||||
color="default"
|
||||
icon="template_download"
|
||||
size="sm"
|
||||
|
@ -23,6 +23,7 @@ const PresentationPlaceholder = ({
|
||||
<div
|
||||
ref={(ref) => setPresentationRef(ref)}
|
||||
className={styles.presentationPlaceholder}
|
||||
data-test="presentationPlaceholder"
|
||||
style={{
|
||||
top,
|
||||
left,
|
||||
|
@ -800,6 +800,7 @@ class PresentationUploader extends Component {
|
||||
disabled={disableActions}
|
||||
className={isDownloadableStyle}
|
||||
label={formattedDownloadableLabel}
|
||||
data-test={item.isDownloadable ? 'disallowPresentationDownload' : 'allowPresentationDownload'}
|
||||
aria-label={formattedDownloadableAriaLabel}
|
||||
hideLabel
|
||||
size="sm"
|
||||
@ -818,6 +819,7 @@ class PresentationUploader extends Component {
|
||||
disabled={disableActions}
|
||||
className={cx(styles.itemAction, styles.itemActionRemove)}
|
||||
label={intl.formatMessage(intlMessages.removePresentation)}
|
||||
data-test="removePresentation"
|
||||
aria-label={`${intl.formatMessage(intlMessages.removePresentation)} ${item.filename}`}
|
||||
size="sm"
|
||||
icon="delete"
|
||||
@ -1006,6 +1008,7 @@ class PresentationUploader extends Component {
|
||||
/>
|
||||
<Button
|
||||
className={styles.confirm}
|
||||
data-test="confirmManagePresentation"
|
||||
color="primary"
|
||||
onClick={() => this.handleConfirm(hasNewUpload)}
|
||||
disabled={disableActions}
|
||||
|
@ -30,3 +30,9 @@ exports.rating = 'div[data-test="rating"]';
|
||||
exports.whiteboard = 'svg[data-test="whiteboard"]';
|
||||
exports.pollMenuButton = 'div[data-test="pollMenuButton"]';
|
||||
exports.unauthorized = 'h1[data-test="unauthorized"]';
|
||||
|
||||
exports.presentationDownloadBtn = 'button[data-test="presentationDownload"]';
|
||||
exports.toastDownload = 'a[data-test="toastDownload"]';
|
||||
exports.confirmManagePresentation = 'button[data-test="confirmManagePresentation"]';
|
||||
exports.allowPresentationDownload = 'button[data-test="allowPresentationDownload"]';
|
||||
exports.disallowPresentationDownload = 'button[data-test="disallowPresentationDownload"]';
|
||||
|
@ -1,6 +1,5 @@
|
||||
const Page = require('./core/page');
|
||||
const Slide = require('./presentation/slide');
|
||||
const Upload = require('./presentation/upload');
|
||||
const Presentation = require('./presentation/presentation');
|
||||
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
||||
const { MAX_PRESENTATION_TEST_TIMEOUT } = require('./core/constants'); // core constants (Timeouts vars imported)
|
||||
|
||||
@ -12,46 +11,88 @@ const presentationTest = () => {
|
||||
});
|
||||
|
||||
test('Skip slide', async () => {
|
||||
const test = new Slide();
|
||||
const test = new Presentation();
|
||||
let response;
|
||||
let screenshot;
|
||||
try {
|
||||
const testName = 'skipSlide';
|
||||
await test.logger('begin of ', testName);
|
||||
await test.init(Page.getArgs(), undefined, undefined, undefined, testName);
|
||||
await test.startRecording(testName);
|
||||
await test.closeAudioModal();
|
||||
response = await test.test();
|
||||
await test.stopRecording(testName);
|
||||
screenshot = await test.page.screenshot();
|
||||
await test.logger('end of ', testName);
|
||||
await test.modPage.logger('begin of ', testName);
|
||||
await test.initModPage(testName);
|
||||
await test.modPage.startRecording(testName);
|
||||
response = await test.skipSlide();
|
||||
await test.modPage.stopRecording(testName);
|
||||
screenshot = await test.modPage.page.screenshot();
|
||||
await test.modPage.logger('end of ', testName);
|
||||
} catch (err) {
|
||||
await test.logger(err);
|
||||
await test.modPage.logger(err);
|
||||
} finally {
|
||||
await test.close();
|
||||
await test.closePages();
|
||||
}
|
||||
expect(response).toBe(true);
|
||||
await Page.checkRegression(0.81, screenshot);
|
||||
});
|
||||
|
||||
test('Upload presentation', async () => {
|
||||
const test = new Upload();
|
||||
const test = new Presentation();
|
||||
let response;
|
||||
let screenshot;
|
||||
try {
|
||||
const testName = 'uploadPresentation';
|
||||
await test.logger('begin of ', testName);
|
||||
await test.init(Page.getArgs(), undefined, undefined, undefined, testName);
|
||||
await test.startRecording(testName);
|
||||
await test.closeAudioModal();
|
||||
response = await test.test(testName);
|
||||
await test.stopRecording();
|
||||
screenshot = await test.page.screenshot();
|
||||
await test.logger('end of ', testName);
|
||||
await test.modPage.logger('begin of ', testName);
|
||||
await test.initModPage(testName);
|
||||
await test.modPage.startRecording(testName);
|
||||
response = await test.uploadPresentation(testName);
|
||||
await test.modPage.stopRecording();
|
||||
screenshot = await test.modPage.page.screenshot();
|
||||
await test.modPage.logger('end of ', testName);
|
||||
} catch (err) {
|
||||
await test.logger(err);
|
||||
await test.modPage.logger(err);
|
||||
} finally {
|
||||
await test.close();
|
||||
await test.closePages();
|
||||
}
|
||||
expect(response).toBe(true);
|
||||
await Page.checkRegression(24.62, screenshot);
|
||||
});
|
||||
|
||||
test('Allow and disallow presentation download', async () => {
|
||||
const test = new Presentation();
|
||||
let response;
|
||||
let screenshot;
|
||||
try {
|
||||
const testName = 'allowAndDisallowPresentationDownload';
|
||||
await test.modPage.logger('begin of ', testName);
|
||||
await test.initPages(testName);
|
||||
await test.modPage.startRecording(testName);
|
||||
response = await test.allowAndDisallowDownload(testName);
|
||||
await test.modPage.stopRecording();
|
||||
screenshot = await test.modPage.page.screenshot();
|
||||
await test.modPage.logger('end of ', testName);
|
||||
} catch (e) {
|
||||
await test.modPage.logger(e);
|
||||
} finally {
|
||||
await test.closePages();
|
||||
}
|
||||
expect(response).toBe(true);
|
||||
await Page.checkRegression(24.62, screenshot);
|
||||
});
|
||||
|
||||
test('Remove all presentation', async () => {
|
||||
const test = new Presentation();
|
||||
let response;
|
||||
let screenshot;
|
||||
try {
|
||||
const testName = 'removeAllPresentation';
|
||||
await test.modPage.logger('begin of ', testName);
|
||||
await test.initPages(testName);
|
||||
await test.modPage.startRecording(testName);
|
||||
response = await test.removeAllPresentation(testName);
|
||||
await test.modPage.stopRecording();
|
||||
screenshot = await test.modPage.page.screenshot();
|
||||
await test.modPage.logger('end of ', testName);
|
||||
} catch (e) {
|
||||
await test.modPage.logger(e);
|
||||
} finally {
|
||||
await test.closePages();
|
||||
}
|
||||
expect(response).toBe(true);
|
||||
await Page.checkRegression(24.62, screenshot);
|
||||
|
@ -4,5 +4,8 @@ exports.prevSlide = '[data-test="prevSlide"]';
|
||||
exports.fileUpload = 'input[type="file"]';
|
||||
exports.upload = 'button[aria-label="Upload"]';
|
||||
exports.cancel = 'button[aria-label="Cancel]';
|
||||
exports.uploadPresentation = '[data-test="uploadPresentation"]';
|
||||
exports.uploadPresentation = 'li[data-test="uploadPresentation"]';
|
||||
exports.removePresentation = 'button[data-test="removePresentation"]';
|
||||
exports.presentationPlaceholder = 'div[data-test="presentationPlaceholder"]';
|
||||
exports.presentationPlaceholderLabel = 'Waiting for a presentation to be uploaded';
|
||||
exports.skipSlide = '[data-test="skipSlide"]';
|
||||
|
166
bigbluebutton-tests/puppeteer/presentation/presentation.js
Normal file
166
bigbluebutton-tests/puppeteer/presentation/presentation.js
Normal file
@ -0,0 +1,166 @@
|
||||
const Page = require('../core/page');
|
||||
const e = require('./elements');
|
||||
const ne = require('../notifications/elements');
|
||||
const ce = require('../core/elements');
|
||||
const we = require('../whiteboard/elements');
|
||||
const params = require('../params');
|
||||
const util = require('./util');
|
||||
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_TIME } = require('../core/constants');
|
||||
const { checkElement, checkElementTextIncludes, checkElementText } = require('../core/util');
|
||||
|
||||
class Presentation {
|
||||
constructor() {
|
||||
this.modPage = new Page();
|
||||
this.userPage = new Page();
|
||||
}
|
||||
|
||||
async initPages(testName) {
|
||||
await this.initModPage(testName);
|
||||
await this.initUserPage(testName);
|
||||
}
|
||||
|
||||
async initModPage(testName) {
|
||||
await this.modPage.init(Page.getArgs(), undefined, { ...params, fullName: 'Mod' }, undefined, testName);
|
||||
await this.modPage.closeAudioModal();
|
||||
}
|
||||
|
||||
async initUserPage(testName) {
|
||||
await this.userPage.init(Page.getArgs(), this.modPage.meetingId, { ...params, fullName: 'Attendee', moderatorPW: '' }, undefined, testName);
|
||||
await this.userPage.closeAudioModal();
|
||||
}
|
||||
|
||||
async closePages() {
|
||||
if (this.modPage.page) await this.modPage.close();
|
||||
if (this.userPage.page) await this.userPage.close();
|
||||
}
|
||||
|
||||
async skipSlide() {
|
||||
try {
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.modPage.waitForSelector(e.presentationToolbarWrapper, ELEMENT_WAIT_TIME);
|
||||
|
||||
const svg0 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/1');
|
||||
|
||||
await this.modPage.waitForSelector(e.nextSlide, ELEMENT_WAIT_TIME);
|
||||
await this.modPage.click(e.nextSlide, true);
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
||||
await this.modPage.page.waitForTimeout(1000);
|
||||
|
||||
const svg1 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/2');
|
||||
|
||||
await this.modPage.waitForSelector(e.prevSlide, ELEMENT_WAIT_TIME);
|
||||
await this.modPage.click(e.prevSlide, true);
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
||||
await this.modPage.page.waitForTimeout(1000);
|
||||
|
||||
const svg2 = await this.modPage.page.evaluate(util.checkSvgIndex, '/svg/1');
|
||||
|
||||
return svg0 === true && svg1 === true && svg2 === true;
|
||||
} catch (err) {
|
||||
await this.modPage.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async uploadPresentation(testName) {
|
||||
try {
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.modPage.waitForSelector(e.skipSlide, ELEMENT_WAIT_TIME);
|
||||
|
||||
const slides0 = await this.modPage.page.evaluate(util.getSvgOuterHtml);
|
||||
|
||||
await this.modPage.click(ce.actions, true);
|
||||
await this.modPage.click(e.uploadPresentation, true);
|
||||
|
||||
await this.modPage.screenshot(`${testName}`, `01-before-presentation-upload-[${testName}]`);
|
||||
|
||||
await this.modPage.waitForSelector(e.fileUpload, ELEMENT_WAIT_TIME);
|
||||
const fileUpload = await this.modPage.page.$(e.fileUpload);
|
||||
await fileUpload.uploadFile(`${__dirname}/upload-test.png`);
|
||||
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'To be uploaded ...'
|
||||
);
|
||||
await this.modPage.page.waitForSelector(e.upload, ELEMENT_WAIT_TIME);
|
||||
|
||||
await this.modPage.page.click(e.upload, true);
|
||||
await this.modPage.logger('\nWaiting for the new presentation to upload...');
|
||||
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'Converting file'
|
||||
);
|
||||
await this.modPage.logger('\nPresentation uploaded!');
|
||||
await this.modPage.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'Current presentation'
|
||||
);
|
||||
await this.modPage.screenshot(`${testName}`, `02-after-presentation-upload-[${testName}]`);
|
||||
|
||||
const slides1 = await this.modPage.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
|
||||
|
||||
await this.modPage.logger('\nSlides before presentation upload:');
|
||||
await this.modPage.logger(slides0);
|
||||
await this.modPage.logger('\nSlides after presentation upload:');
|
||||
await this.modPage.logger(slides1);
|
||||
|
||||
return slides0 !== slides1;
|
||||
} catch (err) {
|
||||
await this.modPage.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async allowAndDisallowDownload(testName) {
|
||||
try {
|
||||
// allow the presentation download
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.modPage.click(ce.actions);
|
||||
await this.modPage.click(e.uploadPresentation);
|
||||
await this.modPage.screenshot(testName, `1-modPage-before-allow-download-[${this.modPage.meetingId}]`);
|
||||
await this.modPage.click(ce.allowPresentationDownload);
|
||||
await this.userPage.screenshot(testName, `2-userPage-after-allow-download-without-save-[${this.modPage.meetingId}]`);
|
||||
await this.userPage.waitForElementHandleToBeRemoved(ne.smallToastMsg);
|
||||
await this.modPage.click(ce.confirmManagePresentation);
|
||||
await this.userPage.screenshot(testName, `3-userPage-after-allow-download-and-save-[${this.modPage.meetingId}]`);
|
||||
await this.userPage.waitForSelector(ce.toastDownload);
|
||||
// check download button in presentation after ALLOW it - should be true
|
||||
const hasPresentationDownloadBtnAfterAllow = await this.userPage.page.evaluate(checkElement, ce.presentationDownloadBtn);
|
||||
|
||||
// disallow the presentation download
|
||||
await this.modPage.click(ce.actions);
|
||||
await this.modPage.click(e.uploadPresentation);
|
||||
await this.modPage.screenshot(testName, `4-modPage-before-disallow-download-[${this.modPage.meetingId}]`);
|
||||
await this.modPage.click(ce.disallowPresentationDownload);
|
||||
await this.modPage.click(ce.confirmManagePresentation);
|
||||
await this.modPage.screenshot(testName, `5-userPage-after-disallow-download-[${this.modPage.meetingId}]`);
|
||||
await this.userPage.waitForElementHandleToBeRemoved(ce.toastDownload);
|
||||
// check download button in presentation after DISALLOW it - should be false
|
||||
const hasPresentationDownloadBtnAfterDisallow = await this.userPage.page.evaluate(checkElement, ce.presentationDownloadBtn);
|
||||
|
||||
return hasPresentationDownloadBtnAfterAllow && !hasPresentationDownloadBtnAfterDisallow;
|
||||
} catch (err) {
|
||||
await this.modPage.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async removeAllPresentation(testName) {
|
||||
try {
|
||||
await this.modPage.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.modPage.click(ce.actions);
|
||||
await this.modPage.click(e.uploadPresentation);
|
||||
await this.modPage.screenshot(testName, `1-modPage-before-remove-download-[${this.modPage.meetingId}]`);
|
||||
await this.modPage.click(e.removePresentation);
|
||||
await this.modPage.click(ce.confirmManagePresentation);
|
||||
await this.modPage.waitForSelector(ce.actions, ELEMENT_WAIT_TIME);
|
||||
await this.modPage.screenshot(testName, `2-modPage-after-remove-download-[${this.modPage.meetingId}]`);
|
||||
await this.userPage.screenshot(testName, `3-userPage-after-remove-download-[${this.modPage.meetingId}]`);
|
||||
const modPagePlaceholder = await this.modPage.page.evaluate(checkElementText, e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
||||
const userPagePlaceholder = await this.userPage.page.evaluate(checkElementText, e.presentationPlaceholder, e.presentationPlaceholderLabel);
|
||||
|
||||
return modPagePlaceholder && userPagePlaceholder;
|
||||
} catch (err) {
|
||||
await this.modPage.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Presentation;
|
@ -1,41 +0,0 @@
|
||||
const Page = require('../core/page');
|
||||
const e = require('./elements');
|
||||
const we = require('../whiteboard/elements');
|
||||
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_TIME } = require('../core/constants');
|
||||
const util = require('./util');
|
||||
|
||||
class Slide extends Page {
|
||||
constructor() {
|
||||
super('presentation-slide');
|
||||
}
|
||||
|
||||
async test() {
|
||||
try {
|
||||
await this.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.waitForSelector(e.presentationToolbarWrapper, ELEMENT_WAIT_TIME);
|
||||
|
||||
const svg0 = await this.page.evaluate(util.checkSvgIndex, '/svg/1');
|
||||
|
||||
await this.waitForSelector(e.nextSlide, ELEMENT_WAIT_TIME);
|
||||
await this.click(e.nextSlide, true);
|
||||
await this.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
||||
await this.page.waitForTimeout(1000);
|
||||
|
||||
const svg1 = await this.page.evaluate(util.checkSvgIndex, '/svg/2');
|
||||
|
||||
await this.waitForSelector(e.prevSlide, ELEMENT_WAIT_TIME);
|
||||
await this.click(e.prevSlide, true);
|
||||
await this.waitForSelector(we.whiteboard, ELEMENT_WAIT_TIME);
|
||||
await this.page.waitForTimeout(1000);
|
||||
|
||||
const svg2 = await this.page.evaluate(util.checkSvgIndex, '/svg/1');
|
||||
|
||||
return svg0 === true && svg1 === true && svg2 === true;
|
||||
} catch (err) {
|
||||
await this.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Slide;
|
@ -1,60 +0,0 @@
|
||||
const Page = require('../core/page');
|
||||
const e = require('./elements');
|
||||
const we = require('../whiteboard/elements');
|
||||
const ce = require('../core/elements');
|
||||
const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
||||
const { checkElementTextIncludes } = require('../core/util');
|
||||
const util = require('./util');
|
||||
|
||||
class Upload extends Page {
|
||||
constructor() {
|
||||
super('presentation-upload');
|
||||
}
|
||||
|
||||
async test(testName) {
|
||||
try {
|
||||
await this.waitForSelector(we.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
||||
await this.waitForSelector(e.skipSlide, ELEMENT_WAIT_TIME);
|
||||
|
||||
const slides0 = await this.page.evaluate(util.getSvgOuterHtml);
|
||||
|
||||
await this.click(ce.actions, true);
|
||||
await this.click(e.uploadPresentation, true);
|
||||
|
||||
await this.screenshot(`${testName}`, `01-before-presentation-upload-[${testName}]`);
|
||||
|
||||
await this.waitForSelector(e.fileUpload, ELEMENT_WAIT_TIME);
|
||||
const fileUpload = await this.page.$(e.fileUpload);
|
||||
await fileUpload.uploadFile(`${__dirname}/upload-test.png`);
|
||||
await this.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'To be uploaded ...'
|
||||
);
|
||||
await this.page.waitForSelector(e.upload, ELEMENT_WAIT_TIME);
|
||||
|
||||
await this.page.click(e.upload, true);
|
||||
await this.logger('\nWaiting for the new presentation to upload...');
|
||||
await this.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'Converting file'
|
||||
);
|
||||
await this.logger('\nPresentation uploaded!');
|
||||
await this.page.waitForFunction(checkElementTextIncludes, {},
|
||||
'body', 'Current presentation'
|
||||
);
|
||||
await this.screenshot(`${testName}`, `02-after-presentation-upload-[${testName}]`);
|
||||
|
||||
const slides1 = await this.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
|
||||
|
||||
await this.logger('\nSlides before presentation upload:');
|
||||
await this.logger(slides0);
|
||||
await this.logger('\nSlides after presentation upload:');
|
||||
await this.logger(slides1);
|
||||
|
||||
return slides0 !== slides1;
|
||||
} catch (err) {
|
||||
await this.logger(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Upload;
|
Loading…
Reference in New Issue
Block a user