Skip to content

Commit

Permalink
console: more tests (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
aswinmprabhu authored and shahidhk committed Jul 4, 2018
1 parent a2a85b8 commit 2cab15e
Show file tree
Hide file tree
Showing 25 changed files with 3,285 additions and 3,539 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm-debug.log
15 changes: 8 additions & 7 deletions console/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ To run the tests for the modules individually (say for create table),

- Go to the `cypress.json` and set the `env > TEST_MODE` variable to `ui`.

```
{
"env": {
"TEST_MODE": "ui"
}
}
```

```
{
"env": {
"TEST_MODE": "ui"
}
}
```

- Run the command `npm run cypress` and click on `create-tabel > test.js`
47 changes: 16 additions & 31 deletions console/cypress/integration/data/create-table/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { setMetaData, validateCT } from '../../validators/validators';

export const checkCreateTableRoute = () => {
// Click on the create table button
cy.get('button')
.contains('Create Table')
.click();
cy.visit('/data/schema');
cy.wait(15000);
cy.get(getElementFromAlias('data-create-table')).click();
// Match the URL
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
};
Expand All @@ -19,11 +19,10 @@ export const failCTWithoutColumns = () => {
// Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Click on create
cy.get('button')
.contains('Create')
.click();
cy.get(getElementFromAlias('table-create')).click();
// Check for an error
cy.get('div').contains('Column name cannot be empty');
// cy.get('div').contains('Column name cannot be empty');
cy.get('.notification-error');
// Check if the route didn't change
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
// Validate
Expand All @@ -35,13 +34,9 @@ export const failCTWithoutPK = () => {
cy.get(getElementFromAlias('column-0')).type(getColName(0));
cy.get(getElementFromAlias('col-type-0')).select('serial');
// Click on create
cy.get('button')
.contains('Create')
.click();
cy.get(getElementFromAlias('table-create')).click();
// Check for an error
cy.get('div').contains(
'You should have atleast one column as a primary key.'
);
cy.get('.notification-error');
// Check if the route didn't change
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
// Validate
Expand All @@ -55,9 +50,7 @@ export const failCTDuplicateColumns = () => {
// Set primary key
cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create
cy.get('button')
.contains('Create')
.click();
cy.get(getElementFromAlias('table-create')).click();
// Check for an alert
cy.on('window:alert', str => {
expect(
Expand All @@ -80,7 +73,7 @@ export const passCT = () => {
cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create
cy.get(getElementFromAlias('table-create')).click();
cy.wait(7000);
cy.wait(10000);
// Check if the table got created and navigatied to modify table
cy.url().should(
'eq',
Expand All @@ -93,9 +86,7 @@ export const passCT = () => {

export const failCTDuplicateTable = () => {
// Visit data page
cy.get('button')
.contains('Add Table')
.click();
cy.get(getElementFromAlias('sidebar-add-table')).click();
// Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Set column
Expand All @@ -104,24 +95,18 @@ export const failCTDuplicateTable = () => {
// Set primary key
cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create
cy.get('button')
.contains('Create')
.click();
cy.wait(5000);
cy.get(getElementFromAlias('table-create')).click();
cy.wait(7000);
// Detect error
cy.get('div').contains('Create table failed');
cy.get('.notification-error');
};

export const deleteCTTestTable = () => {
// Go to the modify section of the table
cy.get('a')
.contains(`${getTableName(0)}`)
.click();
cy.get(getElementFromAlias(`${getTableName(0)}`)).click();
cy.get(getElementFromAlias('table-modify')).click();
// Click on delete
cy.get('button')
.contains('Delete table')
.click();
cy.get(getElementFromAlias('delete-table')).click();
// Confirm
cy.on('window:confirm', str => {
expect(str === 'Are you sure?').to.be.true;
Expand Down
115 changes: 52 additions & 63 deletions console/cypress/integration/data/insert-browse/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ const setColumns = () => {

const clickSaveOrInsert = (firstIndex, currentIndex) => {
if (currentIndex === firstIndex) {
cy.get('button')
.contains('Save')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();
} else {
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();
}
cy.wait(2000);
};
Expand Down Expand Up @@ -95,9 +91,7 @@ const checkOrder = order => {
export const passBICreateTable = () => {
cy.wait(7000);
// Click create table button
cy.get('button')
.contains('Create Table')
.click();
cy.get(getElementFromAlias('data-create-table')).click();
// Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Set columns with all fields
Expand All @@ -112,9 +106,7 @@ export const passBICreateTable = () => {

export const checkInsertRoute = () => {
// Click on Insert tab
cy.get('a')
.contains(getTableName(0))
.click();
cy.get(getElementFromAlias(getTableName(0))).click();
cy.get(getElementFromAlias('table-insert-rows')).click();
// Match URL
cy.url().should(
Expand All @@ -134,10 +126,11 @@ export const failBIWrongDataType = () => {
// Click the Save/Insert Again button.
clickSaveOrInsert(2, i);
// Check for error and dismiss it
cy.get('[class=notification-title]')
.contains('Insert failed')
.click();
// Check the default radio of current column
// cy.get('[class=notification-title]')
// .contains('Insert failed')
// .click();
cy.get('.notification-error').click();
// Check the default radio of curret column
cy.get(getElementFromAlias(`typed-input-default-${i}`)).check();
}

Expand All @@ -157,9 +150,7 @@ export const passBIInsert20Rows = () => {
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type(
'filter-text'
);
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();
continue; // eslint-disable-line
}
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type(
Expand All @@ -172,9 +163,7 @@ export const passBIInsert20Rows = () => {
.toString(36)
.substring(7)
);
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();
validateInsert(getTableName(0), i + 1);
}
// Wait for insert notifications to disappear
Expand All @@ -183,9 +172,7 @@ export const passBIInsert20Rows = () => {

export const checkBrowseRoute = () => {
// Click on Browse tab
cy.get('a')
.contains(getTableName(0))
.click();
cy.get(getElementFromAlias(getTableName(0))).click();
cy.get(getElementFromAlias('table-browse-rows')).click();
cy.wait(2000);
// Match URL
Expand All @@ -198,7 +185,30 @@ export const checkBrowseRoute = () => {
export const passBI20RowsExist = () => {
// Check if the 20 inserted elements reflect in the UI
cy.get(getElementFromAlias('table-browse-rows')).contains('21');
// Check pagination string
};

export const checkPagination = () => {
// Check if the current page is 1
cy.get('.-pageJump > input').should('have.value', '1');
// Check if the total number of pages is 3
cy.get('.-totalPages').contains('3');
// Check if the default value of rows displayed is 10
cy.get('.-pageSizeOptions > select').should('have.value', '10');
cy.get('.-next > button').click();
cy.wait(3000);
// Check if the page changed
cy.get(
'.rt-tbody > div:nth-child(1) > div > div:nth-child(2) > div'
).contains('11');
cy.get('.-pageJump > input').should('have.value', '2');
cy.get('.-previous > button').click();
cy.wait(3000);
// Check if the page changed
cy.get('.-pageJump > input').should('have.value', '1');
cy.get('.-pageSizeOptions > select').select('5 rows');
cy.wait(3000);
// Check if the total number of pages changed
cy.get('.-totalPages').contains('5');
};

export const passBISort = order => {
Expand All @@ -213,19 +223,15 @@ export const passBISort = order => {
order === 'asc' ? 'Asc' : 'Desc'
);
// Run query
cy.get('button')
.contains('Run query')
.click();
cy.get(getElementFromAlias('run-query')).click();
cy.wait(5000);
// Check order
checkOrder(order);

// Clear filter
cy.get(getElementFromAlias('clear-sorts-0')).click();
// Run query
cy.get('button')
.contains('Run query')
.click();
cy.get(getElementFromAlias('run-query')).click();
cy.wait(5000);
};

Expand All @@ -240,19 +246,15 @@ export const passBIFilterQueryEq = () => {
.last()
.type('filter-text');
// Run query
cy.get('button')
.contains('Run query')
.click();
cy.get(getElementFromAlias('run-query')).click();
cy.wait(2000);
// Check if the query was successful
checkQuerySuccess();

// Clear filter
cy.get(getElementFromAlias('clear-filter-0')).click();
// Run query
cy.get('button')
.contains('Run query')
.click();
cy.get(getElementFromAlias('run-query')).click();
cy.wait(5000);
};

Expand All @@ -261,9 +263,7 @@ export const deleteBITestTable = () => {
cy.get(getElementFromAlias('table-modify')).click();
cy.wait(2000);
// Click on delete
cy.get('button')
.contains('Delete table')
.click();
cy.get(getElementFromAlias('delete-table')).click();
// Confirm
cy.on('window:confirm', str => {
expect(str === 'Are you sure?').to.be.true;
Expand All @@ -287,13 +287,9 @@ export const failBINullKeys = () => {
.type('{selectall}{del}');

// Click the Insert Again button.
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();

cy.get('[class=notification-title]')
.contains('Insert failed')
.click();
cy.get('.notification-error').click();
// Wait for insert notifications to disappear
cy.wait(7000);
validateInsert(getTableName(0), 20);
Expand All @@ -317,9 +313,7 @@ export const failBIUniqueKeys = () => {
cy.get('input[placeholder="text"]')
.first()
.type('name');
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();
// Check default for next insert

cy.get(getElementFromAlias(`typed-input-default-${textIndex}`)).check();
Expand All @@ -336,13 +330,9 @@ export const failBIUniqueKeys = () => {
cy.get('input[placeholder="text"]')
.first()
.type('name');
cy.get('button')
.contains('Insert Again')
.click();
cy.get(getElementFromAlias('insert-save-button')).click();

cy.get('[class=notification-title]')
.contains('Insert failed')
.click();
cy.get('.notification-error').click();
cy.wait(7000);
validateInsert(getTableName(0), 21);
};
Expand All @@ -365,11 +355,10 @@ export const passEditButton = () => {
'{selectall}{del}'
);
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type('new-text');
cy.get('button')
.contains('Save')
.last()
.click();
cy.get('h4').contains('Edited!', { timeout: 7000 });
cy.get(getElementFromAlias('save-button')).click();
// cy.get('h4').contains('Edited!', { timeout: 7000 });
cy.get('.notification-success');
cy.wait(7000);
};

export const passCloneButton = () => {
Expand All @@ -389,6 +378,6 @@ export const passDeleteRow = () => {
cy.on('window:confirm', str => {
expect(str === 'Permanently delete this row?').to.be.true;
});
cy.get('h4').contains('Row deleted!', { timeout: 7000 });
cy.wait(7000);
cy.get('.notification-success');
cy.wait(14000);
};
2 changes: 2 additions & 0 deletions console/cypress/integration/data/insert-browse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
passBIInsert20Rows,
checkBrowseRoute,
passBI20RowsExist,
checkPagination,
passBISort,
passBIFilterQueryEq,
passEditButton,
Expand Down Expand Up @@ -42,6 +43,7 @@ export const runInsertBrowseTests = () => {
it('Fail for adding same data for Unique keys', failBIUniqueKeys);
it('Check browser rows route', checkBrowseRoute);
it('20 Inserted rows reflect in browse rows', passBI20RowsExist);
it('Check pagination in Browse Rows table', checkPagination);
it('Ascending sort works as expected', () => passBISort('asc'));
it('Descending sort works as expected', () => passBISort('desc'));
it('FIlter query works as expected with $eq', passBIFilterQueryEq);
Expand Down
Loading

0 comments on commit 2cab15e

Please sign in to comment.