From 34369b8897aece03a972f230edc9e962937b756a Mon Sep 17 00:00:00 2001 From: Anton Barboza Date: Wed, 8 Sep 2021 14:18:01 -0300 Subject: [PATCH] add remove all presentation test --- .../presentation-placeholder/component.jsx | 1 + .../presentation-uploader/component.jsx | 1 + .../puppeteer/presentation.obj.js | 28 +++++++++++++++++-- .../puppeteer/presentation/elements.js | 5 +++- .../puppeteer/presentation/presentation.js | 25 +++++++++++++++-- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-placeholder/component.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-placeholder/component.jsx index a5843a3f03..3d8f1595ab 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-placeholder/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-placeholder/component.jsx @@ -23,6 +23,7 @@ const PresentationPlaceholder = ({
setPresentationRef(ref)} className={styles.presentationPlaceholder} + data-test="presentationPlaceholder" style={{ top, left, diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx index 8cb099a0e4..a7a6d0b4db 100755 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx @@ -808,6 +808,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" diff --git a/bigbluebutton-tests/puppeteer/presentation.obj.js b/bigbluebutton-tests/puppeteer/presentation.obj.js index 903306c6a2..6442457e50 100644 --- a/bigbluebutton-tests/puppeteer/presentation.obj.js +++ b/bigbluebutton-tests/puppeteer/presentation.obj.js @@ -21,7 +21,7 @@ const presentationTest = () => { await test.modPage.startRecording(testName); response = await test.skipSlide(); await test.modPage.stopRecording(testName); - screenshot = await test.modPage.screenshot(); + screenshot = await test.modPage.page.screenshot(); await test.modPage.logger('end of ', testName); } catch (err) { await test.modPage.logger(err); @@ -43,7 +43,7 @@ const presentationTest = () => { await test.modPage.startRecording(testName); response = await test.uploadPresentation(testName); await test.modPage.stopRecording(); - screenshot = await test.modPage.screenshot(); + screenshot = await test.modPage.page.screenshot(); await test.modPage.logger('end of ', testName); } catch (err) { await test.modPage.logger(err); @@ -65,7 +65,29 @@ const presentationTest = () => { await test.modPage.startRecording(testName); response = await test.allowAndDisallowDownload(testName); await test.modPage.stopRecording(); - screenshot = await test.modPage.screenshot(); + 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.only('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); diff --git a/bigbluebutton-tests/puppeteer/presentation/elements.js b/bigbluebutton-tests/puppeteer/presentation/elements.js index 8491b98933..06b9a1ab00 100644 --- a/bigbluebutton-tests/puppeteer/presentation/elements.js +++ b/bigbluebutton-tests/puppeteer/presentation/elements.js @@ -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"]'; diff --git a/bigbluebutton-tests/puppeteer/presentation/presentation.js b/bigbluebutton-tests/puppeteer/presentation/presentation.js index ca3efac688..8af3f42d21 100644 --- a/bigbluebutton-tests/puppeteer/presentation/presentation.js +++ b/bigbluebutton-tests/puppeteer/presentation/presentation.js @@ -6,7 +6,7 @@ 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 } = require('../core/util'); +const { checkElement, checkElementTextIncludes, checkElementText } = require('../core/util'); class Presentation { constructor() { @@ -136,7 +136,28 @@ class Presentation { return hasPresentationDownloadBtnAfterAllow && !hasPresentationDownloadBtnAfterDisallow; } catch (err) { - this.modPage.logger(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; } }