58 lines
4.0 KiB
JavaScript
58 lines
4.0 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.1' && solution.version === '1.3.1.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("String(this.properties.title || '').trim()") >= 0,
|
|
'An empty web part title must remain hidden.');
|
|
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);
|