bigbluebutton-Github/bigbluebutton-html5/tests/puppeteer/test-hotkeys.js
browniecab a9fcad4a0d Added Puppeteer tests
(cherry picked from commit 91ed0475fce431322bef33e0ccb2465d2213f87f)
2018-10-03 13:32:53 -04:00

180 lines
5.0 KiB
JavaScript

// Test: Hotkeys: Options, User List, Leave/Join Audio, Mute/Unmute, Toggle Public Chat, Actions Menu, Status Menu
const Page = require('./page');
const helper = require('./helper');
const e = require('./elements');
class HotkeysTestPage extends Page
{
constructor()
{
super();
this.tabCounts =
{
options: 1,
actions: 11,
audioNoMic: 12,
audioMic: 13,
mute: 12,
chat: 15,
closeChat: 17, // Only when chat is open
status: 16,
userList: 18
}
}
async test()
{
await this.createBBBMeeting();
await this.joinAudioListenOnly();
await this.page.waitFor(e.whiteboard);
await this.page.waitFor(e.options);
await this.page.waitFor(e.userList);
await this.page.waitFor(e.toolbox);
await this.page.waitFor(e.leaveAudio);
await this.page.waitFor(e.chatButton);
await this.page.waitFor(e.firstUser);
await this.page.waitFor(e.screenShare);
await this.page.waitFor(e.videoMenu);
await this.page.waitFor(e.actions);
await this.page.waitFor(e.nextSlide);
await this.page.waitFor(e.prevSlide);
await this.elementRemoved(e.alerts);
// Options
await this.page.click(e.title);
await this.tab(this.tabCounts.options);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-options-0.png"});
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-options-1.png"});
// User List
await this.page.click(e.title);
await this.tab(this.tabCounts.userList);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-userlist-0.png"});
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-userlist-1.png"});
// Toggle Public Chat
await this.elementRemoved(e.alerts);
await this.page.click(e.title);
await this.tab(this.tabCounts.chat);
await this.up(1);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-chat-0.png"});
await this.page.click(e.title);
await this.tab(this.tabCounts.closeChat);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-chat-1.png"});
// Open Actions Menu
await this.page.click(e.title);
await this.tab(this.tabCounts.actions);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-actions-0.png"});
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-actions-1.png"});
// Open Status Menu
await this.elementRemoved(e.alerts);
await this.page.click(e.title);
await this.tab(this.tabCounts.status);
await this.up(1);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-status-0.png"});
await this.tab(1);
await this.enter();
await this.tab(1);
await this.down(7); //Applaud status
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-status-1.png"});
// Leave/Join Audio
await this.page.click(e.title);
await this.tab(this.tabCounts.audioNoMic);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-audio-0.png"});
await this.enter();
await this.page.waitFor(e.microphoneButton);
await this.tab(2);
await this.enter();
await this.page.waitFor(e.echoYes);
await helper.sleep(500); // Echo test confirmation sometimes fails without this
await this.tab(1);
await this.enter();
await this.elementRemoved(e.audioDialog);
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-audio-1.png"});
// Mute/Unmute
await this.elementRemoved(e.alerts);
await this.page.click(e.title);
await this.tab(this.tabCounts.mute);
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-mute-0.png"});
await this.enter();
await helper.sleep(500);
await this.page.screenshot({path: "screenshots/test-hotkeys-mute-1.png"});
}
async tab(count)
{
for(var i = 0; i < count; i++)
{
await this.page.keyboard.press('Tab');
}
}
async enter()
{
await this.page.keyboard.press('Enter');
}
async down(count)
{
for(var i = 0; i < count; i++)
{
await this.page.keyboard.press('ArrowDown');
}
}
async up(count)
{
for(var i = 0; i < count; i++)
{
await this.page.keyboard.press('ArrowUp');
}
}
};
var test = new HotkeysTestPage();
(async() =>
{
try
{
await test.init(Page.getArgs());
await test.test();
await test.close();
}
catch(e)
{
console.log(e);
process.exit(1);
}
})();