Skip to content

Commit d5b366e

Browse files
authored
Replace legacy xlsx dependency (#433)
* Add test for xlsx table export verification * Replace xlsx with @e965/xlsx
1 parent 8ac12ca commit d5b366e

File tree

6 files changed

+41
-107
lines changed

6 files changed

+41
-107
lines changed

cypress/e2e/cps-table.cy.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import path = require('path');
2+
3+
describe('cps-table page', () => {
4+
describe('export to xlsx', () => {
5+
beforeEach(() => {
6+
cy.visit('/table');
7+
});
8+
9+
it('should properly download valid xlsx', () => {
10+
cy.contains('Table 6').click({ force: true });
11+
cy.get('.cps-table-tbar-export-btn cps-icon').click();
12+
cy.contains('XLSX').click();
13+
14+
const downloadsFolder = Cypress.config('downloadsFolder');
15+
const downloadedFilePath = path.join(downloadsFolder, 'table_6.xlsx');
16+
cy.readFile(downloadedFilePath).should('exist');
17+
18+
cy.fixture('table_6_fixture.xlsx').then((fixtureContent) => {
19+
cy.readFile(downloadedFilePath).then((downloadedFileContent) => {
20+
expect(downloadedFileContent).equals(fixtureContent);
21+
});
22+
});
23+
});
24+
});
25+
});

cypress/fixtures/table_6_fixture.xlsx

21 KB
Binary file not shown.

package-lock.json

Lines changed: 13 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
"@angular/platform-browser-dynamic": "^19.1.4",
2525
"@angular/platform-server": "^19.1.4",
2626
"@angular/router": "^19.1.4",
27+
"@e965/xlsx": "^0.20.3",
2728
"@types/lodash-es": "^4.17.12",
2829
"eslint-plugin-cypress": "^3.6.0",
2930
"lodash-es": "^4.17.21",
3031
"primeng": "^19.0.5",
3132
"rxjs": "~7.8.1",
3233
"tslib": "^2.8.1",
33-
"xlsx": "^0.18.5",
3434
"zone.js": "^0.15.0"
3535
},
3636
"devDependencies": {

projects/cps-ui-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@types/lodash-es": "^4.17.12",
1111
"lodash-es": "^4.17.21",
1212
"primeng": "^19.0.5",
13-
"xlsx": "^0.18.5"
13+
"@e965/xlsx": "^0.20.3"
1414
},
1515
"repository": {
1616
"type": "git",

projects/cps-ui-kit/src/lib/components/cps-table/cps-table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ export class CpsTableComponent implements OnInit, AfterViewChecked, OnChanges {
981981
}
982982

983983
exportXLSX() {
984-
import('xlsx').then((xlsx) => {
984+
import('@e965/xlsx').then((xlsx) => {
985985
const sheetData = [
986986
this.selectedColumns.map(
987987
(c: { [key: string]: any }) => c[this.colHeaderName]

0 commit comments

Comments
 (0)