Files
DynamicPoll/tests/validate-project.js
T
Torsten Brendgen 6bcf7c5020 feat: Update dynamic poll web part to version 1.3.0 with enhanced field mapping and configurable title
- Bump version in package.json to 1.3.0
- Add new properties for field mapping in DynamicPollWebPart.manifest.json
- Enhance DynamicPollWebPart.ts to support dynamic field mapping for polls and answers
- Implement field loading and default application logic in PollDataService.ts
- Update PollTypes.ts to include new interfaces for field mapping
- Modify DynamicPollCollection.tsx to display configurable web part title
- Update styles in DynamicPoll.module.scss for improved UI
- Add localization strings for new properties in en-us.js and de-de.js
- Update tests to reflect changes in data structure and functionality
- Validate project structure and ensure all new features are accounted for
2026-08-27 00:13:58 +02:00

56 lines
3.8 KiB
JavaScript

'use strict';
var fs = require('fs');
var path = require('path');
var root = path.resolve(__dirname, '..');
var passed = 0;
function read(file) { return fs.readFileSync(path.join(root, file), 'utf8'); }
function json(file) { return JSON.parse(read(file)); }
function assert(condition, message) { if (!condition) { throw new Error(message); } passed++; }
var packageJson = json('package.json');
var solution = json('config/package-solution.json').solution;
var manifest = json('src/webparts/dynamicPoll/DynamicPollWebPart.manifest.json');
var webPart = read('src/webparts/dynamicPoll/DynamicPollWebPart.ts');
var service = read('src/webparts/dynamicPoll/PollDataService.ts');
var component = read('src/webparts/dynamicPoll/components/DynamicPoll.tsx');
var collection = read('src/webparts/dynamicPoll/components/DynamicPollCollection.tsx');
var styles = read('src/webparts/dynamicPoll/components/DynamicPoll.module.scss');
assert(packageJson.version === '1.3.0' && solution.version === '1.3.0.0', 'Version mismatch.');
assert(solution.includeClientSideAssets === true && solution.skipFeatureDeployment === true, 'Central deployment missing.');
assert(packageJson.name === 'dynamic-poll-web-part' && solution.name === 'dynamic-poll-web-part' &&
solution.title === 'dynamic-poll-web-part', 'Dynamic Poll package naming is inconsistent.');
assert(json('config/package-solution.json').paths.zippedPackage === 'solution/dynamic-poll-web-part.sppkg',
'Dynamic Poll package file name is inconsistent.');
assert(manifest.componentType === 'WebPart', 'Component is not a web part.');
assert(webPart.indexOf("PropertyPaneDropdown('pollListId'") >= 0 && webPart.indexOf("PropertyPaneDropdown('answerListId'") >= 0,
'List selection is missing.');
assert(webPart.indexOf("PropertyPaneDropdown('pollKeyField'") >= 0 &&
webPart.indexOf("PropertyPaneDropdown('answerPollKeyField'") >= 0 &&
webPart.indexOf("PropertyPaneDropdown('answerValueField'") >= 0, 'Column mapping is missing.');
assert(webPart.indexOf("PropertyPaneTextField('title'") >= 0 &&
collection.indexOf('styles.webPartHeading') >= 0,
'Configurable web part title is missing.');
assert(webPart.indexOf("PropertyPaneDropdown('displayMode'") >= 0 &&
webPart.indexOf('DynamicPollCollection') >= 0, 'Multiple-poll display mode is missing.');
assert(service.indexOf('getSnapshots') >= 0 && service.indexOf('getActivePolls') >= 0,
'All active polls must be loaded and remain voteable.');
assert(service.indexOf("body[mapping.answerPollKeyField]") >= 0 &&
service.indexOf("body[mapping.answerValueField]") >= 0, 'Mapped 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('mapping.pollOptionsField') >= 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(read('deployment/Initialize-DynamicPollLists.ps1').indexOf("InternalName 'PollKey'") >= 0 &&
read('deployment/Initialize-DynamicPollLists.ps1').indexOf('Type="Lookup" DisplayName="Poll"') < 0,
'Content Type Hub compatible text key 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.');
['neutralPrimary', 'neutralLight', 'themePrimary', 'themeDark', 'white'].forEach(function (slot) {
assert(styles.indexOf('[theme: ' + slot + ', default:') >= 0, 'Theme slot missing: ' + slot);
});
console.log('DynamicPoll project validation passed:', passed);