@skyux/ag-grid 13.11.5 → 14.0.0-alpha.0
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/fesm2022/skyux-ag-grid-testing.mjs +69 -0
- package/fesm2022/skyux-ag-grid-testing.mjs.map +1 -0
- package/fesm2022/skyux-ag-grid.mjs +145 -123
- package/fesm2022/skyux-ag-grid.mjs.map +1 -1
- package/package.json +23 -18
- package/types/skyux-ag-grid-testing.d.ts +39 -0
- package/{index.d.ts → types/skyux-ag-grid.d.ts} +28 -12
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { UnitTestElement } from '@angular/cdk/testing/testbed';
|
|
2
|
+
import { SkyComponentHarness } from '@skyux/core/testing';
|
|
3
|
+
import { getGridApi } from 'ag-grid-community';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Harness for interacting with SKY UX AG Grid components in tests.
|
|
7
|
+
*/
|
|
8
|
+
class SkyAgGridWrapperHarness extends SkyComponentHarness {
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
static { this.hostSelector = 'sky-ag-grid-wrapper'; }
|
|
13
|
+
/**
|
|
14
|
+
* Gets a `HarnessPredicate` that can be used to search for a
|
|
15
|
+
* `SkyAgGridWrapperHarness` that meets certain criteria
|
|
16
|
+
*/
|
|
17
|
+
static with(filters) {
|
|
18
|
+
return SkyAgGridWrapperHarness.getDataSkyIdPredicate(filters);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether the grid is ready.
|
|
22
|
+
*/
|
|
23
|
+
async isGridReady() {
|
|
24
|
+
const gridReady = this.locatorFactory.locatorFor('.ag-root.ag-unselectable');
|
|
25
|
+
return await gridReady()
|
|
26
|
+
.then((el) => !!el)
|
|
27
|
+
.catch(() => false);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the IDs of the currently displayed columns.
|
|
31
|
+
*/
|
|
32
|
+
async getDisplayedColumnIds() {
|
|
33
|
+
return await this.#getGridApi()
|
|
34
|
+
.then((api) => api.getAllDisplayedColumns().map((col) => col.getColId()))
|
|
35
|
+
.catch(() => Promise.reject('Unable to retrieve displayed column IDs.'));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the header names of the currently displayed columns.
|
|
39
|
+
*/
|
|
40
|
+
async getDisplayedColumnHeaderNames() {
|
|
41
|
+
return await this.#getGridApi()
|
|
42
|
+
.then((api) => api
|
|
43
|
+
.getAllDisplayedColumns()
|
|
44
|
+
.map((col) => col.getColDef().headerName || ''))
|
|
45
|
+
.catch(() => Promise.reject('Unable to retrieve displayed column header names.'));
|
|
46
|
+
}
|
|
47
|
+
async #getGridApi() {
|
|
48
|
+
await this.waitForTasksOutsideAngular();
|
|
49
|
+
const locator = this.locatorFactory.locatorFor('ag-grid-angular');
|
|
50
|
+
return await locator().then((grid) => {
|
|
51
|
+
if (grid instanceof UnitTestElement) {
|
|
52
|
+
const api = getGridApi(grid.element);
|
|
53
|
+
if (api) {
|
|
54
|
+
return api;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// If this harness were used in an environment that did not provide UnitTestElement.
|
|
58
|
+
/* istanbul ignore next */
|
|
59
|
+
throw new Error('Unable to get GridApi from AgGridAngular component.');
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Generated bundle index. Do not edit.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
export { SkyAgGridWrapperHarness };
|
|
69
|
+
//# sourceMappingURL=skyux-ag-grid-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skyux-ag-grid-testing.mjs","sources":["../../../../../libs/components/ag-grid/testing/src/modules/ag-grid-wrapper/ag-grid-wrapper-harness.ts","../../../../../libs/components/ag-grid/testing/src/skyux-ag-grid-testing.ts"],"sourcesContent":["import { HarnessPredicate } from '@angular/cdk/testing';\nimport { UnitTestElement } from '@angular/cdk/testing/testbed';\nimport { SkyComponentHarness } from '@skyux/core/testing';\n\nimport { GridApi, getGridApi } from 'ag-grid-community';\n\nimport { SkyAgGridWrapperHarnessFilters } from './ag-grid-wrapper-harness.filters';\n\n/**\n * Harness for interacting with SKY UX AG Grid components in tests.\n */\nexport class SkyAgGridWrapperHarness extends SkyComponentHarness {\n /**\n * @internal\n */\n public static hostSelector = 'sky-ag-grid-wrapper';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a\n * `SkyAgGridWrapperHarness` that meets certain criteria\n */\n public static with(\n filters: SkyAgGridWrapperHarnessFilters,\n ): HarnessPredicate<SkyAgGridWrapperHarness> {\n return SkyAgGridWrapperHarness.getDataSkyIdPredicate(filters);\n }\n\n /**\n * Checks whether the grid is ready.\n */\n public async isGridReady(): Promise<boolean> {\n const gridReady = this.locatorFactory.locatorFor(\n '.ag-root.ag-unselectable',\n );\n\n return await gridReady()\n .then((el) => !!el)\n .catch(() => false);\n }\n\n /**\n * Retrieves the IDs of the currently displayed columns.\n */\n public async getDisplayedColumnIds(): Promise<string[]> {\n return await this.#getGridApi()\n .then((api) => api.getAllDisplayedColumns().map((col) => col.getColId()))\n .catch(() => Promise.reject('Unable to retrieve displayed column IDs.'));\n }\n\n /**\n * Retrieves the header names of the currently displayed columns.\n */\n public async getDisplayedColumnHeaderNames(): Promise<string[]> {\n return await this.#getGridApi()\n .then((api) =>\n api\n .getAllDisplayedColumns()\n .map((col) => col.getColDef().headerName || ''),\n )\n .catch(() =>\n Promise.reject('Unable to retrieve displayed column header names.'),\n );\n }\n\n async #getGridApi(): Promise<GridApi> {\n await this.waitForTasksOutsideAngular();\n const locator = this.locatorFactory.locatorFor('ag-grid-angular');\n return await locator().then((grid) => {\n if (grid instanceof UnitTestElement) {\n const api = getGridApi(grid.element);\n if (api) {\n return api;\n }\n }\n // If this harness were used in an environment that did not provide UnitTestElement.\n /* istanbul ignore next */\n throw new Error('Unable to get GridApi from AgGridAngular component.');\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAQA;;AAEG;AACG,MAAO,uBAAwB,SAAQ,mBAAmB,CAAA;AAC9D;;AAEG;aACW,IAAA,CAAA,YAAY,GAAG,qBAAqB,CAAC;AAEnD;;;AAGG;IACI,OAAO,IAAI,CAChB,OAAuC,EAAA;AAEvC,QAAA,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,OAAO,CAAC;IAC/D;AAEA;;AAEG;AACI,IAAA,MAAM,WAAW,GAAA;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAC9C,0BAA0B,CAC3B;QAED,OAAO,MAAM,SAAS;aACnB,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;AACjB,aAAA,KAAK,CAAC,MAAM,KAAK,CAAC;IACvB;AAEA;;AAEG;AACI,IAAA,MAAM,qBAAqB,GAAA;AAChC,QAAA,OAAO,MAAM,IAAI,CAAC,WAAW;aAC1B,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,sBAAsB,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,QAAQ,EAAE,CAAC;aACvE,KAAK,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC;IAC5E;AAEA;;AAEG;AACI,IAAA,MAAM,6BAA6B,GAAA;AACxC,QAAA,OAAO,MAAM,IAAI,CAAC,WAAW;AAC1B,aAAA,IAAI,CAAC,CAAC,GAAG,KACR;AACG,aAAA,sBAAsB;AACtB,aAAA,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC;aAElD,KAAK,CAAC,MACL,OAAO,CAAC,MAAM,CAAC,mDAAmD,CAAC,CACpE;IACL;AAEA,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,MAAM,IAAI,CAAC,0BAA0B,EAAE;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC;QACjE,OAAO,MAAM,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AACnC,YAAA,IAAI,IAAI,YAAY,eAAe,EAAE;gBACnC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;gBACpC,IAAI,GAAG,EAAE;AACP,oBAAA,OAAO,GAAG;gBACZ;YACF;;;AAGA,YAAA,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC;AACxE,QAAA,CAAC,CAAC;IACJ;;;AC9EF;;AAEG;;;;"}
|