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');
|
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.waitForSelector(e.hidePollDesc);
|
|
|
|
await testPage.waitAndClick(e.pollLetterAlternatives);
|
|
|
|
await testPage.waitForSelector(e.pollOptionItem);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function startPoll(test, shouldPublishPoll = false, isAnonymous = false) {
|
|
|
|
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);
|
|
|
|
if (shouldPublishPoll) await test.waitAndClick(e.publishPollingLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.openPoll = openPoll;
|
2021-12-04 01:01:36 +08:00
|
|
|
exports.startPoll = startPoll;
|