Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 9f3b71e

Browse files
committed
add tests for edit/delete/rename with hidden cols, and canceled name edit
1 parent bf0b3b3 commit 9f3b71e

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

tests/cypress/tests/standalone/column_test.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ describe(`column, mode=${AppMode.Actionable}, flavor=${AppFlavor.Merged}, ${AppF
2727
DashTable.getHeader(1, 1).within(() => cy.get('span.column-header-name').should('have.html', 'Paris'));
2828
});
2929

30+
it('keeps hidden pieces when deleting a merged column', () => {
31+
cy.get('.column-4 .column-header--hide').click(); // Boston
32+
cy.get('.column-2 .column-header--hide').click(); // Montréal
33+
DashTable.deleteColumnById(0, 'ccc'); // City
34+
cy.get('.show-hide').click();
35+
cy.get('.show-hide-menu-item input').eq(1).click(); // Montréal
36+
cy.get('.show-hide-menu-item input').eq(2).click(); // Boston
37+
cy.get('.column-1 .column-header-name').eq(2).should('have.html', 'Montréal');
38+
cy.get('.column-2 .column-header-name').eq(1).should('have.html', 'Boston');
39+
});
40+
3041
it('can clear column', () => {
3142
DashTable.getFilter(0).click();
3243
DOM.focused.type(`is num`);
@@ -62,6 +73,29 @@ describe(`column, mode=${AppMode.Actionable}, flavor=${AppFlavor.Merged}, ${AppF
6273
DashTable.getFilter(4).within(() => cy.get('input').should('have.value', ''));
6374
});
6475

76+
it('keeps hidden pieces when clearing a merged column', () => {
77+
// initial state of city columns
78+
DashTable.getCell(0, 1).within(() => cy.get('.dash-cell-value').should('have.html', '1'));
79+
DashTable.getCell(0, 2).within(() => cy.get('.dash-cell-value').should('have.html', '100'));
80+
DashTable.getCell(0, 3).within(() => cy.get('.dash-cell-value').should('have.html', '1'));
81+
DashTable.getCell(0, 4).within(() => cy.get('.dash-cell-value').should('have.html', '2'));
82+
DashTable.getCell(0, 5).within(() => cy.get('.dash-cell-value').should('have.html', '10'));
83+
84+
cy.get('.column-4 .column-header--hide').click(); // Boston
85+
cy.get('.column-2 .column-header--hide').click(); // Montréal
86+
DashTable.clearColumnById(0, 'ccc'); // City
87+
cy.get('.show-hide').click();
88+
cy.get('.show-hide-menu-item input').eq(2).click(); // Montréal
89+
cy.get('.show-hide-menu-item input').eq(4).click(); // Boston
90+
91+
// after clear and re-show -> only Montréal and Boston have data
92+
DashTable.getCell(0, 1).within(() => cy.get('.dash-cell-value').should('have.html', ''));
93+
DashTable.getCell(0, 2).within(() => cy.get('.dash-cell-value').should('have.html', '100'));
94+
DashTable.getCell(0, 3).within(() => cy.get('.dash-cell-value').should('have.html', ''));
95+
DashTable.getCell(0, 4).within(() => cy.get('.dash-cell-value').should('have.html', '2'));
96+
DashTable.getCell(0, 5).within(() => cy.get('.dash-cell-value').should('have.html', ''));
97+
});
98+
6599
it('can hide column', () => {
66100
DashTable.getHeader(0, 0).within(() => cy.get('span.column-header-name').should('have.html', 'rows'));
67101
DashTable.hideColumnById(0, 'rows');
@@ -313,4 +347,4 @@ describe(`column, mode=${AppMode.Actionable}`, () => {
313347
DashTable.getHeader(1, 2).within(() => cy.get('span.column-header-name').should('have.html', 'France'));
314348
DashTable.getHeader(2, 2).within(() => cy.get('span.column-header-name').should('have.html', 'Paris'));
315349
});
316-
});
350+
});

tests/cypress/tests/standalone/edit_headers.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,49 @@ describe(`edit, mode=${AppMode.Typed}`, () => {
5151
});
5252
});
5353

54+
describe(`edit headers while some columns are hidden`, () => {
55+
beforeEach(() => {
56+
cy.visit(`http://localhost:8080?mode=${AppMode.Actionable}&flavor=${AppFlavor.Merged}`);
57+
DashTable.toggleScroll(false);
58+
})
59+
it('preserves hidden columns unchanged when editing visible names', () => {
60+
cy.window().then((win: any) => {
61+
cy.stub(win, 'prompt').returns('Chill');
62+
});
63+
// hide 3 columns - one at the start of a merged set, one in the middle, one not in the set
64+
cy.get('.column-8 .column-header--hide').click({force: true});
65+
cy.get('.column-6 .column-header--hide').click({force: true});
66+
cy.get('.column-1 .column-header--hide').click({force: true});
67+
// edit the merged name
68+
cy.get('.dash-header.column-5 .column-header--edit').eq(1).click({force: true});
69+
// re-show the hidden columns
70+
cy.get('.show-hide').click();
71+
cy.get('.show-hide-menu-item input').eq(1).click();
72+
cy.get('.show-hide-menu-item input').eq(6).click();
73+
cy.get('.show-hide-menu-item input').eq(8).click();
74+
// all columns still exist
75+
cy.get('.dash-header.column-9 .column-header-name').should('have.html', 'Temperature-RO');
76+
// the columns that were hidden when the merged name was changed
77+
// still changed name - so they're still all merged
78+
cy.get('.dash-header.column-6[colspan="4"] .column-header-name').eq(1).should('have.html', 'Chill');
79+
});
80+
});
81+
82+
describe('edit headers, canceled edit', () => {
83+
beforeEach(() => {
84+
cy.visit(`http://localhost:8080?mode=${AppMode.SingleHeaders}`);
85+
DashTable.toggleScroll(false);
86+
});
87+
it('preserves column name if edit is canceled', () => {
88+
cy.window().then((win: any) => {
89+
// user presses cancel -> prompt returns null
90+
cy.stub(win, 'prompt').returns(null);
91+
});
92+
cy.get('.dash-header.column-0 .column-header--edit').eq(0).click();
93+
cy.get('.dash-header.column-0 > div > span:last-child').should('have.html', 'rows');
94+
});
95+
});
96+
5497
describe(`edit headers, mode=${AppMode.SingleHeaders}`, () => {
5598
beforeEach(() => {
5699
cy.visit(`http://localhost:8080?mode=${AppMode.SingleHeaders}`);

0 commit comments

Comments
 (0)