Skip to content

Commit

Permalink
feat: add create cluster e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam-Zhao committed Nov 30, 2023
1 parent 5b9b61b commit dd66008
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 132 deletions.
Binary file added cypress/downloads/downloads.html
Binary file not shown.
2 changes: 1 addition & 1 deletion cypress/e2e/404.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('404', () => {
cy.visit('/root');
cy.get('.MuiTypography-h4').should('have.text', 'Something gone wrong!');
cy.get('.MuiButtonBase-root').click();
// Then I see that the current page is the clusters
// Then I see that the current page is the clusters.
cy.url().should('include', '/clusters');
});
});
54 changes: 27 additions & 27 deletions cypress/e2e/clusters.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import root from '../fixtures/api/role-root.json';
import user from '../fixtures/api/user.json';
import seedPeers from '../fixtures/api/clusters/seed-peers.json';
import schedulers from '../fixtures/api/clusters/schedulers.json';
import clusterSearch from '../fixtures/api/clusters/cluster-search.json';
import searchCluster from '../fixtures/api/clusters/search-cluster.json';

describe('Clusters', () => {
beforeEach(() => {
Expand Down Expand Up @@ -117,34 +117,34 @@ describe('Clusters', () => {
});

it('can display clusters card', () => {
// displays a card componen
// Display the card component.
cy.get('.MuiBackdrop-root > .MuiBox-root').should('exist');

// display Default background color
// Show Default background color.
cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > #isDefault')
.should('be.visible')
.and('contain', 'Default')
.and('have.css', 'background-color', 'rgb(46, 143, 121)');

// display cluster name
// Show cluster name.
cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .MuiTypography-h6')
.should('be.visible')
.and('contain', 'cluster-1');

// display cluster description
// Show cluster description.
cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .css-m4gmz7 > .MuiTypography-root')
.should('be.visible')
.and(
'contain',
'Cluster-1 is a high-performance computing cluster located in China, specifically in Hangzhou and Beijing data centers.',
);

// display Non-Default cluster
// Show Non-Default cluster.
cy.get(':nth-child(8) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .MuiTypography-h6')
.should('be.visible')
.and('contain', 'cluster-2');

// display Non-Default background color
// Show Non-Default background color.
cy.get(':nth-child(8) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > #isDefault')
.should('be.visible')
.and('contain', 'Non-Default')
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('Clusters', () => {

it('cluster card should present an empty status', () => {
cy.get('#clusters').should('not.exist');
// shouldn't render pagination buttons
// Shouldn't render pagination buttons.
cy.get('#clusterPagination > .MuiPagination-ul').should('not.exist');
});
});
Expand All @@ -248,10 +248,10 @@ describe('Clusters', () => {
it('pagination updates results and page number', () => {
cy.get('.Mui-selected').invoke('text').should('eq', 'Cluster1');

//total number of pages
// Total number of pages.
cy.get('#clusterPagination > .MuiPagination-ul').children().should('have.length', 4);

// show cluster name
// Show cluster name.
cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .MuiTypography-h6')
.should('be.visible')
.and('contain', 'cluster-1');
Expand All @@ -260,13 +260,13 @@ describe('Clusters', () => {
it('when pagination changes, different page results are rendered', () => {
cy.get('.Mui-selected').invoke('text').should('eq', 'Cluster1');

// go to last page
// Go to last page.
cy.get('.MuiPagination-ul > :nth-child(3) > .MuiButtonBase-root').click();

// display last page cluster information
// Display last page cluster information.
cy.get('.clusters_clusterListContent__UwWjF > .css-k008qs').should('be.visible').and('contain', '8');

// display cluster information
// Display cluster information.
cy.get('#isDefault')
.should('be.visible')
.and('contain', 'Non-Default')
Expand All @@ -283,25 +283,25 @@ describe('Clusters', () => {
'Cluster-8 is a high-performance computing cluster located in China, specifically in Jiangsu data centers.',
);

// current page number
// Current page number.
cy.get('#clusterPagination > .MuiPagination-ul .Mui-selected').should('have.text', '2');
});

it('pagination resets results and page number to first page when refresh is clicked', () => {
// Go to last page
// Go to last page.
cy.get('.MuiPagination-ul > :nth-child(3) > .MuiButtonBase-root').click();

cy.get('.clusters_clusterListContent__UwWjF > .MuiTypography-h6')
.should('be.visible')
.and('contain', 'cluster-8');

cy.get('#clusterPagination > .MuiPagination-ul .Mui-selected').should('have.text', '2');
// refresh page
// Refresh page.
cy.reload().then(() => {
cy.wait(2000);
});

// page numbers have been reset
// Page numbers have been reset.
cy.get('#clusterPagination > .MuiPagination-ul .Mui-selected').should('have.text', '1');

cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .MuiTypography-h6')
Expand Down Expand Up @@ -338,12 +338,12 @@ describe('Clusters', () => {
});

it('show error message', () => {
// show error message
// Show error message.
cy.get('.css-1rr4qq7 > .MuiSnackbar-root > .MuiPaper-root > .MuiAlert-message')
.should('be.visible')
.and('contain', 'Failed to fetch');

// close error message
// Close error message.
cy.get('.css-1rr4qq7 > .MuiSnackbar-root > .MuiPaper-root > .MuiAlert-action > .MuiButtonBase-root').click();
cy.get('.css-1rr4qq7 > .MuiSnackbar-root > .MuiPaper-root > .MuiAlert-message').should('not.exist');
});
Expand Down Expand Up @@ -392,9 +392,9 @@ describe('Clusters', () => {
});

it('cluster card should present an empty status', () => {
// no clusters
// No clusters.
cy.get('#clusters').should('not.exist');
// no pagination
// No pagination.
cy.get('#clusterPagination > .MuiPagination-ul').should('not.exist');
});
});
Expand All @@ -409,20 +409,20 @@ describe('Clusters', () => {
(req) => {
req.reply({
statusCode: 200,
body: clusterSearch,
body: searchCluster,
});
},
);
cy.get('#free-solo-demo').type('cluster-1{enter}');
cy.get('#clusterPagination > .MuiPagination-ul').should('not.exist');

// clear search box
// Clear search box.
cy.get('#free-solo-demo').clear();
//search all clusters
cy.get('#free-solo-demo').type('{enter}');
cy.get('#clusterPagination > .MuiPagination-ul').should('exist');

// number of pagination
// Number of pagination.
cy.get('#clusterPagination > .MuiPagination-ul').children().should('have.length', 4);

cy.get(':nth-child(1) > .MuiPaper-root > .clusters_clusterListContent__UwWjF > .MuiTypography-h6')
Expand All @@ -449,9 +449,9 @@ describe('Clusters', () => {
);

cy.get('#free-solo-demo').type('cluster-16{enter}');
//no clusters card
// No clusters card.
cy.get('#clusters').should('not.exist');
// hidden pagination
// Hidden pagination.
cy.get('#clusterPagination > .MuiPagination-ul').should('not.exist');
});

Expand All @@ -470,7 +470,7 @@ describe('Clusters', () => {

cy.get('#free-solo-demo').clear();
cy.get('#free-solo-demo').type('cluster-1{enter}');
// error message
// Error message.
cy.get('.MuiAlert-message').should('be.visible').and('contain', 'Failed to fetch');
});
});
Expand Down
Loading

0 comments on commit dd66008

Please sign in to comment.