diff --git a/bigbluebutton-html5/tests/puppeteer/chat.test.js b/bigbluebutton-html5/tests/puppeteer/chat.test.js index aff15f20b22702b5d58c9c80a15884e909a5156b..cffc27a253096a67edb1fa7c04273894a65c2c28 100644 --- a/bigbluebutton-html5/tests/puppeteer/chat.test.js +++ b/bigbluebutton-html5/tests/puppeteer/chat.test.js @@ -1,33 +1,50 @@ const Page = require('./page'); const Send = require('./chat/send'); const Clear = require('./chat/clear'); +const Copy = require('./chat/copy'); -describe('Chat tests', () => { +describe('Chat', () => { - test('Tests sending a message in chat', async () => { + test('Send message', async () => { const test = new Send(); + let response; try { await test.init(Page.getArgs()); - await test.test(); - await test.close(); + response = await test.test(); } catch (e) { console.log(e); + } finally { await test.close(); - throw new Error('Test failed'); } + expect(response).toBe(true); }); - test('Tests cleaning a message in chat', async () => { + test('Clear chat', async () => { const test = new Clear(); + let response; try { await test.init(Page.getArgs()); - await test.test(); + response = await test.test(); + } catch (e) { + console.log(e); + } finally { await test.close(); + } + expect(response).toBe(true); + }); + + test('Copy chat', async () => { + const test = new Copy(); + let response; + try { + await test.init(Page.getArgs()); + response = await test.test(); } catch (e) { console.log(e); + } finally { await test.close(); - throw new Error('Test failed'); } + expect(response).toBe(true); }); }); diff --git a/bigbluebutton-html5/tests/puppeteer/chat/clear.js b/bigbluebutton-html5/tests/puppeteer/chat/clear.js index f3ee17e823f673555e96397d5eb72157cb4b760c..36174dbd5c120a850b4c45434fd26c1e6f6bc093 100644 --- a/bigbluebutton-html5/tests/puppeteer/chat/clear.js +++ b/bigbluebutton-html5/tests/puppeteer/chat/clear.js @@ -9,19 +9,27 @@ class Clear extends Page { async test() { await util.openChat(this); - const messages0 = await util.getTestElements(this); + await this.type(e.chatBox, 'Hello world!'); + await this.click(e.sendButton); + await this.screenshot('clear-chat0.png', true); + + // Must be: + // [{ "name": "User1\nXX:XX XM", "message": "Hello world!" }] + const chat0 = await util.getTestElements(this); await this.click(e.chatOptions); await this.click(e.chatClear, true); - await this.screenshot('clear-chat.png', true); + await this.screenshot('clear-chat1.png', true); + + // Must be: + // [] + const chat1 = await util.getTestElements(this); - // TODO: this must change - const messages1 = await util.getTestElements(this); + const response = + chat0[0].message == 'Hello world!' && + chat1.length == 0; - console.log('\nChat messages before cleaning:'); - console.log(JSON.stringify(messages0, null, 2)); - console.log('\nChat messages after cleaning:'); - console.log(JSON.stringify(messages1, null, 2)); + return response; } } diff --git a/bigbluebutton-html5/tests/puppeteer/chat/copy.js b/bigbluebutton-html5/tests/puppeteer/chat/copy.js new file mode 100644 index 0000000000000000000000000000000000000000..f570dd19d03e202c28b72c2b30046cd81cc6ac9f --- /dev/null +++ b/bigbluebutton-html5/tests/puppeteer/chat/copy.js @@ -0,0 +1,33 @@ +// Test: Cleaning a chat message + +const Page = require('../page'); +const helper = require('../helper'); +const e = require('./elements'); +const util = require('./util'); + +class Copy extends Page { + async test() { + await util.openChat(this); + + await this.click(e.chatOptions); + await this.click(e.chatCopy, true); + await this.click(e.chatBox); + + // Pasting in chat because I could't get puppeteer clipboard + await this.page.keyboard.down('ControlLeft'); + await this.page.keyboard.press('KeyV'); + await this.page.keyboard.up('ControlLeft'); + await this.click(e.sendButton, true); + await this.screenshot('copy-chat.png', true); + + // Must be: + // [{ "name": "User1\nXX:XX XM", "message": "[XX:XX] THE_MEETING_WELCOME_MESSAGE }] + const chat = await util.getTestElements(this); + + const response = chat.length != 0; + + return response; + } +} + +module.exports = exports = Copy; diff --git a/bigbluebutton-html5/tests/puppeteer/chat/elements.js b/bigbluebutton-html5/tests/puppeteer/chat/elements.js index 9999f9ced68f50b2f02c02f5af467403b45aee69..40546084f83a4a0edf30673a3b89599a256e17d5 100644 --- a/bigbluebutton-html5/tests/puppeteer/chat/elements.js +++ b/bigbluebutton-html5/tests/puppeteer/chat/elements.js @@ -4,3 +4,5 @@ exports.sendButton = '[aria-label="Send Message"]'; exports.chatMessages = '#chat-messages'; exports.chatOptions = '[aria-label="Chat Options"]'; exports.chatClear = 'i._imports_ui_components_dropdown_list__styles__itemIcon.icon-bbb-delete'; +exports.chatCopy = 'i._imports_ui_components_dropdown_list__styles__itemIcon.icon-bbb-copy'; +exports.chatSave = 'i._imports_ui_components_dropdown_list__styles__itemIcon.icon-bbb-save_notes'; diff --git a/bigbluebutton-html5/tests/puppeteer/chat/send.js b/bigbluebutton-html5/tests/puppeteer/chat/send.js index 2f26713eddb5112d54ed44db425fe7fbe66b329c..6f489773d267ca801c68d77d01f52f36359c41d6 100644 --- a/bigbluebutton-html5/tests/puppeteer/chat/send.js +++ b/bigbluebutton-html5/tests/puppeteer/chat/send.js @@ -9,18 +9,23 @@ class Send extends Page { async test() { await util.openChat(this); - const messages0 = await util.getTestElements(this); + // Must be: + // [] + const chat0 = await util.getTestElements(this); await this.type(e.chatBox, 'Hello world!'); await this.click(e.sendButton); await this.screenshot('test-chat.png', true); - const messages1 = await util.getTestElements(this); + // Must be: + // [{ "name": "User1\nXX:XX XM", "message": "Hello world!" }] + const chat1 = await util.getTestElements(this); - console.log('\nChat messages before posting:'); - console.log(JSON.stringify(messages0, null, 2)); - console.log('\nChat messages after posting:'); - console.log(JSON.stringify(messages1, null, 2)); + const response = + chat0.length == 0 && + chat1[0].message == 'Hello world!'; + + return response; } } diff --git a/bigbluebutton-html5/tests/puppeteer/page.js b/bigbluebutton-html5/tests/puppeteer/page.js index 8f1fab5e868536298d9779a6dc1d1c0fc82e8c5b..b1382edb634653bc7c35a286981b2000c4b3ab95 100644 --- a/bigbluebutton-html5/tests/puppeteer/page.js +++ b/bigbluebutton-html5/tests/puppeteer/page.js @@ -63,7 +63,6 @@ class Page { // Joins a BigBlueButton meeting without audio async joinWithoutAudio() { await this.click(e.closeAudio, true); - console.log('Joined meeting without audio'); } // Returns a Promise that resolves when an element does not exist/is removed from the DOM