Basic Tests for Cell, Column and Row functionalities
This commit is contained in:
parent
4a8cdd0362
commit
c387c649a5
@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
{
|
||||
"id": 8739,
|
||||
"name": "Jane",
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
@ -1,232 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Leanne Graham",
|
||||
"username": "Bret",
|
||||
"email": "Sincere@april.biz",
|
||||
"address": {
|
||||
"street": "Kulas Light",
|
||||
"suite": "Apt. 556",
|
||||
"city": "Gwenborough",
|
||||
"zipcode": "92998-3874",
|
||||
"geo": {
|
||||
"lat": "-37.3159",
|
||||
"lng": "81.1496"
|
||||
}
|
||||
},
|
||||
"phone": "1-770-736-8031 x56442",
|
||||
"website": "hildegard.org",
|
||||
"company": {
|
||||
"name": "Romaguera-Crona",
|
||||
"catchPhrase": "Multi-layered client-server neural-net",
|
||||
"bs": "harness real-time e-markets"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Ervin Howell",
|
||||
"username": "Antonette",
|
||||
"email": "Shanna@melissa.tv",
|
||||
"address": {
|
||||
"street": "Victor Plains",
|
||||
"suite": "Suite 879",
|
||||
"city": "Wisokyburgh",
|
||||
"zipcode": "90566-7771",
|
||||
"geo": {
|
||||
"lat": "-43.9509",
|
||||
"lng": "-34.4618"
|
||||
}
|
||||
},
|
||||
"phone": "010-692-6593 x09125",
|
||||
"website": "anastasia.net",
|
||||
"company": {
|
||||
"name": "Deckow-Crist",
|
||||
"catchPhrase": "Proactive didactic contingency",
|
||||
"bs": "synergize scalable supply-chains"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Clementine Bauch",
|
||||
"username": "Samantha",
|
||||
"email": "Nathan@yesenia.net",
|
||||
"address": {
|
||||
"street": "Douglas Extension",
|
||||
"suite": "Suite 847",
|
||||
"city": "McKenziehaven",
|
||||
"zipcode": "59590-4157",
|
||||
"geo": {
|
||||
"lat": "-68.6102",
|
||||
"lng": "-47.0653"
|
||||
}
|
||||
},
|
||||
"phone": "1-463-123-4447",
|
||||
"website": "ramiro.info",
|
||||
"company": {
|
||||
"name": "Romaguera-Jacobson",
|
||||
"catchPhrase": "Face to face bifurcated interface",
|
||||
"bs": "e-enable strategic applications"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Patricia Lebsack",
|
||||
"username": "Karianne",
|
||||
"email": "Julianne.OConner@kory.org",
|
||||
"address": {
|
||||
"street": "Hoeger Mall",
|
||||
"suite": "Apt. 692",
|
||||
"city": "South Elvis",
|
||||
"zipcode": "53919-4257",
|
||||
"geo": {
|
||||
"lat": "29.4572",
|
||||
"lng": "-164.2990"
|
||||
}
|
||||
},
|
||||
"phone": "493-170-9623 x156",
|
||||
"website": "kale.biz",
|
||||
"company": {
|
||||
"name": "Robel-Corkery",
|
||||
"catchPhrase": "Multi-tiered zero tolerance productivity",
|
||||
"bs": "transition cutting-edge web services"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Chelsey Dietrich",
|
||||
"username": "Kamren",
|
||||
"email": "Lucio_Hettinger@annie.ca",
|
||||
"address": {
|
||||
"street": "Skiles Walks",
|
||||
"suite": "Suite 351",
|
||||
"city": "Roscoeview",
|
||||
"zipcode": "33263",
|
||||
"geo": {
|
||||
"lat": "-31.8129",
|
||||
"lng": "62.5342"
|
||||
}
|
||||
},
|
||||
"phone": "(254)954-1289",
|
||||
"website": "demarco.info",
|
||||
"company": {
|
||||
"name": "Keebler LLC",
|
||||
"catchPhrase": "User-centric fault-tolerant solution",
|
||||
"bs": "revolutionize end-to-end systems"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Mrs. Dennis Schulist",
|
||||
"username": "Leopoldo_Corkery",
|
||||
"email": "Karley_Dach@jasper.info",
|
||||
"address": {
|
||||
"street": "Norberto Crossing",
|
||||
"suite": "Apt. 950",
|
||||
"city": "South Christy",
|
||||
"zipcode": "23505-1337",
|
||||
"geo": {
|
||||
"lat": "-71.4197",
|
||||
"lng": "71.7478"
|
||||
}
|
||||
},
|
||||
"phone": "1-477-935-8478 x6430",
|
||||
"website": "ola.org",
|
||||
"company": {
|
||||
"name": "Considine-Lockman",
|
||||
"catchPhrase": "Synchronised bottom-line interface",
|
||||
"bs": "e-enable innovative applications"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Kurtis Weissnat",
|
||||
"username": "Elwyn.Skiles",
|
||||
"email": "Telly.Hoeger@billy.biz",
|
||||
"address": {
|
||||
"street": "Rex Trail",
|
||||
"suite": "Suite 280",
|
||||
"city": "Howemouth",
|
||||
"zipcode": "58804-1099",
|
||||
"geo": {
|
||||
"lat": "24.8918",
|
||||
"lng": "21.8984"
|
||||
}
|
||||
},
|
||||
"phone": "210.067.6132",
|
||||
"website": "elvis.io",
|
||||
"company": {
|
||||
"name": "Johns Group",
|
||||
"catchPhrase": "Configurable multimedia task-force",
|
||||
"bs": "generate enterprise e-tailers"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Nicholas Runolfsdottir V",
|
||||
"username": "Maxime_Nienow",
|
||||
"email": "Sherwood@rosamond.me",
|
||||
"address": {
|
||||
"street": "Ellsworth Summit",
|
||||
"suite": "Suite 729",
|
||||
"city": "Aliyaview",
|
||||
"zipcode": "45169",
|
||||
"geo": {
|
||||
"lat": "-14.3990",
|
||||
"lng": "-120.7677"
|
||||
}
|
||||
},
|
||||
"phone": "586.493.6943 x140",
|
||||
"website": "jacynthe.com",
|
||||
"company": {
|
||||
"name": "Abernathy Group",
|
||||
"catchPhrase": "Implemented secondary concept",
|
||||
"bs": "e-enable extensible e-tailers"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Glenna Reichert",
|
||||
"username": "Delphine",
|
||||
"email": "Chaim_McDermott@dana.io",
|
||||
"address": {
|
||||
"street": "Dayna Park",
|
||||
"suite": "Suite 449",
|
||||
"city": "Bartholomebury",
|
||||
"zipcode": "76495-3109",
|
||||
"geo": {
|
||||
"lat": "24.6463",
|
||||
"lng": "-168.8889"
|
||||
}
|
||||
},
|
||||
"phone": "(775)976-6794 x41206",
|
||||
"website": "conrad.com",
|
||||
"company": {
|
||||
"name": "Yost and Sons",
|
||||
"catchPhrase": "Switchable contextually-based project",
|
||||
"bs": "aggregate real-time technologies"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Clementina DuBuque",
|
||||
"username": "Moriah.Stanton",
|
||||
"email": "Rey.Padberg@karina.biz",
|
||||
"address": {
|
||||
"street": "Kattie Turnpike",
|
||||
"suite": "Suite 198",
|
||||
"city": "Lebsackbury",
|
||||
"zipcode": "31428-2261",
|
||||
"geo": {
|
||||
"lat": "-38.2386",
|
||||
"lng": "57.2232"
|
||||
}
|
||||
},
|
||||
"phone": "024-648-3804",
|
||||
"website": "ambrose.net",
|
||||
"company": {
|
||||
"name": "Hoeger LLC",
|
||||
"catchPhrase": "Centralized empowering task-force",
|
||||
"bs": "target end-to-end models"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -1,22 +0,0 @@
|
||||
/* globals DataTable */
|
||||
|
||||
describe('Datatable Initialization', function () {
|
||||
it('Initializes datatable correctly', () => {
|
||||
cy.visit('/');
|
||||
|
||||
cy.window()
|
||||
.its('DataTable')
|
||||
.then(DataTable => {
|
||||
const datatable2 = new DataTable('#datatable2', {
|
||||
columns: ['Name', 'Position'],
|
||||
data: [
|
||||
// ['Faris', 'Developer']
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
cy.get('#datatable2 .datatable')
|
||||
.contains('No Data');
|
||||
|
||||
});
|
||||
});
|
||||
183
cypress/integration/datatable_spec.js
Normal file
183
cypress/integration/datatable_spec.js
Normal file
@ -0,0 +1,183 @@
|
||||
describe('DataTable', function () {
|
||||
it('instance is created without any errors', () => {
|
||||
cy.visit('/');
|
||||
|
||||
cy.window()
|
||||
.its('DataTable')
|
||||
.then(DataTable => {
|
||||
// eslint-disable-next-line
|
||||
new DataTable('#datatable2', {
|
||||
columns: ['Name', 'Position'],
|
||||
data: [
|
||||
['Faris', 'Developer']
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
cy.get('#datatable2 .datatable')
|
||||
.contains('Faris');
|
||||
});
|
||||
|
||||
describe('Cell', function () {
|
||||
before(function () {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
it('focuses cell on click', function () {
|
||||
cy.clickCell(2, 0)
|
||||
.should('have.class', 'dt-cell--focus');
|
||||
});
|
||||
|
||||
it('not focuses cell which are not focusable', function () {
|
||||
cy.clickCell(1, 0)
|
||||
.should('not.have.class', 'dt-cell--focus');
|
||||
});
|
||||
|
||||
it('edit cell on enter press', function () {
|
||||
cy.getCell(4, 0).type('{enter}')
|
||||
.should('have.class', 'dt-cell--editing')
|
||||
.type('{enter}')
|
||||
.should('not.have.class', 'dt-cell--editing');
|
||||
|
||||
// cy.focused()
|
||||
// .type('{selectall}{del}')
|
||||
// .wait(20)
|
||||
// .type('Test{enter}');
|
||||
|
||||
// cy.getCell(4, 0).contains('Test');
|
||||
});
|
||||
|
||||
it('edit cell on double click', function () {
|
||||
cy.getCell(4, 0)
|
||||
.as('target')
|
||||
.dblclick({ force: true })
|
||||
.should('have.class', 'dt-cell--editing');
|
||||
|
||||
cy.clickCell(3, 0);
|
||||
|
||||
cy.get('@target').should('not.have.class', 'dt-cell--editing');
|
||||
});
|
||||
|
||||
it('edit cell', function () {
|
||||
|
||||
cy.getCell(4, 1).dblclick();
|
||||
|
||||
cy.wait(100);
|
||||
|
||||
cy.focused()
|
||||
.type('{selectall}')
|
||||
.wait(100)
|
||||
.type('{del}')
|
||||
.wait(100)
|
||||
.type('Test')
|
||||
.wait(100)
|
||||
.type('{enter}');
|
||||
|
||||
cy.getCell(4, 1).contains('Test');
|
||||
});
|
||||
|
||||
it('if editing is false: editing should not activate', function () {
|
||||
cy.getCell(3, 0).dblclick({ force: true })
|
||||
.should('not.have.class', 'dt-cell--editing');
|
||||
});
|
||||
|
||||
it('navigation using arrow keys', function () {
|
||||
cy.clickCell(2, 0)
|
||||
.type('{rightarrow}');
|
||||
|
||||
cy.get('.dt-cell--focus')
|
||||
.should('have.class', 'dt-cell--3-0')
|
||||
.click({ force: true })
|
||||
.type('{downarrow}');
|
||||
|
||||
cy.get('.dt-cell--focus')
|
||||
.should('have.class', 'dt-cell--3-1');
|
||||
// TODO: test navigation over hidden rows
|
||||
});
|
||||
|
||||
it('navigation using ctrl + arrow keys', function () {
|
||||
cy.clickCell(2, 0)
|
||||
.type('{ctrl}{rightarrow}');
|
||||
cy.get('.dt-cell--focus')
|
||||
.should('have.class', 'dt-cell--7-0');
|
||||
});
|
||||
|
||||
it('cell selection using shift + arrow keys', function () {
|
||||
cy.getCell(2, 1)
|
||||
.type('{shift}{rightarrow}{rightarrow}{downarrow}');
|
||||
|
||||
// 6 cells and 2 headers
|
||||
cy.get('.dt-cell--highlight').should('have.length', 6 + 2);
|
||||
|
||||
cy.clickCell(2, 0);
|
||||
});
|
||||
|
||||
it('mouse selection', function () {
|
||||
// TODO
|
||||
// cy.getCell(2, 1)
|
||||
// .trigger('mousedown', { which: 1, pageX: 331, pageY: 207, force: true })
|
||||
// .trigger('mousemove', { which: 1, pageX: 489, pageY: 312 })
|
||||
// .trigger('mouseup');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Column', function () {
|
||||
before(function () {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
it('header dropdown toggles on click', function () {
|
||||
cy.getColumnCell(2)
|
||||
.find('.dt-dropdown__toggle')
|
||||
.as('toggle')
|
||||
.click();
|
||||
cy.getColumnCell(2)
|
||||
.find('.dt-dropdown__list')
|
||||
.as('dropdown-list')
|
||||
.should('be.visible');
|
||||
|
||||
cy.get('@toggle').click();
|
||||
|
||||
cy.get('@dropdown-list').should('not.be.visible');
|
||||
});
|
||||
|
||||
it('sort ascending button should work', function () {
|
||||
cy.clickDropdown(2);
|
||||
cy.clickDropdownItem(2, 'Sort Ascending');
|
||||
|
||||
cy.window().then(win => win.datatable.getColumn(2))
|
||||
.its('sortOrder')
|
||||
.should('eq', 'asc');
|
||||
|
||||
cy.window().then(win => win.datatable.datamanager)
|
||||
.its('currentSort.colIndex')
|
||||
.should('eq', 2);
|
||||
|
||||
cy.get('.dt-body .dt-row:first')
|
||||
.contains('Airi Satou');
|
||||
|
||||
cy.clickDropdownItem(2, 'Reset sorting');
|
||||
});
|
||||
|
||||
it('removes column using dropdown action', function () {
|
||||
cy.get('.dt-cell--header').should('have.length', 8);
|
||||
|
||||
cy.clickDropdown(5);
|
||||
cy.clickDropdownItem(5, 'Remove column');
|
||||
|
||||
cy.get('.dt-cell--header').should('have.length', 7);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Row', function () {
|
||||
it('check / uncheck row', function () {
|
||||
cy.get('.dt-body .dt-row:first')
|
||||
.find('input[type="checkbox"]')
|
||||
.click();
|
||||
|
||||
cy.get('[data-row-index="0"]').should('have.class', 'dt-row--highlight');
|
||||
|
||||
cy.get('.dt-toast').contains('1 row selected');
|
||||
});
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,17 +0,0 @@
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 318 KiB |
@ -23,3 +23,27 @@
|
||||
//
|
||||
// -- This is will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
|
||||
Cypress.Commands.add('getCell', (col, row) => {
|
||||
return cy.get(`.dt-cell--${col}-${row}`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickCell', (col, row) => {
|
||||
return cy.getCell(col, row).click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add('getColumnCell', (col) => {
|
||||
return cy.get(`.dt-cell--header-${col}`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickDropdown', (col) => {
|
||||
return cy.getColumnCell(col)
|
||||
.find('.dt-dropdown__toggle')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickDropdownItem', (col, item) => {
|
||||
return cy.getColumnCell(col)
|
||||
.find(`.dt-dropdown__list-item:contains("${item}")`)
|
||||
.click({ force: true });
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user