Skip to content

Commit

Permalink
Adds missing tests after v8 release (#7354)
Browse files Browse the repository at this point in the history
* #7171 - Adds missing test for #4303

* #7171 - Removes unnecessary E2E test file for hiddenColumns

* #7171 - Adds missing test case for #5207

* #7171 - Adds missing test cases for #3978

* #7171 - Fixes lint errors

* #7171 - Adds missing test cases for #7043

* #7171 - Adds missing test cases for #5000

* #7171 - Adds missing test cases for #5906

* Adds missing tests for #4897

* Changed test for #4897 so thay they only pass in version 8+

* Fixes tests for #4897

* #7171 - Adjustment missing test cases for #4897

* #7171 - Adds missing tests for #6670 and a missing legend for header selection symbols

* #7171 - Adjustment test cases of ##4897 for eslint

* #7171 - Adds missing tests for #7099

* #7171 - Fix linter errors in tests for #7099

* #7171 - Adds missing tests to #7095

* #7171 - Adds missing test cases for #7097

* #7171 - Adds missing expect to tests for #7095

* #7171 - Adds missing test for #6843

* #7171 - Adds missing tests for #7076

* #7171 - Adds missing tests for #6435

* #7171 - Adds missing tests for #3726

* #7171 - Adds missing test cases for #5849

* #7171 - Adds missing tests for #4154

* #7171 - Adjustment on test cases for #5849

* #7171 - Adds missing tests for #6433

* #7171 - Adds missing test cases for #6355

* Fix typo in comment

* #7171 - Adds missing tests for #6386

* #7171 - Adds missing tests for #6831

* #7171 - Adds missing tests for #6363

* #7171 - Adds missing tests for #4999

* #7171 - Adds missing tests for #6426

* #7171 - Adds missing tests for #6113

* #7171 - Adds missing tests for #6412

* #7171 - Adds missing tests for #6310

* #7171 - Adds missing test cases for #5877

* #7171 - Adds missing test for #5824

* #7171 - Adds missing tests for #4713

* #7171 - Adds missing tests for #4576

* #7171 - Changes spec description for #4576

* #7171 - Adds missing test cases for #4601

* #7171 - Adjustment on test cases for #4601

* #7171 - Reverts added tests for #5824 due to a bug #7355

* #7171 - Adds comment with @todo after removing ObserveChanges

Co-authored-by: ndemytruk <ndemytruk@gmail.com>
  • Loading branch information
swistach and aninde committed Oct 29, 2020
1 parent 3250f30 commit dac8f5e
Show file tree
Hide file tree
Showing 28 changed files with 817 additions and 6,607 deletions.
22 changes: 22 additions & 0 deletions src/plugins/collapsibleColumns/test/collapsibleColumns.e2e.js
Expand Up @@ -4454,4 +4454,26 @@ describe('CollapsibleColumns', () => {
`);
});
});

describe('integration', () => {
describe('columnSorting', () => {
it('should collapse all columns', () => {
handsontable({
data: Handsontable.helper.createSpreadsheetData(1, 4),
colHeaders: true,
nestedHeaders: [
['A', { label: 'B', colspan: 2 }, 'C'],
['N', 'O', 'P', 'Q']
],
collapsibleColumns: true,
columnSorting: true,
});

getPlugin('collapsibleColumns').collapseAll();

expect(countVisibleCols()).toBe(3);
expect(getCell(-1, 2)).toBeNull();
});
});
});
});
49 changes: 49 additions & 0 deletions src/plugins/columnSorting/test/columnSorting.e2e.js
Expand Up @@ -2683,5 +2683,54 @@ describe('ColumnSorting', () => {

expect(onErrorSpy).not.toHaveBeenCalled();
});

it('should not break the ability to freeze column', () => {
const hot = handsontable({
data: Handsontable.helper.createSpreadsheetData(1, 3),
fixedColumnsLeft: 1,
columnSorting: true,
manualColumnFreeze: true,
contextMenu: true
});

hot.selectCell(0, 2);
contextMenu();

const freezeColumn = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function() {
return $(this).text() === 'Freeze column';
});
simulateClick(freezeColumn);

expect(hot.getSettings().fixedColumnsLeft).toEqual(2);
expect(hot.toPhysicalColumn(0)).toEqual(0);
expect(hot.toPhysicalColumn(1)).toEqual(2);
expect(hot.toPhysicalColumn(2)).toEqual(1);
expect(hot.getData()).toEqual([['A1', 'C1', 'B1']]);
});
});

describe('compatibility with options', () => {
it('should not break virtual rendering if preventOverflow is used', async() => {
spec().$container.css({
height: 'auto',
width: 'auto',
overflow: 'visible'
});

handsontable({
data: Handsontable.helper.createSpreadsheetData(100, 1),
columnSorting: true,
preventOverflow: 'horizontal',
});

$(window).scrollTop(3000);

await sleep(500);

const wtSpreader = spec().$container.find('.ht_master .wtSpreader');
const cssTop = parseInt(wtSpreader.css('top'), 10);

expect(cssTop).toBeGreaterThan(0);
});
});
});
21 changes: 21 additions & 0 deletions src/plugins/contextMenu/test/contextMenu.e2e.js
Expand Up @@ -3383,6 +3383,27 @@ describe('ContextMenu', () => {
expect($('.htContextMenu').is(':visible')).toBe(true);
expect(getSelected()).toEqual([[0, 0, 2, 2], [2, 2, 7, 2], [2, 4, 2, 4]]);
});

it('should properly change selection on right click on headers', () => {
const hot = handsontable({
data: createSpreadsheetData(2, 2),
contextMenu: true,
colHeaders: true,
rowHeaders: true,
});

selectCell(0, 0);
contextMenu(getCell(-1, 0));

expect(getSelected()).toEqual([[-1, 0, 1, 0]]);
expect(hot.selection.isEntireColumnSelected()).toBe(true);

selectCell(1, 0);
contextMenu(getCell(1, -1));

expect(getSelected()).toEqual([[1, -1, 1, 1]]);
expect(hot.selection.isEntireRowSelected()).toBe(true);
});
});

describe('working with multiple tables', () => {
Expand Down
40 changes: 40 additions & 0 deletions src/plugins/hiddenColumns/test/contextMenu/showColumn.e2e.js
@@ -1,5 +1,6 @@
describe('ContextMenu', () => {
const id = 'testContainer';
const SHOW_COLUMNS_CM_ID = 'hidden_columns_show';
const getShowColumnCMElement = () => $('.htContextMenu tbody td').not('.htSeparator').filter(
(i, item) => {
return $(item).text().toLowerCase().includes('show column');
Expand Down Expand Up @@ -64,5 +65,44 @@ describe('ContextMenu', () => {

expect(compatibleEntries.size()).toEqual(1);
});

it('should show the entry for "Show column" if the last column is hidden and columns\' array ' +
'is shorter than a number of datarow\'s keys', () => {
handsontable({
data: Handsontable.helper.createSpreadsheetObjectData(1, 3),
colHeaders: true,
contextMenu: [SHOW_COLUMNS_CM_ID],
hiddenColumns: {
columns: [1],
},
columns: [{}, {}],
});

const { CONTEXTMENU_ITEMS_SHOW_COLUMN } = Handsontable.languages.dictionaryKeys;
const expectedText = Handsontable.languages.getTranslatedPhrase('en-US', CONTEXTMENU_ITEMS_SHOW_COLUMN);

contextMenu(getCell(-1, 0));

expect($('.htContextMenu tbody td').text()).toBe(expectedText);
});

it('should show the entry for "Show column" if all columns are hidden', () => {
handsontable({
data: Handsontable.helper.createSpreadsheetData(1, 3),
colHeaders: true,
rowHeaders: true,
contextMenu: [SHOW_COLUMNS_CM_ID],
hiddenColumns: {
columns: [0, 1, 2],
},
});

const { CONTEXTMENU_ITEMS_SHOW_COLUMN } = Handsontable.languages.dictionaryKeys;
const expectedText = Handsontable.languages.getTranslatedPhrase('en-US', CONTEXTMENU_ITEMS_SHOW_COLUMN, 1);

contextMenu(getCell(-1, -1));

expect($('.htContextMenu tbody td').text()).toBe(expectedText);
});
});
});

0 comments on commit dac8f5e

Please sign in to comment.