Skip to content

Commit

Permalink
feat: change page loading function (#367)
Browse files Browse the repository at this point in the history
Signed-off-by: zhaoxinxin <[email protected]>
  • Loading branch information
Liam-Zhao authored Apr 17, 2024
1 parent d00869e commit d7c47f1
Show file tree
Hide file tree
Showing 20 changed files with 459 additions and 308 deletions.
257 changes: 177 additions & 80 deletions cypress/e2e/clusters/cluster.cy.ts

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions cypress/e2e/clusters/update-cluster.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Update cluster', () => {

cy.get(':nth-child(2) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root')
.should('contain', 'Hangzhou')
.and('contain', 'Shanghai')
.and('contain', 'Shanghai');

cy.get(':nth-child(3) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root')
.should('contain', '10.0.0.0/8')
Expand Down Expand Up @@ -87,30 +87,30 @@ describe('Update cluster', () => {
req.reply({
statusCode: 200,
body: {
"id": 0,
"name": "",
"bio": "",
"scopes": {
"idc": "",
"location": "",
"cidrs": null,
"hostnames": null
id: 0,
name: '',
bio: '',
scopes: {
idc: '',
location: '',
cidrs: null,
hostnames: null,
},
"scheduler_cluster_id": 1,
"seed_peer_cluster_id": 1,
"scheduler_cluster_config": {
"candidate_parent_limit": 0,
"filter_parent_limit": 0
scheduler_cluster_id: 1,
seed_peer_cluster_id: 1,
scheduler_cluster_config: {
candidate_parent_limit: 0,
filter_parent_limit: 0,
},
"seed_peer_cluster_config": {
"load_limit": 0
seed_peer_cluster_config: {
load_limit: 0,
},
"peer_cluster_config": {
"load_limit": 0
peer_cluster_config: {
load_limit: 0,
},
"created_at": "2023-03-08T02:39:03Z",
"updated_at": "2023-03-08T02:39:03Z",
"is_default": true
created_at: '2023-03-08T02:39:03Z',
updated_at: '2023-03-08T02:39:03Z',
is_default: false,
},
});
},
Expand Down
11 changes: 5 additions & 6 deletions cypress/e2e/schedulers/scheduler.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ describe('Scheduler', () => {
it('click the hostname', () => {
cy.visit('/clusters/1');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
).should('have.text', 'scheduler-7');
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2) > .MuiTypography-root').should(
'have.text',
'scheduler-7',
);

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
).click();
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2) > .MuiTypography-root').click();

// Then I see that the current page is the clusters/1/schedulers/7!
cy.url().should('include', '/clusters/1/schedulers/7');
Expand Down
89 changes: 23 additions & 66 deletions cypress/e2e/schedulers/schedulers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,12 @@ describe('Schedulers', () => {

it('can display schedulers table', () => {
// Show hostname.
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2) > .MuiTypography-root')
.should('be.visible')
.and('contain', 'scheduler-7');

// Show ip.
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(3) > .show_ipContainer__pzOmv',
)
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(3) > .show_ipContainer__pzOmv')
.should('be.visible')
.and('contain', '30.44.98.202');

Expand All @@ -82,27 +78,21 @@ describe('Schedulers', () => {
.and('have.css', 'background-color', 'rgb(46, 143, 121)');

// Show features.
cy.get(':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(6)')
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(6)')
.should('be.visible')
.and('contain', 'Schedule')
.and('contain', 'Preheat');

// Show scheduler-5 information.
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(2) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(2) > :nth-child(2) > .MuiTypography-root')
.should('be.visible')
.and('contain', 'scheduler-5');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(2) > :nth-child(3) > .show_ipContainer__pzOmv',
)
cy.get('#scheduler-table-body > :nth-child(2) > :nth-child(3)')
.should('be.visible')
.and('contain', '20.14.28.202');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(5) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(5) > :nth-child(2)')
.scrollIntoView()
.should('be.visible')
.and('contain', 'scheduler-10');
Expand Down Expand Up @@ -141,9 +131,7 @@ describe('Schedulers', () => {
});

it('there should be a message indicating that there is no scheduler', () => {
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', `You don't have scheduler cluster.`);
});
Expand Down Expand Up @@ -180,9 +168,7 @@ describe('Schedulers', () => {
});

it('there should be a message indicating that there is no scheduler', () => {
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', `You don't have scheduler cluster.`);
});
Expand All @@ -204,19 +190,14 @@ describe('Schedulers', () => {
.and('have.text', 'scheduler-7');

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

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableHead-root > .MuiTableRow-root > :nth-child(2)',
).scrollIntoView();
cy.get('#scheduler-pagination > .MuiPagination-ul > :nth-child(3) > .MuiButtonBase-root').click();

// Check the current page number.
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '2');

// Show scheduler information.
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2)')
.scrollIntoView()
.should('be.visible')
.and('contain', 'scheduler-11');

Expand All @@ -230,9 +211,7 @@ describe('Schedulers', () => {
// Check the current page number.
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '3');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > :nth-child(2)')
.should('be.visible')
.and('contain', 'scheduler-2');
});
Expand All @@ -244,9 +223,7 @@ describe('Schedulers', () => {
// Check the current page number.
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '3');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', 'scheduler-2');

Expand All @@ -270,9 +247,7 @@ describe('Schedulers', () => {
// Check the current page number.
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '3');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', 'scheduler-2');

Expand All @@ -288,9 +263,7 @@ describe('Schedulers', () => {
// Check the current page number.
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '3');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', 'scheduler-2');
});
Expand All @@ -313,19 +286,15 @@ describe('Schedulers', () => {

cy.get('#scheduler-table-body').children().should('have.length', 5);

cy.get(
':nth-child(6) > .show_searchContainer__6kD-7 > .MuiStack-root > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root',
).type('scheduler-8{enter}');
cy.get('#free-solo-demo').type('scheduler-8{enter}');

cy.get('#scheduler-table-body').children().should('have.length', 1);

// Pagination has been hidden.
cy.get('#scheduler-pagination > .MuiPagination-ul').should('not.exist');

// Clear search box.
cy.get(
':nth-child(6) > .show_searchContainer__6kD-7 > .MuiStack-root > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root',
).clear();
cy.get('#free-solo-demo').clear();

// If the search is empty, all schedulers will be displayed.
cy.get('#scheduler-button').click();
Expand All @@ -348,14 +317,10 @@ describe('Schedulers', () => {
},
);

cy.get(
':nth-child(6) > .show_searchContainer__6kD-7 > .MuiStack-root > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root',
).type('scheduler-12{enter}');
cy.get('#free-solo-demo').type('scheduler-12{enter}');

// No scheduler.
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root',
)
cy.get('#scheduler-table-body > .MuiTableRow-root > .MuiTableCell-root')
.should('be.visible')
.and('contain', `You don't have scheduler cluster.`);

Expand All @@ -376,9 +341,7 @@ describe('Schedulers', () => {
},
);

cy.get(
':nth-child(6) > .show_searchContainer__6kD-7 > .MuiStack-root > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root',
).type('scheduler-12{enter}');
cy.get('#free-solo-demo').type('scheduler-12{enter}');

// Show error message.
cy.get('.MuiAlert-message').should('have.text', 'Failed to fetch');
Expand Down Expand Up @@ -446,9 +409,7 @@ describe('Schedulers', () => {
// Go to next page.
cy.get('#scheduler-pagination > .MuiPagination-ul > :nth-child(3) > .MuiButtonBase-root').click();
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '2');
cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(5) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(5) > :nth-child(2)')
.should('be.visible')
.and('contain', 'scheduler-4');
cy.get('#scheduler-4').click();
Expand Down Expand Up @@ -515,9 +476,7 @@ describe('Schedulers', () => {
},
).as('delete');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2)')
.should('be.visible')
.and('contain', 'scheduler-7');

Expand All @@ -542,9 +501,7 @@ describe('Schedulers', () => {
},
).as('delete');

cy.get(
':nth-child(6) > .css-8atqhb > .MuiTable-root > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root',
)
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2)')
.should('be.visible')
.and('contain', 'scheduler-7');

Expand Down
Loading

0 comments on commit d7c47f1

Please sign in to comment.