Implement multiline options support and legacy field handling in Dynamic Poll

This commit is contained in:
Torsten Brendgen
2026-08-24 09:32:31 +02:00
parent ca41674188
commit 53690530bc
6 changed files with 104 additions and 24 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
import { calculatePollResults, findUserAnswer, selectActivePoll } from '../src/webparts/dynamicPoll/PollCore';
import { calculatePollResults, findUserAnswer, parsePollOptionLines, selectActivePoll } from '../src/webparts/dynamicPoll/PollCore';
import { IPoll, IPollAnswer } from '../src/webparts/dynamicPoll/PollTypes';
let passed: number = 0;
@@ -30,5 +30,7 @@ assert('votes are counted per configured option', results[0].votes === 2 && resu
assert('invalid legacy answer is excluded from percentage', results[0].percentage === 67 && results[1].percentage === 33);
assert('user lookup is case insensitive', findUserAnswer(answers, 'ONE@CONTOSO.LOCAL') === 'A');
assert('unknown user has no answer', findUserAnswer(answers, 'unknown@contoso.local') === '');
const parsedOptions: string[] = parsePollOptionLines(['Ja\r\nNein\n\n Anderer Termin ', 'ja']);
assert('multiline options are trimmed, split and deduplicated',
parsedOptions.length === 3 && parsedOptions[0] === 'Ja' && parsedOptions[2] === 'Anderer Termin');
console.log('DynamicPoll core tests passed:', passed);
+4
View File
@@ -23,6 +23,10 @@ assert(webPart.indexOf("PropertyPaneDropdown('pollListId'") >= 0 && webPart.inde
assert(service.indexOf("'PollId': pollId") >= 0 && service.indexOf("'Answer': answer") >= 0, 'Vote persistence is missing.');
assert(service.indexOf("new Error('ALREADY_VOTED')") >= 0, 'Duplicate vote protection is missing.');
assert(service.indexOf("new Error('POLL_NOT_ACTIVE')") >= 0, 'Active poll and answer validation is missing.');
assert(service.indexOf("'OptionsText'") >= 0 && service.indexOf('parsePollOptionLines') >= 0,
'Multiline poll options are missing.');
assert(read('deployment/Initialize-DynamicPollLists.ps1').indexOf('Type="Note" DisplayName="Options"') >= 0,
'Multiline options field provisioning is missing.');
assert(component.indexOf("type='radio'") >= 0 && component.indexOf("role='progressbar'") >= 0,
'Accessible voting or results UI is missing.');
assert(fs.existsSync(path.join(root, 'deployment/Initialize-DynamicPollLists.ps1')), 'Provisioning script is missing.');