Skip to content

Commit

Permalink
Added new Cypress Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyuk1986 authored and karesti committed Oct 21, 2024
1 parent 5988ed6 commit ceb074d
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 24 deletions.
23 changes: 21 additions & 2 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.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.');
// TODO: remove needs to be tested with REST API fixes
//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');
});

});
33 changes: 25 additions & 8 deletions cypress/e2e/1_cluster-welcome.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ describe('Welcome page', () => {
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 @@ -61,6 +66,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 All @@ -78,7 +95,7 @@ describe('Welcome page', () => {
cy.get('[role=dialog]').should('be.visible');
cy.contains('Version');
cy.get('body').then(($body) => {
if (!$body.text().includes('Red Hat Datagrid')) {
if (!$body.text().includes('Red Hat Data Grid')) {
//Checks if links from About dialog work properly
cy.get('a[href*="github"').should('exist');
cy.get('a[href*="zulipchat"').should('exist');
Expand Down
17 changes: 17 additions & 0 deletions 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();

//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.")
}
});
});
});

});
53 changes: 41 additions & 12 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 Down Expand Up @@ -328,17 +328,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
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');
});
});
8 changes: 8 additions & 0 deletions cypress/e2e/3_cache-crud-wizard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ describe('Cache Creation Wizard', () => {
cy.get('[data-cy=wizardNextButton]').click();
cy.get('[data-cy=provideConfigArea] > button').click();

if (Cypress.browser.name === "firefox") {
//At the moment do nothing as the proper command for editing the config is not found yet
} else {
cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' )
.type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}")
.type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}")
.type("{shift}{end}").type("{del}{del}").type("{enter}{upArrow}").type('"distributed-cache": {{}"mode": "ASYNC", "statistics": true }{del}');
}

cy.get('[data-cy=wizardNextButton]').click();
cy.contains('Cache aSimpleCache created with the provided configuration.');
Expand All @@ -194,6 +198,9 @@ describe('Cache Creation Wizard', () => {
cy.get('[data-cy=wizardNextButton]').click();
cy.get('[data-cy=provideConfigArea] > button').click();

if (Cypress.browser.name === "firefox") {
//At the moment do nothing as the proper command for editing the config is not found yet
} else {
cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' )
.type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}")
.type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}")
Expand All @@ -205,6 +212,7 @@ describe('Cache Creation Wizard', () => {
</local-cache>',
{ parseSpecialCharSequences: false }
).type("{del}{del}").type("{upArrow}{backspace}");
}
cy.get('[data-cy=wizardNextButton]').click();
cy.contains('Cache aSimpleXmlCache created with the provided configuration.');
// Once the cache created, redirection to main page is done and the cache should be visible
Expand Down
12 changes: 12 additions & 0 deletions cypress/e2e/3_client-connection.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ describe('Client connection page', () => {
cy.contains('Protocol').should('exist');
cy.contains('infinispan-4-e2e').should('exist');
});

it('successfully filters and refreshes the page', () => {
cy.get('[aria-label="Search input"]').type('test');
cy.contains('infinispan-4-e2e').should('not.exist');
cy.contains('No filtered connected clients').should('exist');
//Refreshing the page
cy.get('[data-cy=aclActions]').click();
cy.get('[data-cy=refreshAction]').click();
//Check that page is refreshed properly
cy.contains('infinispan-4-e2e').should('exist');
cy.contains('No filtered connected clients').should('not.exist');
});
});
10 changes: 9 additions & 1 deletion cypress/e2e/3_proto-schema.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,24 @@ describe('Proto Schema CRUD', () => {
cy.get('[aria-label="editSchemaAction"]').click();
cy.contains('schemaValue');
cy.contains('Save');
//Artificially adding here some delays between actions so that the proto schema is updated properly and normally shown on the page.
cy.wait(3000);
cy.get('[data-cy=schemaEditArea]').type('{selectall}', { timeout: 10000 });
cy.wait(3000);
cy.get('[data-cy=schemaEditArea]').type(
'package org.infinispan; message ExampleProto { optional int32 other_id = 1; }',
{ parseSpecialCharSequences: false }
);
cy.wait(3000);
cy.get('button[aria-label="confirm-edit-schema-button"]').click();
cy.wait(3000);
cy.contains('Schema ' + schemaName +'.proto updated.');
cy.wait(3000);
cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup.
//Waiting 5 seconds so that the proto schema is managed to be updated on the page.
cy.wait(3000);
cy.get('[data-cy="' + schemaName + '.protoConfig"]').click();

cy.wait(3000);
cy.contains('schemaValue').should('not.exist');
cy.contains('ExampleProto');
cy.contains('Schema ' + schemaName + '.proto has errors').should('not.exist');
Expand Down
1 change: 1 addition & 0 deletions src/app/AccessManagement/RemovePrincipal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const RemovePrincipal = (props: {
<Button
key={'Remove'}
aria-label={'Remove'}
data-cy="removePrincipalButton"
variant={ButtonVariant.warning}
onClick={() => {
onRemove();
Expand Down
1 change: 1 addition & 0 deletions src/app/ClusterStatus/ClusterStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const ClusterStatus = () => {
<Td dataLabel={columnNames.physicalAdd}>{row.physical_address}</Td>
<Td dataLabel={columnNames.physicalAdd}>
<Button
data-cy="downloadReportLink"
variant="link"
isInline
isLoading={isDownloading}
Expand Down
2 changes: 1 addition & 1 deletion src/app/GlobalStats/GlobalStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const GlobalStats = () => {
<CardBody>
<TextContent style={{ height: '208px' }}>
<TextList component={TextListVariants.dl}>
<TextListItem component={TextListItemVariants.dt}>
<TextListItem component={TextListItemVariants.dt} data-cy="cacheManagerStartTime">
{displayUtils.formatNumber(stats.time_since_start)}
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
Expand Down

0 comments on commit ceb074d

Please sign in to comment.