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');
|
2024-04-06 00:35:32 +08:00
|
|
|
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);
|
2024-07-31 06:49:02 +08:00
|
|
|
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);
|
2024-07-31 06:49:02 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-04-06 00:35:32 +08:00
|
|
|
async function uploadSPresentationForTestingPolls(test, fileName) {
|
|
|
|
await test.waitAndClick(e.actions);
|
|
|
|
await test.waitAndClick(e.managePresentations);
|
2024-07-31 06:49:02 +08:00
|
|
|
await test.hasElement(e.presentationFileUpload, 'should display the presentation file upload on the manage presentations modal');
|
2024-04-06 00:35:32 +08:00
|
|
|
|
|
|
|
await test.page.setInputFiles(e.presentationFileUpload, path.join(__dirname, `../core/media/${fileName}`));
|
2024-07-31 06:49:02 +08:00
|
|
|
await test.hasText('body', e.statingUploadPresentationToast, 'should display the presentation toast about the upload');
|
2024-04-06 00:35:32 +08:00
|
|
|
|
|
|
|
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;
|
2024-04-06 00:35:32 +08:00
|
|
|
exports.uploadSPresentationForTestingPolls = uploadSPresentationForTestingPolls;
|