Skip to content

Commit

Permalink
fix(core): grid service resetGrid method wasn't always resetting
Browse files Browse the repository at this point in the history
- add E2E tests for the real fix that was applied in Slickgrid-Universal [PR](ghiscoding/slickgrid-universal#829)
  • Loading branch information
ghiscoding committed Dec 1, 2022
1 parent 4efaaa5 commit a5bf5f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/examples/grid-state.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class GridStateComponent implements OnInit, OnDestroy {

/** Clear the Grid State from Local Storage and reset the grid to it's original state */
clearGridStateFromLocalStorage() {
localStorage[LOCAL_STORAGE_KEY] = null;
localStorage.removeItem(LOCAL_STORAGE_KEY);
this.angularGrid.gridService.resetGrid(this.columnDefinitions);
this.angularGrid.paginationService!.changeItemPerPage(DEFAULT_PAGE_SIZE);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export class GridStateComponent implements OnInit, OnDestroy {

getData(count: number) {
// mock a dataset
const tmpData = [];
const tmpData: any[] = [];
for (let i = 0; i < count; i++) {
const randomDuration = Math.round(Math.random() * 100);
const randomYear = randomBetween(2000, 2025);
Expand Down
12 changes: 12 additions & 0 deletions test/cypress/e2e/example16.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,16 @@ describe('Example 16: Grid State & Presets using Local Storage', { retries: 1 },
cy.get('.grid-canvas-left > [style="top:0px"]').children().should('have.length', 2);
cy.get('.grid-canvas-right > [style="top:0px"]').children().should('have.length', 3);
});

it('should click on the reset button and have exact Column Titles position as in beginning', () => {
cy.get('#slickGridContainer-grid16').as('grid16');

cy.get('[data-test="reset-button"]')
.click();

cy.get('@grid16')
.find('.slick-header-columns')
.children()
.each(($child, index) => expect($child.text()).to.eq(fullEnglishTitles[index]));
});
});

0 comments on commit a5bf5f1

Please sign in to comment.