console: more tests (#35)

This commit is contained in:
aswinmprabhu 2018-07-04 18:27:56 +05:30 committed by Shahidh K Muhammed
parent a2a85b8952
commit 2cab15ede4
25 changed files with 3285 additions and 3539 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
npm-debug.log

View File

@ -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`. - 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` - Run the command `npm run cypress` and click on `create-tabel > test.js`

View File

@ -8,9 +8,9 @@ import { setMetaData, validateCT } from '../../validators/validators';
export const checkCreateTableRoute = () => { export const checkCreateTableRoute = () => {
// Click on the create table button // Click on the create table button
cy.get('button') cy.visit('/data/schema');
.contains('Create Table') cy.wait(15000);
.click(); cy.get(getElementFromAlias('data-create-table')).click();
// Match the URL // Match the URL
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`); cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
}; };
@ -19,11 +19,10 @@ export const failCTWithoutColumns = () => {
// Type table name // Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0)); cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Click on create // Click on create
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create')
.click();
// Check for an error // 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 // Check if the route didn't change
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`); cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
// Validate // Validate
@ -35,13 +34,9 @@ export const failCTWithoutPK = () => {
cy.get(getElementFromAlias('column-0')).type(getColName(0)); cy.get(getElementFromAlias('column-0')).type(getColName(0));
cy.get(getElementFromAlias('col-type-0')).select('serial'); cy.get(getElementFromAlias('col-type-0')).select('serial');
// Click on create // Click on create
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create')
.click();
// Check for an error // Check for an error
cy.get('div').contains( cy.get('.notification-error');
'You should have atleast one column as a primary key.'
);
// Check if the route didn't change // Check if the route didn't change
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`); cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
// Validate // Validate
@ -55,9 +50,7 @@ export const failCTDuplicateColumns = () => {
// Set primary key // Set primary key
cy.get(getElementFromAlias('primary-key-select-0')).select('0'); cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create // Click on create
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create')
.click();
// Check for an alert // Check for an alert
cy.on('window:alert', str => { cy.on('window:alert', str => {
expect( expect(
@ -80,7 +73,7 @@ export const passCT = () => {
cy.get(getElementFromAlias('primary-key-select-0')).select('0'); cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create // Click on create
cy.get(getElementFromAlias('table-create')).click(); cy.get(getElementFromAlias('table-create')).click();
cy.wait(7000); cy.wait(10000);
// Check if the table got created and navigatied to modify table // Check if the table got created and navigatied to modify table
cy.url().should( cy.url().should(
'eq', 'eq',
@ -93,9 +86,7 @@ export const passCT = () => {
export const failCTDuplicateTable = () => { export const failCTDuplicateTable = () => {
// Visit data page // Visit data page
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
// Type table name // Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0)); cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Set column // Set column
@ -104,24 +95,18 @@ export const failCTDuplicateTable = () => {
// Set primary key // Set primary key
cy.get(getElementFromAlias('primary-key-select-0')).select('0'); cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Click on create // Click on create
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create') cy.wait(7000);
.click();
cy.wait(5000);
// Detect error // Detect error
cy.get('div').contains('Create table failed'); cy.get('.notification-error');
}; };
export const deleteCTTestTable = () => { export const deleteCTTestTable = () => {
// Go to the modify section of the table // Go to the modify section of the table
cy.get('a') cy.get(getElementFromAlias(`${getTableName(0)}`)).click();
.contains(`${getTableName(0)}`)
.click();
cy.get(getElementFromAlias('table-modify')).click(); cy.get(getElementFromAlias('table-modify')).click();
// Click on delete // Click on delete
cy.get('button') cy.get(getElementFromAlias('delete-table')).click();
.contains('Delete table')
.click();
// Confirm // Confirm
cy.on('window:confirm', str => { cy.on('window:confirm', str => {
expect(str === 'Are you sure?').to.be.true; expect(str === 'Are you sure?').to.be.true;

View File

@ -44,13 +44,9 @@ const setColumns = () => {
const clickSaveOrInsert = (firstIndex, currentIndex) => { const clickSaveOrInsert = (firstIndex, currentIndex) => {
if (currentIndex === firstIndex) { if (currentIndex === firstIndex) {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
} else { } else {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
} }
cy.wait(2000); cy.wait(2000);
}; };
@ -95,9 +91,7 @@ const checkOrder = order => {
export const passBICreateTable = () => { export const passBICreateTable = () => {
cy.wait(7000); cy.wait(7000);
// Click create table button // Click create table button
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
// Type table name // Type table name
cy.get(getElementFromAlias('tableName')).type(getTableName(0)); cy.get(getElementFromAlias('tableName')).type(getTableName(0));
// Set columns with all fields // Set columns with all fields
@ -112,9 +106,7 @@ export const passBICreateTable = () => {
export const checkInsertRoute = () => { export const checkInsertRoute = () => {
// Click on Insert tab // Click on Insert tab
cy.get('a') cy.get(getElementFromAlias(getTableName(0))).click();
.contains(getTableName(0))
.click();
cy.get(getElementFromAlias('table-insert-rows')).click(); cy.get(getElementFromAlias('table-insert-rows')).click();
// Match URL // Match URL
cy.url().should( cy.url().should(
@ -134,10 +126,11 @@ export const failBIWrongDataType = () => {
// Click the Save/Insert Again button. // Click the Save/Insert Again button.
clickSaveOrInsert(2, i); clickSaveOrInsert(2, i);
// Check for error and dismiss it // Check for error and dismiss it
cy.get('[class=notification-title]') // cy.get('[class=notification-title]')
.contains('Insert failed') // .contains('Insert failed')
.click(); // .click();
// Check the default radio of current column cy.get('.notification-error').click();
// Check the default radio of curret column
cy.get(getElementFromAlias(`typed-input-default-${i}`)).check(); cy.get(getElementFromAlias(`typed-input-default-${i}`)).check();
} }
@ -157,9 +150,7 @@ export const passBIInsert20Rows = () => {
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type( cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type(
'filter-text' 'filter-text'
); );
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
continue; // eslint-disable-line continue; // eslint-disable-line
} }
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type( cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type(
@ -172,9 +163,7 @@ export const passBIInsert20Rows = () => {
.toString(36) .toString(36)
.substring(7) .substring(7)
); );
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
validateInsert(getTableName(0), i + 1); validateInsert(getTableName(0), i + 1);
} }
// Wait for insert notifications to disappear // Wait for insert notifications to disappear
@ -183,9 +172,7 @@ export const passBIInsert20Rows = () => {
export const checkBrowseRoute = () => { export const checkBrowseRoute = () => {
// Click on Browse tab // Click on Browse tab
cy.get('a') cy.get(getElementFromAlias(getTableName(0))).click();
.contains(getTableName(0))
.click();
cy.get(getElementFromAlias('table-browse-rows')).click(); cy.get(getElementFromAlias('table-browse-rows')).click();
cy.wait(2000); cy.wait(2000);
// Match URL // Match URL
@ -198,7 +185,30 @@ export const checkBrowseRoute = () => {
export const passBI20RowsExist = () => { export const passBI20RowsExist = () => {
// Check if the 20 inserted elements reflect in the UI // Check if the 20 inserted elements reflect in the UI
cy.get(getElementFromAlias('table-browse-rows')).contains('21'); 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 => { export const passBISort = order => {
@ -213,9 +223,7 @@ export const passBISort = order => {
order === 'asc' ? 'Asc' : 'Desc' order === 'asc' ? 'Asc' : 'Desc'
); );
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
cy.wait(5000); cy.wait(5000);
// Check order // Check order
checkOrder(order); checkOrder(order);
@ -223,9 +231,7 @@ export const passBISort = order => {
// Clear filter // Clear filter
cy.get(getElementFromAlias('clear-sorts-0')).click(); cy.get(getElementFromAlias('clear-sorts-0')).click();
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
cy.wait(5000); cy.wait(5000);
}; };
@ -240,9 +246,7 @@ export const passBIFilterQueryEq = () => {
.last() .last()
.type('filter-text'); .type('filter-text');
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
cy.wait(2000); cy.wait(2000);
// Check if the query was successful // Check if the query was successful
checkQuerySuccess(); checkQuerySuccess();
@ -250,9 +254,7 @@ export const passBIFilterQueryEq = () => {
// Clear filter // Clear filter
cy.get(getElementFromAlias('clear-filter-0')).click(); cy.get(getElementFromAlias('clear-filter-0')).click();
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
cy.wait(5000); cy.wait(5000);
}; };
@ -261,9 +263,7 @@ export const deleteBITestTable = () => {
cy.get(getElementFromAlias('table-modify')).click(); cy.get(getElementFromAlias('table-modify')).click();
cy.wait(2000); cy.wait(2000);
// Click on delete // Click on delete
cy.get('button') cy.get(getElementFromAlias('delete-table')).click();
.contains('Delete table')
.click();
// Confirm // Confirm
cy.on('window:confirm', str => { cy.on('window:confirm', str => {
expect(str === 'Are you sure?').to.be.true; expect(str === 'Are you sure?').to.be.true;
@ -287,13 +287,9 @@ export const failBINullKeys = () => {
.type('{selectall}{del}'); .type('{selectall}{del}');
// Click the Insert Again button. // Click the Insert Again button.
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
cy.get('[class=notification-title]') cy.get('.notification-error').click();
.contains('Insert failed')
.click();
// Wait for insert notifications to disappear // Wait for insert notifications to disappear
cy.wait(7000); cy.wait(7000);
validateInsert(getTableName(0), 20); validateInsert(getTableName(0), 20);
@ -317,9 +313,7 @@ export const failBIUniqueKeys = () => {
cy.get('input[placeholder="text"]') cy.get('input[placeholder="text"]')
.first() .first()
.type('name'); .type('name');
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
// Check default for next insert // Check default for next insert
cy.get(getElementFromAlias(`typed-input-default-${textIndex}`)).check(); cy.get(getElementFromAlias(`typed-input-default-${textIndex}`)).check();
@ -336,13 +330,9 @@ export const failBIUniqueKeys = () => {
cy.get('input[placeholder="text"]') cy.get('input[placeholder="text"]')
.first() .first()
.type('name'); .type('name');
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
cy.get('[class=notification-title]') cy.get('.notification-error').click();
.contains('Insert failed')
.click();
cy.wait(7000); cy.wait(7000);
validateInsert(getTableName(0), 21); validateInsert(getTableName(0), 21);
}; };
@ -365,11 +355,10 @@ export const passEditButton = () => {
'{selectall}{del}' '{selectall}{del}'
); );
cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type('new-text'); cy.get(getElementFromAlias(`typed-input-${textIndex}`)).type('new-text');
cy.get('button') cy.get(getElementFromAlias('save-button')).click();
.contains('Save') // cy.get('h4').contains('Edited!', { timeout: 7000 });
.last() cy.get('.notification-success');
.click(); cy.wait(7000);
cy.get('h4').contains('Edited!', { timeout: 7000 });
}; };
export const passCloneButton = () => { export const passCloneButton = () => {
@ -389,6 +378,6 @@ export const passDeleteRow = () => {
cy.on('window:confirm', str => { cy.on('window:confirm', str => {
expect(str === 'Permanently delete this row?').to.be.true; expect(str === 'Permanently delete this row?').to.be.true;
}); });
cy.get('h4').contains('Row deleted!', { timeout: 7000 }); cy.get('.notification-success');
cy.wait(7000); cy.wait(14000);
}; };

View File

@ -13,6 +13,7 @@ import {
passBIInsert20Rows, passBIInsert20Rows,
checkBrowseRoute, checkBrowseRoute,
passBI20RowsExist, passBI20RowsExist,
checkPagination,
passBISort, passBISort,
passBIFilterQueryEq, passBIFilterQueryEq,
passEditButton, passEditButton,
@ -42,6 +43,7 @@ export const runInsertBrowseTests = () => {
it('Fail for adding same data for Unique keys', failBIUniqueKeys); it('Fail for adding same data for Unique keys', failBIUniqueKeys);
it('Check browser rows route', checkBrowseRoute); it('Check browser rows route', checkBrowseRoute);
it('20 Inserted rows reflect in browse rows', passBI20RowsExist); 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('Ascending sort works as expected', () => passBISort('asc'));
it('Descending sort works as expected', () => passBISort('desc')); it('Descending sort works as expected', () => passBISort('desc'));
it('FIlter query works as expected with $eq', passBIFilterQueryEq); it('FIlter query works as expected with $eq', passBIFilterQueryEq);

View File

@ -11,21 +11,13 @@ import {
} from '../../validators/validators'; } from '../../validators/validators';
export const passMTCreateTable = () => { export const passMTCreateTable = () => {
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`); cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
cy.get(getElementFromAlias('tableName')).type(getTableName(0)); cy.get(getElementFromAlias('tableName')).type(getTableName(0));
cy.get('input[placeholder="column_name"]').type('id'); cy.get(getElementFromAlias('column-0')).type('id');
cy.get('select') cy.get(getElementFromAlias('col-type-0')).select('Integer');
.first() cy.get(getElementFromAlias('primary-key-select-0')).select('id');
.select('Integer'); cy.get(getElementFromAlias('table-create')).click();
cy.get('select')
.last()
.select('id');
cy.get('button')
.contains('Create')
.click();
cy.wait(7000); cy.wait(7000);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -48,9 +40,7 @@ export const makeid = () => {
export const passMTCheckRoute = () => { export const passMTCheckRoute = () => {
// Click on the create table button // Click on the create table button
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify')
.click();
// Match the URL // Match the URL
cy.url().should( cy.url().should(
'eq', 'eq',
@ -59,9 +49,7 @@ export const passMTCheckRoute = () => {
}; };
export const passMTMoveToTable = () => { export const passMTMoveToTable = () => {
cy.get('a') cy.get(getElementFromAlias(getTableName(0))).click();
.contains(getTableName(0))
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/browse` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/browse`
@ -69,12 +57,8 @@ export const passMTMoveToTable = () => {
}; };
export const failMTWithoutColName = () => { export const failMTWithoutColName = () => {
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.get('.notification-error').click();
.click();
cy.get('[class=notification-title]')
.contains('Error adding column!')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -84,13 +68,9 @@ export const failMTWithoutColName = () => {
}; };
export const failMTWithoutColType = () => { export const failMTWithoutColType = () => {
cy.get('input[placeholder = "column name"]').type('something'); cy.get(getElementFromAlias('column-name')).type('something');
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.get('.notification-error').click();
.click();
cy.get('[class=notification-title]')
.contains('Error creating column!')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -99,47 +79,46 @@ export const failMTWithoutColType = () => {
}; };
export const failMTDuplicateColumns = () => { export const failMTDuplicateColumns = () => {
cy.get('input[placeholder = "column name"]').type('{selectall}{del}'); cy.get(getElementFromAlias('column-name')).type('{selectall}{del}');
cy.get('input[placeholder = "column name"]').type('id'); cy.get(getElementFromAlias('column-name')).type('id');
cy.get('select').select('integer'); cy.get(getElementFromAlias('data-type')).select('integer');
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') // Check for an alert
.click(); cy.wait(5500);
cy.wait(5000); cy.get('.notification-error').click();
cy.get('[class=notification-title]') // Check if the route didn't change
.contains('Adding column failed') cy.url().should(
.click(); 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
);
}; };
export const Addcolumn = () => { export const Addcolumn = () => {
cy.get('input[placeholder = "column name"]').type('{selectall}{del}'); cy.get(getElementFromAlias('column-name')).type('{selectall}{del}');
const name = makeid(); const name = makeid();
cy.get('input[placeholder = "column name"]').type(name); cy.get(getElementFromAlias('column-name')).type(name);
cy.get(getElementFromAlias('data-type')).select('integer'); cy.get(getElementFromAlias('data-type')).select('integer');
cy.get('input[placeholder = "default value"]').type('{selectall}{del}'); cy.get(getElementFromAlias('default-value')).type('{selectall}{del}');
cy.get('[data-test=nullable-checkbox]').check(); cy.get(getElementFromAlias('nullable-checkbox')).check();
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.wait(5500);
.click(); cy.get('.notification-success').click();
cy.wait(5000); cy.wait(7000);
cy.get('[class=notification-title]').contains('Column added'); cy.url().should(
cy.wait(5000); 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
);
validateColumn(getTableName(0), [name], 'success'); validateColumn(getTableName(0), [name], 'success');
}; };
export const Addcolumnnullable = () => { export const Addcolumnnullable = () => {
cy.get('input[placeholder = "column name"]').type('{selectall}{del}'); cy.get(getElementFromAlias('column-name')).type('{selectall}{del}');
cy.get('input[placeholder = "column name"]').type('some'); cy.get(getElementFromAlias('column-name')).type('some');
cy.get('select').select('Text'); cy.get(getElementFromAlias('data-type')).select('Text');
cy.get('[data-test=nullable-checkbox]').uncheck(); cy.get(getElementFromAlias('nullable-checkbox')).uncheck();
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.wait(5500);
.click(); cy.get('.notification-error').click();
cy.wait(5000);
cy.get('[class=notification-title]')
.contains('Adding column failed')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -148,15 +127,13 @@ export const Addcolumnnullable = () => {
}; };
export const failMTWrongDefault = () => { export const failMTWrongDefault = () => {
cy.get('input[placeholder = "column name"]').type('{selectall}{del}'); cy.get(getElementFromAlias('column-name')).type('{selectall}{del}');
cy.get('input[placeholder = "column name"]').type('some'); cy.get(getElementFromAlias('column-name')).type('some');
cy.get('input[placeholder = "default value"]').type('some'); cy.get(getElementFromAlias('default-value')).type('some');
cy.get('select').select('Integer'); cy.get(getElementFromAlias('data-type')).select('Integer');
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.wait(5500);
.click(); cy.get('.notification-error').click();
cy.wait(5000);
cy.get('[class=notification-title]').contains('Adding column failed');
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -165,17 +142,13 @@ export const failMTWrongDefault = () => {
}; };
export const Addcolumnname = name => { export const Addcolumnname = name => {
cy.get('input[placeholder = "column name"]').type('{selectall}{del}'); cy.get(getElementFromAlias('column-name')).type('{selectall}{del}');
cy.get('input[placeholder = "column name"]').type(name); cy.get(getElementFromAlias('column-name')).type(name);
cy.get('select').select('integer'); cy.get(getElementFromAlias('data-type')).select('integer');
cy.get('button') cy.get(getElementFromAlias('add-column-button')).click();
.contains('+ Add column') cy.wait(5500);
.click(); cy.get('.notification-success').click();
cy.wait(5000);
cy.get('[class=notification-title]')
.contains('Column added')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -190,11 +163,7 @@ export const passMTAddTwoCols = () => {
export const Movetocolumn = () => { export const Movetocolumn = () => {
Addcolumnname('somes'); Addcolumnname('somes');
cy.get('h5') cy.get(getElementFromAlias('edit-somes')).click();
.contains('somes')
.parent()
.contains('Edit')
.click();
}; };
export const passMTChangeColType = () => { export const passMTChangeColType = () => {
@ -204,13 +173,9 @@ export const passMTChangeColType = () => {
.get('select') .get('select')
.first() .first()
.select('Text'); .select('Text');
cy.get('button') cy.get(getElementFromAlias('save-button')).click();
.contains('Save') cy.wait(5500);
.click(); cy.get('.notification-success').click();
cy.wait(5000);
cy.get('[class=notification-title]')
.contains('Column modified')
.click();
cy.get('button') cy.get('button')
.contains('Close') .contains('Close')
.click(); .click();
@ -222,21 +187,15 @@ export const passMTChangeColType = () => {
}; };
export const passMTDeleteCol = () => { export const passMTDeleteCol = () => {
cy.get('h5') cy.get(getElementFromAlias('edit-somes')).click();
.contains('somes')
.parent()
.contains('Edit')
.click();
cy.get('button') cy.get('button')
.contains('Remove') .contains('Remove')
.click(); .click();
cy.on('window:alert', str => { cy.on('window:alert', str => {
expect(str === 'Are you sure you want to delete?').to.be.true; expect(str === 'Are you sure you want to delete?').to.be.true;
}); });
cy.wait(5000); cy.wait(5500);
cy.get('[class=notification-title]') cy.get('.notification-success').click();
.contains('Column deleted')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify` `${baseUrl}/data/schema/public/tables/${getTableName(0)}/modify`
@ -245,9 +204,7 @@ export const passMTDeleteCol = () => {
}; };
export const passMTDeleteTableCancel = () => { export const passMTDeleteTableCancel = () => {
cy.get('button') cy.get(getElementFromAlias('delete-table')).click();
.contains('Delete table')
.click();
cy.on('window:confirm', () => false); cy.on('window:confirm', () => false);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -258,9 +215,7 @@ export const passMTDeleteTableCancel = () => {
}; };
export const passMTDeleteTable = () => { export const passMTDeleteTable = () => {
cy.get('button') cy.get(getElementFromAlias('delete-table')).click();
.contains('Delete table')
.click();
cy.on('window:confirm', () => true); cy.on('window:confirm', () => true);
cy.wait(5000); cy.wait(5000);
cy.url().should('eq', `${baseUrl}/data/schema/public`); cy.url().should('eq', `${baseUrl}/data/schema/public`);
@ -268,22 +223,14 @@ export const passMTDeleteTable = () => {
}; };
export const failMTRemoveNullable = () => { export const failMTRemoveNullable = () => {
cy.get('a') cy.get(getElementFromAlias('table-insert-rows')).click();
.contains('Insert Row')
.click();
cy.get('input[placeholder = "integer"]').type('{selectall}{del}'); cy.get('input[placeholder = "integer"]').type('{selectall}{del}');
cy.get('input[placeholder="integer"]').type(123); cy.get('input[placeholder="integer"]').type(123);
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
cy.get('input[placeholder = "integer"]').type('{selectall}{del}'); cy.get('input[placeholder = "integer"]').type('{selectall}{del}');
cy.get('input[placeholder="integer"]').type(1234); cy.get('input[placeholder="integer"]').type(1234);
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again') cy.get(getElementFromAlias('table-modify')).click();
.click();
cy.get('a')
.contains('Modify')
.click();
Addcolumnnullable(); Addcolumnnullable();
}; };
@ -313,9 +260,7 @@ export const Createtable = (name, dict) => {
cy.get('select') cy.get('select')
.last() .last()
.select('id'); .select('id');
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create')
.click();
cy.wait(7000); cy.wait(7000);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -326,13 +271,9 @@ export const Createtable = (name, dict) => {
}; };
export const Createtables = () => { export const Createtables = () => {
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
Createtable('author', { id: 'Integer', name: 'Text' }); Createtable('author', { id: 'Integer', name: 'Text' });
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
Createtable('article', { Createtable('article', {
id: 'Integer', id: 'Integer',
title: 'Text', title: 'Text',
@ -343,53 +284,35 @@ export const Createtables = () => {
}; };
export const Createview = () => { export const Createview = () => {
cy.get('a') cy.get(getElementFromAlias('sql-link')).click();
.contains('SQL')
.click();
cy.get('textarea').type(`CREATE VIEW author_average_rating AS cy.get('textarea').type(`CREATE VIEW author_average_rating AS
SELECT author_table.id, avg(article_table.rating) SELECT author_table.id, avg(article_table.rating)
From author_table, article_table From author_table, article_table
WHERE author_table.id = article_table.author_id WHERE author_table.id = article_table.author_id
GROUP BY author_table.id`); GROUP BY author_table.id`);
cy.get('button') cy.get(getElementFromAlias('run-sql')).click();
.contains('Run!')
.click();
validateCT('author_average_rating', 'success'); validateCT('author_average_rating', 'success');
}; };
export const Checkviewtable = () => { export const Checkviewtable = () => {
cy.get('a') cy.get(getElementFromAlias('author_average_rating')).click();
.contains('author_average_rating')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/views/author_average_rating/browse` `${baseUrl}/data/schema/public/views/author_average_rating/browse`
); );
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify') cy.get(getElementFromAlias('modify-view')).click();
.click();
cy.get('button')
.contains('Modify')
.last()
.click();
cy.url().should('eq', `${baseUrl}/data/sql`); cy.url().should('eq', `${baseUrl}/data/sql`);
}; };
export const Checkviewtabledelete = () => { export const Checkviewtabledelete = () => {
cy.get('a') cy.get(getElementFromAlias('author_average_rating')).click();
.contains('author_average_rating')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/views/author_average_rating/browse` `${baseUrl}/data/schema/public/views/author_average_rating/browse`
); );
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify') cy.get(getElementFromAlias('delete-view')).click();
.click();
cy.get('button')
.contains('Delete view')
.last()
.click();
cy.on('window:confirm', str => { cy.on('window:confirm', str => {
expect(str === 'Are you sure?').to.be.true; expect(str === 'Are you sure?').to.be.true;
return true; return true;

View File

@ -12,9 +12,7 @@ import { testPermissions, permRemove, createView, trackView } from './utils';
export const passPTCreateTable = () => { export const passPTCreateTable = () => {
// Click on create tabel // Click on create tabel
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
// Match the URL // Match the URL
cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`); cy.url().should('eq', `${baseUrl}/data/schema/public/table/add`);
// Type table name // Type table name
@ -31,9 +29,7 @@ export const passPTCreateTable = () => {
// Set primary key // Set primary key
cy.get(getElementFromAlias('primary-key-select-0')).select('0'); cy.get(getElementFromAlias('primary-key-select-0')).select('0');
// Create // Create
cy.get('button') cy.get(getElementFromAlias('table-create')).click();
.contains('Create')
.click();
cy.wait(7000); cy.wait(7000);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -90,13 +86,9 @@ export const passPVRemovePerms = () => {
export const passPVDeleteView = () => { export const passPVDeleteView = () => {
// Go to modify table // Go to modify table
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify')
.click();
// Delete table // Delete table
cy.get('button') cy.get(getElementFromAlias('delete-view')).click();
.contains('Delete view')
.click();
cy.wait(7000); cy.wait(7000);
}; };
@ -107,9 +99,7 @@ export const passPTDeleteTable = () => {
// Go to modify table // Go to modify table
cy.get(getElementFromAlias('table-modify')).click(); cy.get(getElementFromAlias('table-modify')).click();
// Delete table // Delete table
cy.get('button') cy.get(getElementFromAlias('delete-table')).click();
.contains('Delete table')
.click();
cy.wait(7000); cy.wait(7000);
}; };

View File

@ -9,12 +9,10 @@ import {
import { validatePermission } from '../../validators/validators'; import { validatePermission } from '../../validators/validators';
export const savePermission = () => { export const savePermission = () => {
cy.get('button') cy.get(getElementFromAlias('Save-permissions-button')).click();
.contains('Save permissions') cy.wait(5500);
.click();
cy.wait(5000);
// Check for success notif // Check for success notif
cy.get('[class=notification-title]').contains('Permissions updated'); cy.get('.notification-success').click();
}; };
export const permNoCheck = (tableName, query, first) => { export const permNoCheck = (tableName, query, first) => {
@ -91,12 +89,10 @@ export const permRemove = (tableName, query) => {
// click on the query type to edit permission // click on the query type to edit permission
cy.get(getElementFromAlias(`role0-${query}`)).click(); cy.get(getElementFromAlias(`role0-${query}`)).click();
// Remove permission // Remove permission
cy.get('button') cy.get(getElementFromAlias('Remove-all-access-button')).click();
.contains('Remove all access') cy.wait(5500);
.click();
cy.wait(5000);
// Check for notif // Check for notif
cy.get('[class=notification-title]').contains('Permissions deleted'); cy.get('.notification-success').click();
cy.wait(5000); cy.wait(5000);
// Validate // Validate
validatePermission(tableName, 'role0', query, 'custom', 'failure'); validatePermission(tableName, 'role0', query, 'custom', 'failure');
@ -128,9 +124,7 @@ export const trackView = () => {
cy.get(getElementFromAlias(`add-track-table-${getTableName(1)}`)).click(); cy.get(getElementFromAlias(`add-track-table-${getTableName(1)}`)).click();
cy.wait(10000); cy.wait(10000);
// Move to permissions // Move to permissions
cy.get('a') cy.get(getElementFromAlias('table-permissions')).click();
.contains('Permissions')
.click();
}; };
export const createView = (viewName, tableName) => { export const createView = (viewName, tableName) => {

View File

@ -1,6 +1,7 @@
/* eslint import/prefer-default-export: 0 */ /* eslint import/prefer-default-export: 0 */
import { baseUrl } from '../../../helpers/dataHelpers'; import { baseUrl } from '../../../helpers/dataHelpers';
import { getElementFromAlias } from '../../../helpers/dataHelpers';
export const openRawSQL = () => { export const openRawSQL = () => {
// eslint-disable-line // eslint-disable-line
@ -9,9 +10,7 @@ export const openRawSQL = () => {
.contains('Data') .contains('Data')
.click(); .click();
cy.wait(3000); cy.wait(3000);
cy.get('a') cy.get(getElementFromAlias('sql-link')).click();
.contains('SQL')
.click();
cy.wait(3000); cy.wait(3000);
// Match URL // Match URL
cy.url().should('eq', `${baseUrl}/data/sql`); cy.url().should('eq', `${baseUrl}/data/sql`);

View File

@ -12,23 +12,12 @@ export const Createtable = (name, dict) => {
const keys = Object.keys(dict).map(k => k); const keys = Object.keys(dict).map(k => k);
const values = Object.keys(dict).map(k => dict[k]); const values = Object.keys(dict).map(k => dict[k]);
for (let i = 0; i < keys.length; i += 1) { for (let i = 0; i < keys.length; i += 1) {
cy.get('input[placeholder="column_name"]') cy.get(getElementFromAlias(`column-${i}`)).type(keys[i]);
.last() cy.get(getElementFromAlias(`col-type-${i}`)).select(values[i]);
.type(keys[i]);
cy.get('select')
.find('option')
.contains('-- type --')
.parent()
.last()
.select(values[i]);
} }
cy.get('select') cy.get(getElementFromAlias('primary-key-select-0')).select('id');
.last() cy.get(getElementFromAlias('table-create')).click();
.select('id');
cy.get('button')
.contains('Create')
.click();
cy.wait(10000); cy.wait(10000);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -39,13 +28,9 @@ export const Createtable = (name, dict) => {
}; };
export const passRTCreateTables = () => { export const passRTCreateTables = () => {
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
Createtable('author', { id: 'Integer', name: 'Text' }); Createtable('author', { id: 'Integer', name: 'Text' });
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
Createtable('article', { Createtable('article', {
id: 'Integer', id: 'Integer',
title: 'Text', title: 'Text',
@ -53,9 +38,7 @@ export const passRTCreateTables = () => {
author_id: 'Integer', author_id: 'Integer',
rating: 'Integer', rating: 'Integer',
}); });
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
Createtable('comment', { Createtable('comment', {
id: 'Integer', id: 'Integer',
user_id: 'Integer', user_id: 'Integer',
@ -65,24 +48,14 @@ export const passRTCreateTables = () => {
}; };
export const passRTMoveToTable = () => { export const passRTMoveToTable = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
}; };
export const Deletetable = name => { export const Deletetable = name => {
cy.get('a') cy.get(getElementFromAlias(name)).click();
.contains(name) cy.get(getElementFromAlias('table-modify')).click();
.click(); cy.get(getElementFromAlias('delete-table')).click();
cy.get('a')
.contains('Modify')
.click();
cy.get('button')
.contains('Delete table')
.click();
cy.on('window:alert', str => { cy.on('window:alert', str => {
expect(str === 'Are you sure?').to.be.true; expect(str === 'Are you sure?').to.be.true;
}); });
@ -97,12 +70,8 @@ export const passRTDeleteTables = () => {
}; };
export const passRTAddDataarticle = data => { export const passRTAddDataarticle = data => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-insert-rows')).click();
.click();
cy.get('a')
.contains('Insert Row')
.click();
cy.get('label') cy.get('label')
.contains('id') .contains('id')
.next() .next()
@ -140,12 +109,8 @@ export const passRTAddDataarticle = data => {
}; };
export const passRTAddDataauthor = data => { export const passRTAddDataauthor = data => {
cy.get('a') cy.get(getElementFromAlias('author_table')).click();
.contains('author_table') cy.get(getElementFromAlias('table-insert-rows')).click();
.click();
cy.get('a')
.contains('Insert Row')
.click();
cy.get('label') cy.get('label')
.contains('id') .contains('id')
.next() .next()
@ -158,19 +123,13 @@ export const passRTAddDataauthor = data => {
.find('input') .find('input')
.last() .last()
.type(data[1]); .type(data[1]);
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
}; };
export const passRTAddDatacomment = data => { export const passRTAddDatacomment = data => {
cy.get('a') cy.get(getElementFromAlias('comment_table')).click();
.contains('comment_table') cy.get(getElementFromAlias('table-insert-rows')).click();
.click();
cy.get('a')
.contains('Insert Row')
.click();
cy.get('label') cy.get('label')
.contains('id') .contains('id')
.next() .next()
@ -195,9 +154,7 @@ export const passRTAddDatacomment = data => {
.find('input') .find('input')
.last() .last()
.type(data[3]); .type(data[3]);
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
}; };
@ -222,15 +179,9 @@ export const passRTAddData = () => {
}; };
export const passRTAddManualObjRel = () => { export const passRTAddManualObjRel = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click(); cy.get(getElementFromAlias('add-manual-relationship')).click();
cy.get('a')
.contains('Relationships')
.click();
cy.get('button')
.contains('+ Add a manual relationship')
.click();
cy.get('select') cy.get('select')
.first() .first()
.select('Object Relationship'); .select('Object Relationship');
@ -261,15 +212,9 @@ export const passRTAddManualObjRel = () => {
}; };
export const passRTAddManualArrayRel = () => { export const passRTAddManualArrayRel = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click(); cy.get(getElementFromAlias('add-manual-relationship')).click();
cy.get('a')
.contains('Relationships')
.click();
cy.get('button')
.contains('+ Add a manual relationship')
.click();
cy.get('select') cy.get('select')
.first() .first()
.select('Array Relationship'); .select('Array Relationship');
@ -300,12 +245,8 @@ export const passRTAddManualArrayRel = () => {
}; };
export const passRTAddForeignKey = () => { export const passRTAddForeignKey = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-modify')).click();
.click();
cy.get('a')
.contains('Modify')
.click();
cy.get('b') cy.get('b')
.contains('author_id') .contains('author_id')
.prev() .prev()
@ -321,16 +262,10 @@ export const passRTAddForeignKey = () => {
.contains('Reference column') .contains('Reference column')
.parent() .parent()
.select('id'); .select('id');
cy.get('button') cy.get(getElementFromAlias('save-button')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
cy.get('a') cy.get(getElementFromAlias('comment_table')).click();
.contains('comment_table') cy.get(getElementFromAlias('table-modify')).click();
.click();
cy.get('a')
.contains('Modify')
.click();
cy.get('b') cy.get('b')
.contains('article_id') .contains('article_id')
.prev() .prev()
@ -346,21 +281,14 @@ export const passRTAddForeignKey = () => {
.contains('Reference column') .contains('Reference column')
.parent() .parent()
.select('id'); .select('id');
cy.get('button') cy.get(getElementFromAlias('save-button')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
}; };
export const passRTDeleteRelationships = () => { export const passRTDeleteRelationships = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click(); cy.get(getElementFromAlias('remove-button'))
cy.get('a')
.contains('Relationships')
.click();
cy.get('button')
.contains('Remove')
.first() .first()
.click(); .click();
cy.on('window:alert', str => { cy.on('window:alert', str => {
@ -372,14 +300,9 @@ export const passRTDeleteRelationships = () => {
['title', { name: 'author', columns: ['name'] }], ['title', { name: 'author', columns: ['name'] }],
'failure' 'failure'
); );
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click(); cy.get(getElementFromAlias('remove-button'))
cy.get('a')
.contains('Relationships')
.click();
cy.get('button')
.contains('Remove')
.first() .first()
.click(); .click();
cy.on('window:alert', str => { cy.on('window:alert', str => {
@ -394,12 +317,8 @@ export const passRTDeleteRelationships = () => {
}; };
export const passRTAddSuggestedRel = () => { export const passRTAddSuggestedRel = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get(getElementFromAlias('obj-rel-add-0')) cy.get(getElementFromAlias('obj-rel-add-0'))
.contains('Add') .contains('Add')
.last() .last()
@ -407,21 +326,15 @@ export const passRTAddSuggestedRel = () => {
cy.get('input') cy.get('input')
.last() .last()
.type('author'); .type('author');
cy.get('button') cy.get(getElementFromAlias('obj-rel-save-0')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
validateColumn( validateColumn(
'article_table', 'article_table',
['title', { name: 'author', columns: ['name'] }], ['title', { name: 'author', columns: ['name'] }],
'success' 'success'
); );
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get(getElementFromAlias('arr-rel-add-0')) cy.get(getElementFromAlias('arr-rel-add-0'))
.contains('Add') .contains('Add')
.last() .last()
@ -429,9 +342,7 @@ export const passRTAddSuggestedRel = () => {
cy.get('input') cy.get('input')
.last() .last()
.type('comments'); .type('comments');
cy.get('button') cy.get(getElementFromAlias('arr-rel-save-0')).click();
.contains('Save')
.click();
cy.wait(7000); cy.wait(7000);
validateColumn( validateColumn(
'article_table', 'article_table',
@ -441,20 +352,14 @@ export const passRTAddSuggestedRel = () => {
}; };
export const failRTAddSuggestedRel = () => { export const failRTAddSuggestedRel = () => {
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get(getElementFromAlias('obj-rel-add-0')) cy.get(getElementFromAlias('obj-rel-add-0'))
.contains('Add') .contains('Add')
.last() .last()
.click(); .click();
cy.get('button') cy.get(getElementFromAlias('obj-rel-save-0')).click();
.contains('Save') cy.get('.notification-error');
.click();
cy.get('h4').contains('Error adding relationship!');
cy.wait(7000); cy.wait(7000);
cy.get('input') cy.get('input')
.last() .last()
@ -462,41 +367,30 @@ export const failRTAddSuggestedRel = () => {
cy.get('button') cy.get('button')
.contains('Save') .contains('Save')
.click(); .click();
cy.get('h4').contains('Error adding relationship!'); cy.get('.notification-error');
cy.wait(10000); cy.wait(10000);
validateColumn( validateColumn(
'article_table', 'article_table',
['title', { name: 'author', columns: ['name'] }], ['title', { name: 'author', columns: ['name'] }],
'failure' 'failure'
); );
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get(getElementFromAlias('obj-rel-add-0')) cy.get(getElementFromAlias('obj-rel-add-0'))
.contains('Add')
.last() .last()
.click(); .click();
cy.get('input') cy.get('input')
.last() .last()
.type('author'); .type('author');
cy.get('button') cy.get(getElementFromAlias('obj-rel-save-0')).click();
.contains('Save')
.click();
cy.wait(10000); cy.wait(10000);
validateColumn( validateColumn(
'article_table', 'article_table',
['title', { name: 'author', columns: ['name'] }], ['title', { name: 'author', columns: ['name'] }],
'success' 'success'
); );
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get(getElementFromAlias('arr-rel-add-0')) cy.get(getElementFromAlias('arr-rel-add-0'))
.contains('Add') .contains('Add')
.last() .last()
@ -508,16 +402,11 @@ export const failRTAddSuggestedRel = () => {
.contains('Save') .contains('Save')
.click(); .click();
cy.wait(7000); cy.wait(7000);
cy.get('h4').contains('Creating relationship failed'); cy.get('.notification-error');
cy.wait(7000); cy.wait(7000);
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table') cy.get(getElementFromAlias('table-relationships')).click();
.click(); cy.get(getElementFromAlias('remove-button'))
cy.get('a')
.contains('Relationships')
.click();
cy.get('button')
.contains('Remove')
.first() .first()
.click(); .click();
cy.on('window:alert', str => { cy.on('window:alert', str => {

View File

@ -16,23 +16,11 @@ export const Createtable = (name, dict) => {
const keys = Object.keys(dict).map(k => k); const keys = Object.keys(dict).map(k => k);
const values = Object.keys(dict).map(k => dict[k]); const values = Object.keys(dict).map(k => dict[k]);
for (let i = 0; i < keys.length; i += 1) { for (let i = 0; i < keys.length; i += 1) {
cy.get('input[placeholder="column_name"]') cy.get(getElementFromAlias(`column-${i}`)).type(keys[i]);
.last() cy.get(getElementFromAlias(`col-type-${i}`)).select(values[i]);
.type(keys[i]);
cy.get('select')
.find('option')
.contains('-- type --')
.parent()
.last()
.select(values[i]);
} }
cy.get(getElementFromAlias('primary-key-select-0')).select('id');
cy.get('select') cy.get(getElementFromAlias('table-create')).click();
.last()
.select('id');
cy.get('button')
.contains('Create')
.click();
cy.wait(7000); cy.wait(7000);
cy.url().should( cy.url().should(
'eq', 'eq',
@ -43,13 +31,9 @@ export const Createtable = (name, dict) => {
}; };
export const passVCreateTables = () => { export const passVCreateTables = () => {
cy.get('button') cy.get(getElementFromAlias('data-create-table')).click();
.contains('Create Table')
.click();
Createtable('author', { id: 'Integer', name: 'Text' }); Createtable('author', { id: 'Integer', name: 'Text' });
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
Createtable('article', { Createtable('article', {
id: 'Integer', id: 'Integer',
title: 'Text', title: 'Text',
@ -57,9 +41,7 @@ export const passVCreateTables = () => {
author_id: 'Integer', author_id: 'Integer',
rating: 'Integer', rating: 'Integer',
}); });
cy.get('button') cy.get(getElementFromAlias('sidebar-add-table')).click();
.contains('Add Table')
.click();
Createtable('comment', { Createtable('comment', {
id: 'Integer', id: 'Integer',
user_id: 'Integer', user_id: 'Integer',
@ -83,15 +65,13 @@ export const passTrackTable = () => {
.click(); .click();
cy.wait(7000); cy.wait(7000);
cy.get(getElementFromAlias('add-track-table-author_average_rating')).click(); cy.get(getElementFromAlias('add-track-table-author_average_rating')).click();
cy.wait(5000); cy.wait(7000);
cy.get('h4').contains('Existing table/view added'); cy.get('.notification-success');
validateView('author_average_rating', 'success'); validateView('author_average_rating', 'success');
}; };
export const passViewRoute = () => { export const passViewRoute = () => {
cy.get('a') cy.get(getElementFromAlias('author_average_rating')).click();
.contains('author_average_rating')
.click();
cy.url().should( cy.url().should(
'eq', 'eq',
`${baseUrl}/data/schema/public/views/author_average_rating/browse` `${baseUrl}/data/schema/public/views/author_average_rating/browse`
@ -161,13 +141,9 @@ export const passVAddDataarticle = (data, index) => {
.last() .last()
.type(data[4]); .type(data[4]);
if (index) { if (index) {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
} else { } else {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
} }
cy.wait(5000); cy.wait(5000);
@ -199,13 +175,9 @@ export const passVAddDataauthor = (data, index) => {
.last() .last()
.type(data[1]); .type(data[1]);
if (index) { if (index) {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
} else { } else {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
} }
cy.wait(5000); cy.wait(5000);
}; };
@ -260,13 +232,9 @@ export const passVAddDatacomment = (data, index) => {
.last() .last()
.type(data[3]); .type(data[3]);
if (index) { if (index) {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Insert Again')
.click();
} else { } else {
cy.get('button') cy.get(getElementFromAlias('insert-save-button')).click();
.contains('Save')
.click();
} }
cy.wait(5000); cy.wait(5000);
}; };
@ -281,9 +249,7 @@ const checkQuerySuccess = () => {
export const passVAddData = () => { export const passVAddData = () => {
let data; let data;
cy.get('a') cy.get(getElementFromAlias('article_table')).click();
.contains('article_table')
.click();
cy.get(getElementFromAlias('table-insert-rows')).click(); cy.get(getElementFromAlias('table-insert-rows')).click();
data = [1, 'A', 'Sontent', userId, 4]; data = [1, 'A', 'Sontent', userId, 4];
passVAddDataarticle(data, 0); passVAddDataarticle(data, 0);
@ -291,18 +257,14 @@ export const passVAddData = () => {
passVAddDataarticle(data, 1); passVAddDataarticle(data, 1);
data = [3, 'C', 'Sontentb', userId, 4]; data = [3, 'C', 'Sontentb', userId, 4];
passVAddDataarticle(data, 2); passVAddDataarticle(data, 2);
cy.get('a') cy.get(getElementFromAlias('author_table')).click();
.contains('author_table')
.click();
cy.get(getElementFromAlias('table-insert-rows')).click(); cy.get(getElementFromAlias('table-insert-rows')).click();
data = [userId, 'A']; data = [userId, 'A'];
passVAddDataauthor(data, 0); passVAddDataauthor(data, 0);
data = [2, 'B']; data = [2, 'B'];
passVAddDataauthor(data, 1); passVAddDataauthor(data, 1);
cy.get('a') cy.get(getElementFromAlias('comment_table')).click();
.contains('comment_table')
.click();
cy.get(getElementFromAlias('table-insert-rows')).click(); cy.get(getElementFromAlias('table-insert-rows')).click();
data = [1, 1, 1, 'new comment']; data = [1, 1, 1, 'new comment'];
@ -333,9 +295,7 @@ export const passVFilterQueryEq = () => {
.last() .last()
.type(userId); .type(userId);
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
cy.wait(5000); cy.wait(5000);
// Check if the query was successful // Check if the query was successful
checkQuerySuccess(); checkQuerySuccess();
@ -389,17 +349,13 @@ export const passVAscendingSort = () => {
.last() .last()
.select('id'); .select('id');
// Run query // Run query
cy.get('button') cy.get(getElementFromAlias('run-query')).click();
.contains('Run query')
.click();
// Check order // Check order
checkOrder('asc'); checkOrder('asc');
}; };
export const passModifyView = () => { export const passModifyView = () => {
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify')
.click();
cy.get('button') cy.get('button')
.contains('Modify') .contains('Modify')
.last() .last()
@ -408,13 +364,9 @@ export const passModifyView = () => {
}; };
export const passVAddManualObjRel = () => { export const passVAddManualObjRel = () => {
cy.get('a') cy.get(getElementFromAlias('author_average_rating')).click();
.contains('author_average_rating')
.click();
cy.wait(2000); cy.wait(2000);
cy.get('a') cy.get(getElementFromAlias('table-relationships')).click();
.contains('Relationships')
.click();
cy.wait(2000); cy.wait(2000);
cy.get(getElementFromAlias('data-rel-type')).select('object_rel'); cy.get(getElementFromAlias('data-rel-type')).select('object_rel');
cy.get("input[placeholder='Enter relationship name']").type('author'); cy.get("input[placeholder='Enter relationship name']").type('author');
@ -441,12 +393,8 @@ export const passVAddManualObjRel = () => {
}; };
export const passVDeleteRelationships = () => { export const passVDeleteRelationships = () => {
cy.get('a') cy.get(getElementFromAlias('author_average_rating')).click();
.contains('author_average_rating') cy.get(getElementFromAlias('table-relationships')).click();
.click();
cy.get('a')
.contains('Relationships')
.click();
cy.get('button') cy.get('button')
.contains('Remove') .contains('Remove')
.first() .first()
@ -463,30 +411,20 @@ export const passVDeleteRelationships = () => {
}; };
export const passVDeleteView = () => { export const passVDeleteView = () => {
cy.get('a') cy.get(getElementFromAlias('table-modify')).click();
.contains('Modify') cy.get(getElementFromAlias('delete-view')).click();
.click();
cy.get('button')
.contains('Delete view')
.click();
cy.on('window:confirm', str => { cy.on('window:confirm', str => {
expect(str === 'Are you sure').to.be.true; expect(str === 'Are you sure').to.be.true;
}); });
cy.wait(5000); cy.wait(5000);
cy.get('h4').contains('View deleted'); cy.get('.notification-success');
validateView('author_average_rating', 'failure'); validateView('author_average_rating', 'failure');
}; };
export const Deletetable = name => { export const Deletetable = name => {
cy.get('a') cy.get(getElementFromAlias(name)).click();
.contains(name) cy.get(getElementFromAlias('table-modify')).click();
.click(); cy.get(getElementFromAlias('delete-table')).click();
cy.get('a')
.contains('Modify')
.click();
cy.get('button')
.contains('Delete table')
.click();
cy.on('window:alert', str => { cy.on('window:alert', str => {
expect(str === 'Are you sure?').to.be.true; expect(str === 'Are you sure?').to.be.true;
}); });

View File

@ -11,7 +11,6 @@
// This function is called when a project is opened or re-opened (e.g. due to // This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing) // the project's config changing)
// module.exports = (on, config) => {
module.exports = () => { module.exports = () => {
// `on` is used to hook into various events Cypress emits // `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config // `config` is the resolved Cypress config

5950
console/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,9 @@ const DataHeader = ({
currentLocation.indexOf('sql') !== -1 ? styles.active : '' currentLocation.indexOf('sql') !== -1 ? styles.active : ''
} }
> >
<Link to={appPrefix + '/sql'}>SQL</Link> <Link to={appPrefix + '/sql'} data-test="sql-link">
SQL
</Link>
</li> </li>
{migrationSection} {migrationSection}
</ul> </ul>

View File

@ -54,11 +54,11 @@ const PageContainer = ({
tableName + tableName +
'/browse' '/browse'
} }
data-test={tableName}
> >
<i <i
className={styles.tableIcon + ' fa fa-table'} className={styles.tableIcon + ' fa fa-table'}
aria-hidden="true" aria-hidden="true"
data-test={tableName}
/> />
{tableName} {tableName}
</Link> </Link>
@ -76,6 +76,7 @@ const PageContainer = ({
tableName + tableName +
'/browse' '/browse'
} }
data-test={tableName}
> >
<i <i
className={styles.tableIcon + ' fa fa-table'} className={styles.tableIcon + ' fa fa-table'}
@ -145,6 +146,7 @@ const PageContainer = ({
> >
<button <button
className={styles.add_mar_right + ' btn btn-xs btn-default'} className={styles.add_mar_right + ' btn btn-xs btn-default'}
data-test="sidebar-add-table"
> >
Add Table Add Table
</button> </button>

View File

@ -272,6 +272,7 @@ const RawSQL = ({
dispatch(executeSQL(false)); dispatch(executeSQL(false));
} }
}} }}
data-test="run-sql"
> >
Run! Run!
</button> </button>

View File

@ -316,6 +316,7 @@ class EditItem extends Component {
}); });
dispatch(editItem(tableName, inputValues)); dispatch(editItem(tableName, inputValues));
}} }}
data-test="save-button"
> >
{buttonText} {buttonText}
</button> </button>

View File

@ -201,7 +201,11 @@ class FilterQuery extends Component {
</div> </div>
</div> </div>
<div className={`${styles.padd_right} ${styles.clear_fix}`}> <div className={`${styles.padd_right} ${styles.clear_fix}`}>
<button type="submit" className={`btn ${styles.yellow_button}`}> <button
type="submit"
className={`btn ${styles.yellow_button}`}
data-test="run-query"
>
Run query Run query
</button> </button>
{/* <div className={styles.count + ' alert alert-info'}><i>Total <b>{tableName}</b> rows in the database for current query: {count} </i></div> */} {/* <div className={styles.count + ' alert alert-info'}><i>Total <b>{tableName}</b> rows in the database for current query: {count} </i></div> */}

View File

@ -67,6 +67,7 @@ const ViewHeader = ({ tableName, tabName, tableComment, currentSchema }) => {
tableName + tableName +
'/browse' '/browse'
} }
data-test="table-browse-rows"
> >
Browse Rows Browse Rows
</Link> </Link>
@ -84,6 +85,7 @@ const ViewHeader = ({ tableName, tabName, tableComment, currentSchema }) => {
tableName + tableName +
'/modify' '/modify'
} }
data-test="table-modify"
> >
Modify Modify
</Link> </Link>
@ -101,6 +103,7 @@ const ViewHeader = ({ tableName, tabName, tableComment, currentSchema }) => {
tableName + tableName +
'/relationships' '/relationships'
} }
data-test="table-relationships"
> >
Relationships Relationships
</Link> </Link>
@ -118,6 +121,7 @@ const ViewHeader = ({ tableName, tabName, tableComment, currentSchema }) => {
tableName + tableName +
'/permissions' '/permissions'
} }
data-test="table-permissions"
> >
Permissions Permissions
</Link> </Link>

View File

@ -70,7 +70,6 @@ const TableHeader = ({
<li <li
role="presentation" role="presentation"
className={tabName === 'view' ? styles.active : ''} className={tabName === 'view' ? styles.active : ''}
data-test="table-browse-rows"
> >
<Link <Link
to={ to={
@ -81,6 +80,7 @@ const TableHeader = ({
tableName + tableName +
'/browse' '/browse'
} }
data-test="table-browse-rows"
> >
Browse Rows {showCount} Browse Rows {showCount}
</Link> </Link>
@ -88,7 +88,6 @@ const TableHeader = ({
<li <li
role="presentation" role="presentation"
className={tabName === 'insert' ? styles.active : ''} className={tabName === 'insert' ? styles.active : ''}
data-test="table-insert-rows"
> >
<Link <Link
to={ to={
@ -99,6 +98,7 @@ const TableHeader = ({
tableName + tableName +
'/insert' '/insert'
} }
data-test="table-insert-rows"
> >
Insert Row Insert Row
</Link> </Link>
@ -107,7 +107,6 @@ const TableHeader = ({
<li <li
role="presentation" role="presentation"
className={tabName === 'modify' ? styles.active : ''} className={tabName === 'modify' ? styles.active : ''}
data-test="table-modify"
> >
<Link <Link
to={ to={
@ -118,6 +117,7 @@ const TableHeader = ({
tableName + tableName +
'/modify' '/modify'
} }
data-test="table-modify"
> >
Modify Modify
</Link> </Link>
@ -126,7 +126,6 @@ const TableHeader = ({
<li <li
role="presentation" role="presentation"
className={tabName === 'relationships' ? styles.active : ''} className={tabName === 'relationships' ? styles.active : ''}
data-test="table-relationships"
> >
<Link <Link
to={ to={
@ -137,6 +136,7 @@ const TableHeader = ({
tableName + tableName +
'/relationships' '/relationships'
} }
data-test="table-relationships"
> >
Relationships Relationships
</Link> </Link>
@ -144,7 +144,6 @@ const TableHeader = ({
<li <li
role="presentation" role="presentation"
className={tabName === 'permissions' ? styles.active : ''} className={tabName === 'permissions' ? styles.active : ''}
data-test="table-permissions"
> >
<Link <Link
to={ to={
@ -155,6 +154,7 @@ const TableHeader = ({
tableName + tableName +
'/permissions' '/permissions'
} }
data-test="table-permissions"
> >
Permissions Permissions
</Link> </Link>

View File

@ -449,6 +449,7 @@ class InsertItem extends Component {
this.nextInsert(); this.nextInsert();
}); });
}} }}
data-test="insert-save-button"
> >
{this.state.insertedRows > 0 ? 'Insert Again' : 'Save'} {this.state.insertedRows > 0 ? 'Insert Again' : 'Save'}
</button> </button>

View File

@ -270,7 +270,11 @@ const ColumnEditor = ({
</div> </div>
{checkExistingForeignKey()} {checkExistingForeignKey()}
<div className="row"> <div className="row">
<button type="submit" className={`${styles.yellow_button} btn`}> <button
type="submit"
className={`${styles.yellow_button} btn`}
data-test="save-button"
>
Save Save
</button> </button>
{!isPrimaryKey ? ( {!isPrimaryKey ? (
@ -281,6 +285,7 @@ const ColumnEditor = ({
e.preventDefault(); e.preventDefault();
onDelete(); onDelete();
}} }}
data-test="remove-button"
> >
Remove Remove
</button> </button>
@ -439,6 +444,7 @@ class ModifyTable extends Component {
onClick={() => { onClick={() => {
dispatch({ type: TOGGLE_ACTIVE_COLUMN, column: colName }); dispatch({ type: TOGGLE_ACTIVE_COLUMN, column: colName });
}} }}
data-test={`edit-${colName}`}
> >
{btnText} {btnText}
</button> </button>
@ -538,6 +544,7 @@ class ModifyTable extends Component {
type="text" type="text"
className={`${styles.input} input-sm form-control`} className={`${styles.input} input-sm form-control`}
ref={n => (colNameInput = n)} ref={n => (colNameInput = n)}
data-test="column-name"
/> />
<select <select
className={`${styles.select} input-sm form-control`} className={`${styles.select} input-sm form-control`}
@ -576,8 +583,13 @@ class ModifyTable extends Component {
styles.defaultInput styles.defaultInput
} input-sm form-control`} } input-sm form-control`}
ref={n => (colDefaultInput = n)} ref={n => (colDefaultInput = n)}
data-test="default-value"
/> />
<button type="submit" className="btn btn-sm btn-warning"> <button
type="submit"
className="btn btn-sm btn-warning"
data-test="add-column-button"
>
+ Add column + Add column
</button> </button>
</form> </form>
@ -593,6 +605,7 @@ class ModifyTable extends Component {
dispatch(deleteTableSql(tableName, tableSchema)); dispatch(deleteTableSql(tableName, tableSchema));
} }
}} }}
data-test="delete-table"
> >
Delete table Delete table
</button> </button>

View File

@ -95,6 +95,7 @@ class ModifyView extends Component {
dispatch(untrackTableSql(tableName)); dispatch(untrackTableSql(tableName));
} }
}} }}
data-test="untrack-view"
> >
Untrack View Untrack View
</button> </button>
@ -139,6 +140,7 @@ class ModifyView extends Component {
onClick={() => { onClick={() => {
this.modifyViewDefinition(tableName); this.modifyViewDefinition(tableName);
}} }}
data-test="modify-view"
> >
Modify Modify
</button> </button>
@ -152,6 +154,7 @@ class ModifyView extends Component {
dispatch(deleteViewSql(tableName)); dispatch(deleteViewSql(tableName));
} }
}} }}
data-test="delete-view"
> >
Delete view Delete view
</button> </button>

View File

@ -639,6 +639,7 @@ class Permissions extends Component {
className={`${styles.editActionButton} button btn ${customClasses}`} className={`${styles.editActionButton} button btn ${customClasses}`}
onClick={onClickFn} onClick={onClickFn}
disabled={disabled} disabled={disabled}
data-test={`${value.split(' ').join('-')}-button`}
> >
{value} {value}
</button> </button>

View File

@ -77,7 +77,11 @@ const relationshipView = (
return ( return (
<td> <td>
<div> <div>
<button className="btn btn-sm btn-danger" onClick={onDelete}> <button
className="btn btn-sm btn-danger"
onClick={onDelete}
data-test="remove-button"
>
Remove Remove
</button> </button>
&nbsp; &nbsp;