@microsoft/connected-workbooks 3.2.2-beta → 3.3.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +372 -132
- package/dist/src/utils/constants.js +20 -2
- package/dist/src/utils/documentUtils.js +18 -4
- package/dist/src/utils/tableUtils.js +74 -29
- package/dist/src/utils/xmlInnerPartsUtils.js +156 -14
- package/dist/src/utils/xmlPartsUtils.js +61 -17
- package/dist/src/workbookTemplate.js +3 -1
- package/dist/tests/arrayUtils.test.js +14 -13
- package/dist/tests/documentUtils.test.js +40 -34
- package/dist/tests/gridUtils.test.js +59 -13
- package/dist/tests/htmlUtils.test.js +16 -15
- package/dist/tests/mashupDocumentParser.test.js +7 -6
- package/dist/tests/mocks/xmlMocks.js +3 -1
- package/dist/tests/tableUtils.test.js +44 -37
- package/dist/tests/workbookQueryTemplate.test.js +89 -17
- package/dist/tests/workbookTableTemplate.test.js +12 -11
- package/dist/tests/xmlInnerPartsUtils.test.js +159 -18
- package/dist/types.d.ts +7 -1
- package/dist/utils/constants.js +20 -2
- package/dist/utils/documentUtils.js +18 -4
- package/dist/utils/tableUtils.js +74 -29
- package/dist/utils/xmlInnerPartsUtils.js +156 -14
- package/dist/utils/xmlPartsUtils.js +61 -17
- package/dist/workbookManager.js +12 -12
- package/dist/workbookTemplate.js +3 -1
- package/package.json +8 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pqMetadataXmlMockPart2 = exports.pqMetadataXmlMockPart1 = exports.existingSharedStringsXmlMock = exports.sharedStringsXmlMock = exports.queryTableMock = exports.workbookXmlMock = exports.addZeroSheetsXmlMock = exports.sheetsXmlMock = exports.connectedWorkbookXmlMock = void 0;
|
|
3
|
+
exports.pqConnectionWithrefreshOnLoadDisable = exports.pqConnectionWithrefreshOnLoadEnable = exports.pqMetadataXmlMockPart2 = exports.pqMetadataXmlMockPart1 = exports.existingSharedStringsXmlMock = exports.sharedStringsXmlMock = exports.queryTableMock = exports.workbookXmlMock = exports.addZeroSheetsXmlMock = exports.sheetsXmlMock = exports.connectedWorkbookXmlMock = void 0;
|
|
4
4
|
exports.connectedWorkbookXmlMock = '<?xml version="1.0" encoding="utf-8"?><ConnectedWorkbook xmlns="http://schemas.microsoft.com/ConnectedWorkbook" version="1.0.0"></ConnectedWorkbook>';
|
|
5
5
|
exports.sheetsXmlMock = '<sheetData><row r="1" spans="1:2" x14ac:dyDescent="0.3"><c r="A1" t="str"><v>Column1</v></c><c r="B1" t="str"><v>Column2</v></c></row><row r="2" spans="1:2" x14ac:dyDescent="0.3"><c r="A2" t="1"><v>1</v></c><c r="B2" t="1"><v>2</v></c></row></sheetData>';
|
|
6
6
|
exports.addZeroSheetsXmlMock = '<sheetData><row r="1" spans="1:2" x14ac:dyDescent="0.3"><c r="A1" t="str"><v>Column1</v></c><c r="B1" t="str"><v>Column2</v></c></row><row r="2" spans="1:2" x14ac:dyDescent="0.3"><c r="A2" t="str"><v>one</v></c><c r="B2" t="1"><v>0</v></c></row><row r="3" spans="1:2" x14ac:dyDescent="0.3"><c r="A3" t="str"><v>two</v></c><c r="B3" t="1"><v>2</v></c></row></sheetData>';
|
|
@@ -10,3 +10,5 @@ exports.sharedStringsXmlMock = "<sst xmlns=\"http://schemas.openxmlformats.org/s
|
|
|
10
10
|
exports.existingSharedStringsXmlMock = "<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"1\" uniqueCount=\"1\"><si><t>newQueryName</t></si><si><t/></si></sst>";
|
|
11
11
|
exports.pqMetadataXmlMockPart1 = '<LocalPackageMetadataFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Items> <Item> <ItemLocation> <ItemType>AllFormulas</ItemType> <ItemPath/> </ItemLocation> <StableEntries/> </Item> <Item> <ItemLocation> <ItemType>Formula</ItemType> <ItemPath>Section1/newQueryName</ItemPath> </ItemLocation> <StableEntries> <Entry Type="IsPrivate" Value="l0"/> <Entry Type="FillEnabled" Value="l1"/> <Entry Type="FillObjectType" Value="sTable"/> <Entry Type="FillToDataModelEnabled" Value="l0"/> <Entry Type="BufferNextRefresh" Value="l1"/> <Entry Type="ResultType" Value="sTable"/> <Entry Type="NameUpdatedAfterFill" Value="l0"/> <Entry Type="NavigationStepName" Value="sNavigation"/> <Entry Type="FillTarget" Value="sQuery1"/> <Entry Type="FilledCompleteResultToWorksheet" Value="l1"/> <Entry Type="AddedToDataModel" Value="l0"/> <Entry Type="FillCount" Value="l1"/> <Entry Type="FillErrorCode" Value="sUnknown"/> <Entry Type="FillErrorCount" Value="l0"/>';
|
|
12
12
|
exports.pqMetadataXmlMockPart2 = '<Entry Type="FillColumnTypes" Value="sBg=="/> <Entry Type="FillColumnNames" Value="s["Query1"]"/> <Entry Type="FillStatus" Value="sComplete"/> <Entry Type="RelationshipInfoContainer" Value="s{"columnCount":1,"keyColumnNames":[],"queryRelationships":[],"columnIdentities":["Section1/Query1/AutoRemovedColumns1.{Query1,0}"],"ColumnCount":1,"KeyColumnNames":[],"ColumnIdentities":["Section1/Query1/AutoRemovedColumns1.{Query1,0}"],"RelationshipInfo":[]}"/> </StableEntries> </Item> <Item> <ItemLocation> <ItemType>Formula</ItemType> <ItemPath>Section1/newQueryName/Source</ItemPath> </ItemLocation> <StableEntries/> </Item> </Items> </LocalPackageMetadataFile>';
|
|
13
|
+
exports.pqConnectionWithrefreshOnLoadEnable = "<connection id=\"1\" xr16:uid=\"{86BA784C-6640-4989-A85E-EB4966B9E741}\" keepAlive=\"1\" name=\"Query - Query1\" description=\"Connection to the 'Query1' query in the workbook.\" type=\"5\" refreshedVersion=\"7\" background=\"1\" saveData=\"1\"><dbPr connection=\"Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location="Query1";\" command=\"SELECT * FROM [Query1]\" refreshOnLoad=\"1\"/></connection>";
|
|
14
|
+
exports.pqConnectionWithrefreshOnLoadDisable = "<connection id=\"1\" xr16:uid=\"{86BA784C-6640-4989-A85E-EB4966B9E741}\" keepAlive=\"1\" name=\"Query - Query1\" description=\"Connection to the 'Query1' query in the workbook.\" type=\"5\" refreshedVersion=\"7\" background=\"1\" saveData=\"1\"><dbPr connection=\"Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location="Query1";\" command=\"SELECT * FROM [Query1]\" refreshOnLoad=\"0\"/></connection>";
|
|
@@ -3,61 +3,68 @@
|
|
|
3
3
|
// Licensed under the MIT license.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
var utils_1 = require("../src/utils");
|
|
6
|
+
var constants_1 = require("../src/utils/constants");
|
|
6
7
|
var mocks_1 = require("./mocks");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
8
|
+
var globals_1 = require("@jest/globals");
|
|
9
|
+
(0, globals_1.describe)("Table Utils tests", function () {
|
|
10
|
+
(0, globals_1.test)("tests workbookXML contains initial data dimensions", function () {
|
|
11
|
+
var tableData = {
|
|
11
12
|
columnNames: ["Column1", "Column2"],
|
|
12
13
|
rows: [["1", "2"]],
|
|
13
|
-
}
|
|
14
|
-
|
|
14
|
+
};
|
|
15
|
+
var cellRangeRef = constants_1.defaults.sheetName + utils_1.tableUtils.GenerateReferenceFromString("A1:".concat(utils_1.documentUtils.getCellReferenceRelative(tableData.columnNames.length - 1, tableData.rows.length + 1)));
|
|
16
|
+
var defaultString = '<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"><fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="24729"/><workbookPr codeName="ThisWorkbook" defaultThemeVersion="166925"/><mc:AlternateContent><mc:Choice Requires="x15"><x15ac:absPath url="C:Usersv-ahmadsbeihDesktop" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/></mc:Choice></mc:AlternateContent><xr:revisionPtr revIDLastSave="0" documentId="13_ncr:1_{93EF201C-7856-4B60-94D4-65DDB8F3F16A}" xr6:coauthVersionLast="47" xr6:coauthVersionMax="47" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}"/><bookViews><workbookView xWindow="28680" yWindow="-120" windowWidth="29040" windowHeight="15990" xr2:uid="{DB915CB9-8DD9-492A-A471-C61E61200113}"/></bookViews><sheets><sheet name="Query1" sheetId="2" r:id="rId1"/><sheet name="Sheet1" sheetId="1" r:id="rId2"/></sheets><definedNames><definedName name="ExternalData_1" localSheetId="0" hidden="1">Sheet1!$A$1:$B$2</definedName></definedNames><calcPr calcId="191029"/><extLst><ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}"><x15:workbookPr chartTrackingRefBase="1"/></ext><ext uri="{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}" xmlns:xcalcf="http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures"><xcalcf:calcFeatures><xcalcf:feature name="microsoft.com:RD"/><xcalcf:feature name="microsoft.com:FV"/><xcalcf:feature name="microsoft.com:LET_WF"/><xcalcf:feature name="microsoft.com:LAMBDA_WF"/></xcalcf:calcFeatures></ext></extLst></workbook>';
|
|
17
|
+
var worksheetXml = utils_1.tableUtils.updateWorkbookInitialData(defaultString, cellRangeRef);
|
|
18
|
+
(0, globals_1.expect)(worksheetXml).toContain(mocks_1.workbookXmlMock);
|
|
15
19
|
});
|
|
16
|
-
test("tests Pivot Tables contain initial data", function () {
|
|
20
|
+
(0, globals_1.test)("tests Pivot Tables contain initial data", function () {
|
|
17
21
|
var defaultString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="xr xr3" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" id="1" xr:uid="{D8539CF6-04E5-464D-9950-5A36C5A1FCFE}" name="Query1" displayName="Query1" ref="A1:A2" tableType="queryTable" totalsRowShown="0"><autoFilter ref="A1:A2" xr:uid="{D8539CF6-04E5-464D-9950-5A36C5A1FCFE}"/><tableColumns count="1"><tableColumn id="1" xr3:uid="{D1084858-8AE5-4728-A9BE-FE78821CDFFF}" uniqueName="1" name="Query1" queryTableFieldId="1" dataDxfId="0"/></tableColumns><tableStyleInfo name="TableStyleMedium7" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>';
|
|
18
|
-
var
|
|
22
|
+
var tableData = {
|
|
19
23
|
columnNames: ["Column1", "Column2"],
|
|
20
24
|
rows: [["1", "2"]],
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
expect(tableXmlSheet).toContain('
|
|
24
|
-
expect(tableXmlSheet).toContain('
|
|
25
|
-
expect(tableXmlSheet).toContain('
|
|
26
|
-
expect(tableXmlSheet).toContain('
|
|
27
|
-
expect(tableXmlSheet).toContain('
|
|
28
|
-
expect(tableXmlSheet).toContain('
|
|
29
|
-
expect(tableXmlSheet).toContain('
|
|
25
|
+
};
|
|
26
|
+
var tableXmlSheet = utils_1.tableUtils.updateTablesInitialData(defaultString, tableData, "A1:".concat(utils_1.documentUtils.getCellReferenceRelative(tableData.columnNames.length - 1, tableData.rows.length + 1)), true);
|
|
27
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('count="2"');
|
|
28
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('ref="A1:B2');
|
|
29
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('uniqueName="1"');
|
|
30
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('name="Column1"');
|
|
31
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('queryTableFieldId="1"');
|
|
32
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('uniqueName="2"');
|
|
33
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('name="Column2"');
|
|
34
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('queryTableFieldId="2"');
|
|
30
35
|
});
|
|
31
|
-
test("tests blank Table contain initial data", function () {
|
|
32
|
-
var
|
|
33
|
-
var tableXmlSheet = utils_1.tableUtils.updateTablesInitialData(defaultString, {
|
|
36
|
+
(0, globals_1.test)("tests blank Table contain initial data", function () {
|
|
37
|
+
var tableData = {
|
|
34
38
|
columnNames: ["Column1", "Column2"],
|
|
35
39
|
rows: [["1", "2"]],
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expect(tableXmlSheet).toContain('
|
|
40
|
-
expect(tableXmlSheet).toContain('
|
|
41
|
-
|
|
42
|
-
expect(tableXmlSheet).
|
|
43
|
-
|
|
44
|
-
expect(tableXmlSheet).not.toContain('uniqueName="
|
|
45
|
-
expect(tableXmlSheet).not.toContain('queryTableFieldId="
|
|
40
|
+
};
|
|
41
|
+
var defaultString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="xr xr3" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" id="1" xr:uid="{D8539CF6-04E5-464D-9950-5A36C5A1FCFE}" name="Query1" displayName="Query1" ref="A1:A2" tableType="queryTable" totalsRowShown="0"><autoFilter ref="A1:A2" xr:uid="{D8539CF6-04E5-464D-9950-5A36C5A1FCFE}"/><tableColumns count="1"><tableColumn id="1" xr3:uid="{D1084858-8AE5-4728-A9BE-FE78821CDFFF}" uniqueName="1" name="Query1" queryTableFieldId="1" dataDxfId="0"/></tableColumns><tableStyleInfo name="TableStyleMedium7" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>';
|
|
42
|
+
var tableXmlSheet = utils_1.tableUtils.updateTablesInitialData(defaultString, tableData, "A1:".concat(utils_1.documentUtils.getCellReferenceRelative(tableData.columnNames.length - 1, tableData.rows.length + 1)), false);
|
|
43
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('count="2"');
|
|
44
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('ref="A1:B2');
|
|
45
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('name="Column2"');
|
|
46
|
+
(0, globals_1.expect)(tableXmlSheet).toContain('name="Column1"');
|
|
47
|
+
//Not contains query table metadata.
|
|
48
|
+
(0, globals_1.expect)(tableXmlSheet).not.toContain('uniqueName="1"');
|
|
49
|
+
(0, globals_1.expect)(tableXmlSheet).not.toContain('queryTableFieldId="1"');
|
|
50
|
+
(0, globals_1.expect)(tableXmlSheet).not.toContain('uniqueName="2"');
|
|
51
|
+
(0, globals_1.expect)(tableXmlSheet).not.toContain('queryTableFieldId="2"');
|
|
46
52
|
});
|
|
47
|
-
test("test valid initial data in SheetsXML", function () {
|
|
48
|
-
var
|
|
49
|
-
var sheetsXmlString = utils_1.tableUtils.updateSheetsInitialData(defaultString, {
|
|
53
|
+
(0, globals_1.test)("test valid initial data in SheetsXML", function () {
|
|
54
|
+
var tableData = {
|
|
50
55
|
columnNames: ["Column1", "Column2"],
|
|
51
56
|
rows: [["1", "2"]],
|
|
52
|
-
}
|
|
53
|
-
|
|
57
|
+
};
|
|
58
|
+
var defaultString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{EDF0138E-D216-4CD1-8EFA-1396A1BB4478}"><sheetPr codeName="Sheet1"/><dimension ref="A1:B2"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"><selection sqref="A1:B2"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="14.4" x14ac:dyDescent="0.3"/><cols><col min="1" max="1" width="9.6640625" bestFit="1" customWidth="1"/></cols><sheetData><row r="1" spans="1:1" x14ac:dyDescent="0.3"><c r="A1" t="s"><v>0</v></c></row><row r="2" spans="1:1" x14ac:dyDescent="0.3"><c r="A2" t="s"><v>1</v></c></row></sheetData><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/><tableParts count="1"><tablePart r:id="rId1"/></tableParts></worksheet>';
|
|
59
|
+
var sheetsXmlString = utils_1.tableUtils.updateSheetsInitialData(defaultString, tableData, "A1:".concat(utils_1.documentUtils.getCellReferenceRelative(tableData.columnNames.length - 1, tableData.rows.length + 1)));
|
|
60
|
+
(0, globals_1.expect)(sheetsXmlString).toContain(mocks_1.sheetsXmlMock);
|
|
54
61
|
});
|
|
55
|
-
test("tests Query Tables contain initial data", function () {
|
|
62
|
+
(0, globals_1.test)("tests Query Tables contain initial data", function () {
|
|
56
63
|
var defaultString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<queryTable xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="xr16" xmlns:xr16="http://schemas.microsoft.com/office/spreadsheetml/2017/revision16" name="ExternalData_1" connectionId="1" xr16:uid="{24C17B89-3CD3-4AA5-B84F-9FF5F35245D7}" autoFormatId="16" applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="0"><queryTableRefresh nextId="2"><queryTableFields count="1"><queryTableField id="1" name="Query1" tableColumnId="1"/></queryTableFields></queryTableRefresh></queryTable>';
|
|
57
64
|
var queryTableXmlSheet = utils_1.tableUtils.updateQueryTablesInitialData(defaultString, {
|
|
58
65
|
columnNames: ["Column1", "Column2"],
|
|
59
66
|
rows: [["1", "2"]],
|
|
60
67
|
});
|
|
61
|
-
expect(queryTableXmlSheet).toContain(mocks_1.queryTableMock);
|
|
68
|
+
(0, globals_1.expect)(queryTableXmlSheet).toContain(mocks_1.queryTableMock);
|
|
62
69
|
});
|
|
63
70
|
});
|
|
@@ -47,6 +47,8 @@ var mashupDocumentParser_1 = require("../src/utils/mashupDocumentParser");
|
|
|
47
47
|
var workbookTemplate_1 = require("../src/workbookTemplate");
|
|
48
48
|
var mocks_1 = require("./mocks");
|
|
49
49
|
var jszip_1 = __importDefault(require("jszip"));
|
|
50
|
+
var globals_1 = require("@jest/globals");
|
|
51
|
+
var xmlMocks_1 = require("./mocks/xmlMocks");
|
|
50
52
|
var getZip = function (template) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
53
|
return __generator(this, function (_a) {
|
|
52
54
|
switch (_a.label) {
|
|
@@ -57,14 +59,16 @@ var getZip = function (template) { return __awaiter(void 0, void 0, void 0, func
|
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
61
|
}); };
|
|
60
|
-
describe("Single query template tests", function () {
|
|
62
|
+
(0, globals_1.describe)("Single query template tests", function () {
|
|
61
63
|
var singleQueryDefaultTemplate = workbookTemplate_1.SIMPLE_QUERY_WORKBOOK_TEMPLATE;
|
|
64
|
+
var singleQueryTemplateDiffrenName = workbookTemplate_1.QUERY_WORKBOOK_TEMPLATE_DIFFRENT_SHEET_NAME;
|
|
62
65
|
var defaultZipFile;
|
|
63
|
-
|
|
66
|
+
var zipFileWithSheetName;
|
|
67
|
+
(0, globals_1.beforeAll)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
68
|
return __generator(this, function (_a) {
|
|
65
69
|
switch (_a.label) {
|
|
66
70
|
case 0:
|
|
67
|
-
expect(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
71
|
+
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
68
72
|
switch (_a.label) {
|
|
69
73
|
case 0: return [4 /*yield*/, getZip(singleQueryDefaultTemplate)];
|
|
70
74
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -73,22 +77,37 @@ describe("Single query template tests", function () {
|
|
|
73
77
|
return [4 /*yield*/, getZip(singleQueryDefaultTemplate)];
|
|
74
78
|
case 1:
|
|
75
79
|
defaultZipFile = _a.sent();
|
|
80
|
+
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0: return [4 /*yield*/, getZip(singleQueryTemplateDiffrenName)];
|
|
83
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
84
|
+
}
|
|
85
|
+
}); }); }).not.toThrow();
|
|
86
|
+
return [4 /*yield*/, getZip(singleQueryTemplateDiffrenName)];
|
|
87
|
+
case 2:
|
|
88
|
+
zipFileWithSheetName = _a.sent();
|
|
76
89
|
return [2 /*return*/];
|
|
77
90
|
}
|
|
78
91
|
});
|
|
79
92
|
}); });
|
|
80
|
-
test("Default template is a valid zip file", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
(0, globals_1.test)("Default template is a valid zip file", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
(0, globals_1.expect)(defaultZipFile).toBeTruthy();
|
|
96
|
+
return [2 /*return*/];
|
|
97
|
+
});
|
|
98
|
+
}); });
|
|
99
|
+
(0, globals_1.test)("Template with different name is a valid zip file", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
100
|
return __generator(this, function (_a) {
|
|
82
|
-
expect(
|
|
101
|
+
(0, globals_1.expect)(zipFileWithSheetName).toBeTruthy();
|
|
83
102
|
return [2 /*return*/];
|
|
84
103
|
});
|
|
85
104
|
}); });
|
|
86
|
-
test("DataMashup XML exists, and valid PQ Base64 can be extracted", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
+
(0, globals_1.test)("DataMashup XML exists, and valid PQ Base64 can be extracted", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
106
|
var _a, found, path, value;
|
|
88
107
|
return __generator(this, function (_b) {
|
|
89
108
|
switch (_b.label) {
|
|
90
109
|
case 0:
|
|
91
|
-
expect(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
110
|
+
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
92
111
|
switch (_a.label) {
|
|
93
112
|
case 0: return [4 /*yield*/, utils_1.pqUtils.getDataMashupFile(defaultZipFile)];
|
|
94
113
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -97,28 +116,28 @@ describe("Single query template tests", function () {
|
|
|
97
116
|
return [4 /*yield*/, utils_1.pqUtils.getDataMashupFile(defaultZipFile)];
|
|
98
117
|
case 1:
|
|
99
118
|
_a = _b.sent(), found = _a.found, path = _a.path, value = _a.value;
|
|
100
|
-
expect(found).toBeTruthy();
|
|
101
|
-
expect(value).toEqual(mocks_1.pqEmptySingleQueryBase64);
|
|
102
|
-
expect(path).toEqual(mocks_1.item1Path);
|
|
119
|
+
(0, globals_1.expect)(found).toBeTruthy();
|
|
120
|
+
(0, globals_1.expect)(value).toEqual(mocks_1.pqEmptySingleQueryBase64);
|
|
121
|
+
(0, globals_1.expect)(path).toEqual(mocks_1.item1Path);
|
|
103
122
|
return [2 /*return*/];
|
|
104
123
|
}
|
|
105
124
|
});
|
|
106
125
|
}); });
|
|
107
|
-
test("ConnectedWorkbook XML exists as item1.xml", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
(0, globals_1.test)("ConnectedWorkbook XML exists as item1.xml", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
127
|
var _a, found, path, xmlString;
|
|
109
128
|
return __generator(this, function (_b) {
|
|
110
129
|
switch (_b.label) {
|
|
111
130
|
case 0: return [4 /*yield*/, utils_1.pqUtils.getCustomXmlFile(defaultZipFile, constants_1.URLS.CONNECTED_WORKBOOK)];
|
|
112
131
|
case 1:
|
|
113
132
|
_a = _b.sent(), found = _a.found, path = _a.path, xmlString = _a.xmlString;
|
|
114
|
-
expect(found).toBeTruthy();
|
|
115
|
-
expect(xmlString).toEqual(mocks_1.connectedWorkbookXmlMock);
|
|
116
|
-
expect(path).toEqual(mocks_1.item2Path);
|
|
133
|
+
(0, globals_1.expect)(found).toBeTruthy();
|
|
134
|
+
(0, globals_1.expect)(xmlString).toEqual(mocks_1.connectedWorkbookXmlMock);
|
|
135
|
+
(0, globals_1.expect)(path).toEqual(mocks_1.item2Path);
|
|
117
136
|
return [2 /*return*/];
|
|
118
137
|
}
|
|
119
138
|
});
|
|
120
139
|
}); });
|
|
121
|
-
test("A single blank query named Query1 exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
(0, globals_1.test)("A single blank query named Query1 exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
141
|
var base64Str, packageOPC, packageZip, section1m, hasQuery1;
|
|
123
142
|
var _a;
|
|
124
143
|
return __generator(this, function (_b) {
|
|
@@ -137,10 +156,63 @@ describe("Single query template tests", function () {
|
|
|
137
156
|
throw new Error("section1m is undefined");
|
|
138
157
|
}
|
|
139
158
|
hasQuery1 = section1m.includes("Query1");
|
|
140
|
-
expect(hasQuery1).toBeTruthy();
|
|
141
|
-
expect(section1m).toEqual(mocks_1.section1mBlankQueryMock);
|
|
159
|
+
(0, globals_1.expect)(hasQuery1).toBeTruthy();
|
|
160
|
+
(0, globals_1.expect)(section1m).toEqual(mocks_1.section1mBlankQueryMock);
|
|
142
161
|
return [2 /*return*/];
|
|
143
162
|
}
|
|
144
163
|
});
|
|
145
164
|
}); });
|
|
165
|
+
(0, globals_1.test)("A update query with specific sheet name", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
166
|
+
var queryName, sheetName, refreshOnOpen, zipFileWithSheetNameClone, connectionsXmlString;
|
|
167
|
+
var _a;
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
switch (_b.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
queryName = constants_1.defaults.queryName;
|
|
172
|
+
sheetName = "SheetNew";
|
|
173
|
+
refreshOnOpen = false;
|
|
174
|
+
zipFileWithSheetNameClone = zipFileWithSheetName.clone();
|
|
175
|
+
(0, globals_1.expect)(utils_1.xmlPartsUtils.updateWorkbookSingleQueryAttributes(zipFileWithSheetNameClone, queryName, refreshOnOpen, sheetName)).resolves.toBeUndefined();
|
|
176
|
+
return [4 /*yield*/, utils_1.xmlPartsUtils.updateWorkbookSingleQueryAttributes(zipFileWithSheetNameClone, queryName, refreshOnOpen, sheetName)];
|
|
177
|
+
case 1:
|
|
178
|
+
_b.sent();
|
|
179
|
+
return [4 /*yield*/, ((_a = zipFileWithSheetNameClone.file(constants_1.connectionsXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
180
|
+
case 2:
|
|
181
|
+
connectionsXmlString = _b.sent();
|
|
182
|
+
(0, globals_1.expect)(connectionsXmlString).toContain(xmlMocks_1.pqConnectionWithrefreshOnLoadDisable);
|
|
183
|
+
return [2 /*return*/];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}); });
|
|
187
|
+
(0, globals_1.test)("A update query with default sheet name", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
188
|
+
var queryName, refreshOnOpen, defaultZipFileClone, connectionsXmlString;
|
|
189
|
+
var _a;
|
|
190
|
+
return __generator(this, function (_b) {
|
|
191
|
+
switch (_b.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
queryName = constants_1.defaults.queryName;
|
|
194
|
+
refreshOnOpen = true;
|
|
195
|
+
defaultZipFileClone = defaultZipFile.clone();
|
|
196
|
+
(0, globals_1.expect)(utils_1.xmlPartsUtils.updateWorkbookSingleQueryAttributes(defaultZipFileClone, queryName, refreshOnOpen)).resolves.toBeUndefined();
|
|
197
|
+
return [4 /*yield*/, utils_1.xmlPartsUtils.updateWorkbookSingleQueryAttributes(defaultZipFileClone, queryName, refreshOnOpen)];
|
|
198
|
+
case 1:
|
|
199
|
+
_b.sent();
|
|
200
|
+
return [4 /*yield*/, ((_a = defaultZipFileClone.file(constants_1.connectionsXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
201
|
+
case 2:
|
|
202
|
+
connectionsXmlString = _b.sent();
|
|
203
|
+
(0, globals_1.expect)(connectionsXmlString).toContain(xmlMocks_1.pqConnectionWithrefreshOnLoadEnable);
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}); });
|
|
208
|
+
(0, globals_1.test)("sent sheet name does not exist in template", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
209
|
+
var queryName, sheetName, refreshOnOpen;
|
|
210
|
+
return __generator(this, function (_a) {
|
|
211
|
+
queryName = constants_1.defaults.queryName;
|
|
212
|
+
sheetName = "SheetElse";
|
|
213
|
+
refreshOnOpen = true;
|
|
214
|
+
(0, globals_1.expect)(utils_1.xmlPartsUtils.updateWorkbookSingleQueryAttributes(zipFileWithSheetName, queryName, refreshOnOpen, sheetName)).rejects.toEqual(new Error("Sheet with name ".concat(sheetName, " not found")));
|
|
215
|
+
return [2 /*return*/];
|
|
216
|
+
});
|
|
217
|
+
}); });
|
|
146
218
|
});
|
|
@@ -45,6 +45,7 @@ var workbookTemplate_1 = require("../src/workbookTemplate");
|
|
|
45
45
|
var utils_1 = require("../src/utils");
|
|
46
46
|
var constants_1 = require("../src/utils/constants");
|
|
47
47
|
var jszip_1 = __importDefault(require("jszip"));
|
|
48
|
+
var globals_1 = require("@jest/globals");
|
|
48
49
|
var getZip = function (template) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
50
|
return __generator(this, function (_a) {
|
|
50
51
|
switch (_a.label) {
|
|
@@ -55,14 +56,14 @@ var getZip = function (template) { return __awaiter(void 0, void 0, void 0, func
|
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
}); };
|
|
58
|
-
describe("Single blank table template tests", function () {
|
|
59
|
+
(0, globals_1.describe)("Single blank table template tests", function () {
|
|
59
60
|
var simpleTableDefaultTemplate = workbookTemplate_1.SIMPLE_BLANK_TABLE_TEMPLATE;
|
|
60
61
|
var defaultZipFile;
|
|
61
|
-
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
+
(0, globals_1.beforeAll)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
63
|
return __generator(this, function (_a) {
|
|
63
64
|
switch (_a.label) {
|
|
64
65
|
case 0:
|
|
65
|
-
expect(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
66
|
+
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
66
67
|
switch (_a.label) {
|
|
67
68
|
case 0: return [4 /*yield*/, getZip(simpleTableDefaultTemplate)];
|
|
68
69
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -75,10 +76,10 @@ describe("Single blank table template tests", function () {
|
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
}); });
|
|
78
|
-
test("Default template is a valid zip file", function () {
|
|
79
|
-
expect(defaultZipFile).toBeTruthy();
|
|
79
|
+
(0, globals_1.test)("Default template is a valid zip file", function () {
|
|
80
|
+
(0, globals_1.expect)(defaultZipFile).toBeTruthy();
|
|
80
81
|
});
|
|
81
|
-
test("DataMashup XML doesn't exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
+
(0, globals_1.test)("DataMashup XML doesn't exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
83
|
var error_1;
|
|
83
84
|
return __generator(this, function (_a) {
|
|
84
85
|
switch (_a.label) {
|
|
@@ -90,13 +91,13 @@ describe("Single blank table template tests", function () {
|
|
|
90
91
|
return [3 /*break*/, 3];
|
|
91
92
|
case 2:
|
|
92
93
|
error_1 = _a.sent();
|
|
93
|
-
expect(error_1).toBeTruthy();
|
|
94
|
+
(0, globals_1.expect)(error_1).toBeTruthy();
|
|
94
95
|
return [3 /*break*/, 3];
|
|
95
96
|
case 3: return [2 /*return*/];
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
}); });
|
|
99
|
-
test("A single blank table exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
(0, globals_1.test)("A single blank table exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
101
|
var tableXml;
|
|
101
102
|
var _a;
|
|
102
103
|
return __generator(this, function (_b) {
|
|
@@ -104,12 +105,12 @@ describe("Single blank table template tests", function () {
|
|
|
104
105
|
case 0: return [4 /*yield*/, ((_a = defaultZipFile.file(constants_1.tableXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
105
106
|
case 1:
|
|
106
107
|
tableXml = _b.sent();
|
|
107
|
-
expect(tableXml).toContain('name="Table1" displayName="Table1" ref="A1:A2"');
|
|
108
|
+
(0, globals_1.expect)(tableXml).toContain('name="Table1" displayName="Table1" ref="A1:A2"');
|
|
108
109
|
return [2 /*return*/];
|
|
109
110
|
}
|
|
110
111
|
});
|
|
111
112
|
}); });
|
|
112
|
-
test("Does not contains query table", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
(0, globals_1.test)("Does not contains query table", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
114
|
var queryTableXml;
|
|
114
115
|
var _a;
|
|
115
116
|
return __generator(this, function (_b) {
|
|
@@ -117,7 +118,7 @@ describe("Single blank table template tests", function () {
|
|
|
117
118
|
case 0: return [4 /*yield*/, ((_a = defaultZipFile.file(constants_1.queryTableXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
118
119
|
case 1:
|
|
119
120
|
queryTableXml = _b.sent();
|
|
120
|
-
expect(queryTableXml).toBeFalsy();
|
|
121
|
+
(0, globals_1.expect)(queryTableXml).toBeFalsy();
|
|
121
122
|
return [2 /*return*/];
|
|
122
123
|
}
|
|
123
124
|
});
|