Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new Cypress tests. #493

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default defineConfig({
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:11222/console/',
baseUrl: 'http://localhost:11222/console/'
},
})
25 changes: 22 additions & 3 deletions cypress/e2e/1_acess_management.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,35 @@ describe('Global stats', () => {
cy.get("[data-cy=option-typeahead-deployer]").click();
cy.get("[data-cy=menu-toogle-roles]").click();
cy.get('[aria-label=Save').click();
// cy.contains('Access granted to aPrincipal.');
cy.contains('Access granted to aPrincipal.');
cy.get('[data-cy=detailLink-admin]').should('not.exist');
cy.get('[data-cy=detailLink-deployer]').should('exist');
cy.get('[aria-label^="Close"]').first().click();
//@TODO uncomment when ISPN-16618 is fixed
//Managing roles of the principal
// cy.get("[aria-label=aPrincipal-menu]").click();
// cy.get("[aria-label=manageRoles]").click();
// cy.get("[data-cy=menu-toogle-roles]").click();
// cy.get("[data-cy=option-typeahead-admin]").click();
// cy.get("[data-cy=option-typeahead-deployer]").click();
// cy.get("[data-cy=menu-toogle-roles]").click();
// cy.get('[aria-label=Save').click();
// cy.contains('Roles [admin] granted to aPrincipal.');
// TODO: remove needs to be tested with REST API fixes
// cy.get('[data-cy=detailLink-admin]').should('exist');
// cy.get('[data-cy=detailLink-deployer]').should('not.exist');
//@TODO uncomment when the both popups will be shown properly
//cy.contains('Roles [admin] granted to aPrincipal.');
//cy.contains('Roles [deployer] denied to aPrincipal.');

//Removing principal
// cy.get("[aria-label=aPrincipal-menu]").click();
// cy.get("[aria-label=removePrincipal]").click();
// cy.get("[data-cy=cancelPrincipalRemoveButton]").click();
// cy.contains("aPrincipal");
// cy.get("[aria-label=aPrincipal-menu]").click();
// cy.get("[aria-label=removePrincipal]").click();
// cy.get("[data-cy=removePrincipalButton]").click();
// cy.contains('aPrincipal successfully removed.')
// cy.contains('aPrincipal').should('not.exist');
});

});
32 changes: 24 additions & 8 deletions cypress/e2e/1_cluster-welcome.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ describe('Welcome page', () => {
cy.contains('Running'); // cluster status
cy.contains('Cluster rebalancing on'); // rebalancing status
cy.contains('Tracing is enabled'); // tracing status
cy.contains('Data container');
cy.contains('15 Caches');
cy.contains('10 Counters');
cy.contains('1 Tasks');
cy.contains('13 Schemas');
cy.contains('invalidationCache');

//Checks that user's dropbox exists on the page.
cy.contains('admin').click();
cy.contains('Logout').click();
cy.get('h1')
.invoke('text')
.should('match', /.* Server.*/);
cy.contains('Open the console');
if (Cypress.browser.name === 'firefox') {
cy.contains('admin');
cy.get('[aria-label*="incognito"]').should('exist');
} else {
//Checks that user's dropbox exists on the page.
cy.contains('admin').click();
cy.contains('Logout').click();
cy.get('h1')
.invoke('text')
.should('match', /.* Server.*/);
cy.contains('Open the console');
}
});

it('successfully opens and navigates side menu', () => {
Expand Down Expand Up @@ -63,6 +67,18 @@ describe('Welcome page', () => {
cy.contains('Cluster-wide statistics');
cy.contains('Cache Manager lifecycle values');

//Clicks the Access management link and should go to Access management page
cy.contains('Access Management').click();
cy.contains('Access management').should('be.visible');
cy.contains('Access control');
cy.contains('Create role');

//Clicks the Connected clients link and should go to Connected clients page
cy.contains('Connected Clients').click();
cy.contains('Connected clients').should('be.visible');
cy.contains('Client library');
cy.contains('Server node');

//Clicks the Data Container link and should go to Data Container page
cy.contains('Data Container').click();
cy.contains('Data container').should('be.visible');
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/1_data-container.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Data Container Overview', () => {
it('successfully loads Data Container Overview', () => {
cy.contains('Data container');
cy.contains('Running'); // cluster status
cy.contains('Tracing is enabled');
cy.contains('Cluster rebalancing on'); // rebalancing status
cy.get('#cluster-manager-header').should('exist');
cy.get('[data-cy=cacheManagerStatus]').should('exist');
Expand Down
19 changes: 18 additions & 1 deletion cypress/e2e/1_global-stats.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,25 @@ describe('Global stats', () => {
cy.get('[data-cy="clearAccessMetricsButton"]').click();
cy.contains('Permanently clear global metrics?');
cy.get('[data-cy="confirmButton"]').click();
cy.contains('Global metrics cleared');
cy.get('[data-cy="globalStatsActions"]').click();
cy.get('[data-cy="refreshAction"]').click();

//Comparing the value of the start time before and after refresh to make sure that refresh takes place
cy.get('[data-cy=cacheManagerStartTime]').then(($field) => {
const timeTextBefore = $field.text();
//Wait for a few seconds before refresh
cy.wait(2000);

//Refreshing the stat page
cy.get('[data-cy="refreshAction"]').click();

cy.get('[data-cy=cacheManagerStartTime]').then(($field) => {
const timeTextAfter = $field.text();
if (timeTextBefore === timeTextAfter) {
throw new Error("The page was not refreshed properly.")
}
});
});
});

});
62 changes: 49 additions & 13 deletions cypress/e2e/1_rbac_func.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('RBAC Functionality Tests', () => {
checkNonSecuredCacheDetailView(false, false);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
checkSchemasPageView(false);
checkCountersPageView();
checkCountersPageView(false);
cy.login(observerUserName, Cypress.env('password'), '/cache/not-encoded');
checkNoEntriesTabView(false);
cy.login(observerUserName, Cypress.env('password'), '/global-stats');
Expand All @@ -54,7 +54,7 @@ describe('RBAC Functionality Tests', () => {
checkNonSecuredCacheDetailView(false, false);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
checkSchemasPageView(false);
checkCountersPageView();
checkCountersPageView(false);
cy.login(applicationUserName, Cypress.env('password'), '/cache/not-encoded');
checkNoEntriesTabView(false);
cy.login(applicationUserName, Cypress.env('password'), '/global-stats');
Expand All @@ -73,7 +73,7 @@ describe('RBAC Functionality Tests', () => {
checkNonSecuredCacheDetailView(false, false);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
checkSchemasPageView(true);
checkCountersPageView();
checkCountersPageView(false);
cy.login(deployerUserName, Cypress.env('password'), '/cache/not-encoded');
checkNoEntriesTabView(false);
cy.login(deployerUserName, Cypress.env('password'), '/global-stats');
Expand All @@ -92,7 +92,7 @@ describe('RBAC Functionality Tests', () => {
checkNonSecuredCacheDetailView(false, true);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
checkSchemasPageView(true);
checkCountersPageView();
checkCountersPageView(true);
checkTasksPage();
cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/not-encoded');
checkNoEntriesTabView(true);
Expand All @@ -114,7 +114,7 @@ describe('RBAC Functionality Tests', () => {
function checkDataContainerView(isMonitor, isDeployer, isAdmin, isSuperAdmin) {
//Checking Data Container view
cy.contains('Data container'); // cluster name
cy.contains('Running'); // cluster status
cy.contains('Tracing is enabled'); // Tracing enabled
if (isSuperAdmin) {
cy.get('[data-cy=rebalancingSwitch]').should('exist'); // rebalancing status
} else {
Expand Down Expand Up @@ -190,6 +190,13 @@ describe('RBAC Functionality Tests', () => {
}

cy.get('[data-cy=detailCacheActions]').click();
if(isSuperAdmin) {
cy.get('[data-cy=manageTracingLink]').should('exist');
} else {
//@TODO uncomment when ISPN-16622 is fixed.
//cy.get('[data-cy=manageTracingLink]').should('not.exist');
}

cy.get('[data-cy=manageIndexesLink]').click();
if (isSuperAdmin) {
cy.get('[data-cy=clearIndexButton]').should('exist');
Expand Down Expand Up @@ -328,17 +335,46 @@ describe('RBAC Functionality Tests', () => {
}
}

function checkCountersPageView() {
function checkCountersPageView(isSuperAdmin) {
//Checking counters page
cy.get('a[aria-label="nav-item-Counters"]').click();
cy.contains('strong-1');
// cy.get('#counterFilterSelect').should('exist');
// cy.contains('td', 'strong-1').parent()
// .within($tr => {
// cy.get('td button').should('exist');
// cy.get('td button').click();
// cy.get('[data-cy=deleteCounter]').should('exist');
// });
cy.get('body').then(($body) => {
if ($body.find('button[aria-label="Show Filters"]').length) {
cy.get('button[aria-label="Show Filters"]').click();
}
})

cy.get('[data-cy=counterFilterSelectExpanded]').should('exist');
//Checking delete counter functionality
cy.contains('td', 'strong-1').parent()
.within($tr => {
cy.get('td button').should('exist');
cy.get('td button').click();
cy.get('[aria-label="deleteCounter"]').should('exist');
cy.get('[aria-label="deleteCounter"]').click();
});
cy.get('[data-cy="deleteCounterButton"]').should('exist');
if (isSuperAdmin) {
cy.get('[data-cy="deleteCounterButton"]').should('not.be.disabled');
} else {
cy.get('[data-cy="deleteCounterButton"]').should('be.disabled');
}
cy.get('[data-cy="cancelCounterDeleteButton"]').click();
//Checking edit for counter functionality
cy.contains('td', 'strong-1').parent()
.within($tr => {
cy.get('td button').should('exist');
cy.get('td button').click();
cy.get('[aria-label="setCounterAction"]').should('exist');
cy.get('[aria-label="setCounterAction"]').click();
});
cy.get('[data-cy="confirmSetbutton"]').should('exist');
cy.get('[data-cy="confirmSetbutton"]').should('not.be.disabled');
cy.get('[data-cy="cancelSetButton"]').click();
if (isSuperAdmin) {
cy.get('[data-cy="createCounterButton"]').should('exist');
}
}

function checkActionsOnSuperCache() {
Expand Down
18 changes: 18 additions & 0 deletions cypress/e2e/2_cache-detail.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ describe('Cache Detail Overview', () => {
cy.contains('-2147483647').should('not.exist');
});

it('successfully switches on/off rebalancing of the cache', () => {
cy.get('#rebalancing-switch').click({force: true});
cy.contains('Disable rebalancing on this cache?');
//Testing cancel button
cy.get('[data-cy=rebalanceChangeCancelButton]').click();
cy.contains('Disable rebalancing on this cache?').should('not.exist');
//Testing switching off functionality
cy.get('#rebalancing-switch').click({force: true});
cy.contains('Disable rebalancing on this cache?');
cy.get('[data-cy=rebalanceChangeButton]').click();
cy.contains('Rebalancing is off');
//Testing switching on again
cy.get('#rebalancing-switch').click({force: true});
cy.contains('Enable rebalancing on this cache?');
cy.get('[data-cy=rebalanceChangeButton]').click();
cy.contains('Rebalancing is on');
});

function verifyGet(keyType, key, value) {
// Going back to cache entries page
cy.get('[data-cy=cacheEntriesTab]').click();
Expand Down
63 changes: 34 additions & 29 deletions cypress/e2e/2_cache-tracing.cy.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
describe('Cache Tracing', () => {
it('successfully displays tracing and changes options', () => {
cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/people');
cy.contains('Tracing is enabled');

cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageTracingLink]").click();
cy.get('[data-cy=tracingSwitch]').should('exist');
cy.get('[data-cy=tracingSwitch]').uncheck({force: true});
cy.get('[data-cy=saveButton]').click();
cy.get('[data-cy=backButton]').click();
cy.contains('Detail of cache people');
cy.contains('Tracing is disabled');

cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageTracingLink]").click();
cy.get('[data-cy=tracingSwitch]').check({force: true});
cy.contains('Categories');
cy.contains('container');
cy.get('[data-cy=menu-toogle-categorySelector]').click();
cy.get('[data-cy=option-typeahead-x-site]').click();
cy.get('[data-cy=option-typeahead-cluster]').click();
cy.get('[data-cy=option-typeahead-persistence]').click();
cy.get('[data-cy=menu-toogle-categorySelector]').click();
cy.get('[data-cy=saveButton]').click();
cy.contains('Cache people successfully updated.');
cy.get('[data-cy=backButton]').click();
cy.contains('Detail of cache people');
cy.contains('Tracing is enabled');
});
const cacheNames = ['people', 'indexed-cache']; //non-auth and auth caches

cacheNames.forEach((cacheName) => {
it('successfully displays tracing and changes options for cache ' + cacheName, () => {
cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/' + cacheName);
cy.contains('Tracing is enabled');

cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageTracingLink]").click();
cy.get('[data-cy=tracingSwitch]').should('exist');
cy.get('[data-cy=tracingSwitch]').uncheck({force: true});
cy.get('[data-cy=saveButton]').click();
cy.get('[data-cy=backButton]').click();
cy.contains('Detail of cache ' + cacheName);
cy.contains('Tracing is disabled');

cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageTracingLink]").click();
cy.get('[data-cy=tracingSwitch]').check({force: true});
cy.contains('Categories');
cy.contains('container');
cy.get('[data-cy=menu-toogle-categorySelector]').click();
cy.get('[data-cy=option-typeahead-x-site]').click();
cy.get('[data-cy=option-typeahead-cluster]').click();
cy.get('[data-cy=option-typeahead-persistence]').click();
cy.get('[data-cy=menu-toogle-categorySelector]').click();
cy.get('[data-cy=saveButton]').click();
cy.contains('Cache ' + cacheName + ' successfully updated.');
cy.get('[data-cy=backButton]').click();
cy.contains('Detail of cache ' + cacheName);
cy.contains('Tracing is enabled');
});
})

});
8 changes: 8 additions & 0 deletions cypress/e2e/2_cluster-membership.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ describe('Cluster Membership', () => {

it('successfully loads Cluster Membership', () => {
cy.get('h1').should('contain', 'Cluster membership');
cy.contains('1 member in use');
cy.get('[data-cy="downloadReportLink"]').should('exist');
//@TODO Uncomment and fix this part after ISPN-16672 is fixed
// cy.get('[data-cy="downloadReportLink"]').click();
// cy.wait(5000);
// let downloadedFile = cy.readFile('./cypress/downloads/downloadedFileName');
// downloadedFile.should('exist');
// downloadedFile.its('distributed-cache.mode').should('eq', 'SYNC');
});
});
Loading
Loading