Skip to content

Commit

Permalink
Merge pull request #529 from plotly/copy-paste-headers
Browse files Browse the repository at this point in the history
Include hideable mode on copy-paste test
  • Loading branch information
alinastarkov committed Aug 5, 2019
1 parent 7e8c0be commit 4eabde8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/dash-table/tests/cypress/dash/v_copy_paste.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
id="table",
data=df[0:250],
columns=[
{"id": 0, "name": "Complaint ID"},
{"id": 0, "name": "Complaint ID", "hideable": True},
{"id": 1, "name": "Product"},
{"id": 2, "name": "Sub-product"},
{"id": 3, "name": "Issue"},
Expand All @@ -47,12 +47,14 @@
],
editable=True,
sort_action='native',
include_headers_on_copy_paste=True,

),
dash_table.DataTable(
id="table2",
data=df[0:10],
columns=[
{"id": 0, "name": "Complaint ID"},
{"id": 0, "name": "Complaint ID", "hideable": True},
{"id": 1, "name": "Product"},
{"id": 2, "name": "Sub-product"},
{"id": 3, "name": "Issue"},
Expand All @@ -69,6 +71,7 @@
],
editable=True,
sort_action='native',
include_headers_on_copy_paste=True,
),
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('copy paste', () => {
DashTable.getCell(14, 0).click();
DOM.focused.type(Key.Shift, { release: false });

for (let row = 9; row <= 13; ++row) {
for (let row = 10; row <= 13; ++row) {
for (let column = 0; column <= 3; ++column) {
let initialValue: string;

Expand All @@ -79,6 +79,58 @@ describe('copy paste', () => {
}
});

describe('copy and paste with hideable columns', () => {
it('copy multiple rows and columns within table', () => {
DashTable.hideColumnById(0, '0');

DashTable.getCell(0, 0).click();
DOM.focused.type(Key.Shift, { release: false });
DashTable.getCell(2, 2).click();

DOM.focused.type(`${Key.Meta}c`);
DashTable.getCell(3, 1).click();
DOM.focused.type(`${Key.Meta}v`);
DashTable.getCell(5, 3).click();

DashTable.getCell(6, 0).click();
DOM.focused.type(Key.Shift, { release: false });

for (let row = 0; row <= 2; ++row) {
for (let column = 0; column <= 2; ++column) {
let initialValue: string;

DashTable.getCell(row, column).within(() => cy.get('.dash-cell-value').then($cells => initialValue = $cells[0].innerHTML));
DashTable.getCell(row + 3, column + 1).within(() => cy.get('.dash-cell-value').should('have.html', initialValue));
}
}
});

it('copy multiple rows and columns from one table to another', () => {
DashTable.hideColumnById(0, '0');

DashTable.getCell(10, 0).click();
DOM.focused.type(Key.Shift, { release: false });
DashTable.getCell(13, 2).click();

DOM.focused.type(`${Key.Meta}c`);
cy.get(`#table2 tbody tr td.column-${0}`).eq(0).click();
DOM.focused.type(`${Key.Meta}v`);
cy.get(`#table2 tbody tr td.column-${3}`).eq(2).click();

DashTable.getCell(16, 6).click();
DOM.focused.type(Key.Shift, { release: false });

for (let row = 10; row <= 13; ++row) {
for (let column = 0; column <= 2; ++column) {
let initialValue: string;

DashTable.getCell(row, column).within(() => cy.get('.dash-cell-value').then($cells => initialValue = $cells[0].innerHTML));
cy.get(`#table2 tbody tr td.column-${column}`).eq(row - 10).within(() => cy.get('.dash-cell-value').should('have.html', initialValue));
}
}
});
});

// Commenting this test as Cypress team is having issues with the copy/paste scenario
// LINK: https://github.com/cypress-io/cypress/issues/2386
describe('BE roundtrip on copy-paste', () => {
Expand Down

0 comments on commit 4eabde8

Please sign in to comment.