bigbluebutton-Github/bigbluebutton-tests/playwright/polling/util.js

37 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2022-06-08 02:52:22 +08:00
const { test } = require('@playwright/test');
2021-11-26 02:23:58 +08:00
const e = require('../core/elements.js');
2022-03-29 21:53:07 +08:00
const { getSettings } = require('../core/settings.js');
const path = require('path');
2021-11-26 02:23:58 +08:00
2022-06-08 02:52:22 +08:00
async function openPoll(testPage) {
2022-03-29 21:53:07 +08:00
const { pollEnabled } = getSettings();
test.fail(!pollEnabled, 'Polling is disabled');
2022-06-08 02:52:22 +08:00
await testPage.waitAndClick(e.actions);
await testPage.waitAndClick(e.polling);
await testPage.hasElement(e.hidePollDesc, 'should display the hide poll description when creating a new poll');
2022-06-08 02:52:22 +08:00
await testPage.waitAndClick(e.pollLetterAlternatives);
await testPage.checkElementCount(e.pollOptionItem, 4, 'should display the poll options item for the poll answers');
2021-11-26 02:23:58 +08:00
}
2024-03-05 00:44:47 +08:00
async function startPoll(test, isAnonymous = false) {
2021-11-26 02:23:58 +08:00
await openPoll(test);
2023-04-28 20:30:29 +08:00
if (isAnonymous) await test.getLocator(e.anonymousPoll).setChecked();
2021-11-26 02:23:58 +08:00
await test.waitAndClick(e.startPoll);
}
async function uploadSPresentationForTestingPolls(test, fileName) {
await test.waitAndClick(e.actions);
await test.waitAndClick(e.managePresentations);
await test.hasElement(e.presentationFileUpload, 'should display the presentation file upload on the manage presentations modal');
await test.page.setInputFiles(e.presentationFileUpload, path.join(__dirname, `../core/media/${fileName}`));
await test.hasText('body', e.statingUploadPresentationToast, 'should display the presentation toast about the upload');
await test.waitAndClick(e.confirmManagePresentation);
}
2021-11-26 02:23:58 +08:00
exports.openPoll = openPoll;
2021-12-04 01:01:36 +08:00
exports.startPoll = startPoll;
exports.uploadSPresentationForTestingPolls = uploadSPresentationForTestingPolls;