Skip to content

Commit 45b6a16

Browse files
authored
chore: change scheduler e2e test (#506)
Signed-off-by: zhaoxinxin <1186037180@qq.com>
1 parent 9fa12d4 commit 45b6a16

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

cypress/e2e/schedulers/scheduler.cy.ts

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -75,59 +75,55 @@ describe('Scheduler', () => {
7575

7676
it('click the breadcrumb', () => {
7777
// Check for breadcrumb.
78-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
79-
.should('be.visible')
80-
.and('contain', 'scheduler-cluster-1');
78+
cy.get('#cluster-id').should('be.visible').and('contain', 'scheduler-cluster-1');
8179

82-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root').click();
80+
cy.get('#cluster-id').click();
8381

8482
// Then I see that the current page is the clusters/1!
8583
cy.url().should('include', '/clusters/1');
8684
});
8785

8886
describe('when data is loaded', () => {
8987
it('can display breadcrumb', () => {
90-
// Show isloading.
88+
// Display is loading.
9189
cy.get('[data-testid="isloading"]').should('be.exist');
9290

93-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
94-
.should('be.visible')
95-
.and('contain', 'scheduler-cluster-1');
91+
cy.get('#cluster-id').should('be.visible').and('contain', 'scheduler-cluster-1');
9692

97-
cy.get(':nth-child(7) > .MuiTypography-root').should('be.visible').and('contain', 'scheduler-7');
93+
cy.get('#scheduler-host-name').should('be.visible').and('contain', 'scheduler-7');
9894

9995
cy.get('[data-testid="isloading"]').should('not.exist');
10096
});
10197

10298
it('can display active scheduler', () => {
103-
// Show id.
99+
// Displays the scheduler ID.
104100
cy.get('#id').should('be.visible').and('contain', '7');
105101

106-
// Show hostname.
102+
// Displays the scheduler hostname.
107103
cy.get('#hostname').should('be.visible').and('contain', 'scheduler-7');
108104

109-
// Show ip.
105+
// Displays the scheduler IP.
110106
cy.get('#ip').should('be.visible').and('contain', '30.44.98.202');
111107

112-
// Show cluster id.
108+
// Displays the scheduler cluster ID.
113109
cy.get('#cluster-id').should('be.visible').and('contain', '1');
114110

115-
// Show port.
111+
// Displays the scheduler port.
116112
cy.get('#port').should('be.visible').and('contain', '8002');
117113

118-
// Show Active background color.
114+
// Displays the active background color.
119115
cy.get('#status')
120116
.should('be.visible')
121117
.and('contain', 'Active')
122118
.and('have.css', 'background-color', 'rgb(0, 129, 112)');
123119

124-
// Show features.
120+
// Displays the scheduler features.
125121
cy.get('#features').should('be.visible').and('contain', 'Schedule').and('contain', 'Preheat');
126122

127-
// Show created at.
123+
// Displays the scheduler creation time.
128124
cy.get('#created-at').should('have.text', '2023-11-09 07:09:06');
129125

130-
// Show updated at.
126+
// Displays the scheduler update time.
131127
cy.get('#updated-at').should('have.text', '2023-11-09 07:09:11');
132128
});
133129

@@ -147,10 +143,10 @@ describe('Scheduler', () => {
147143

148144
cy.visit('/clusters/1/schedulers/2');
149145

150-
// Show hostname.
146+
// Displays the scheduler hostname.
151147
cy.get('#hostname').should('be.visible').and('contain', 'scheduler-2');
152148

153-
// Show Inactive background color.
149+
// Displays the inactive background color.
154150
cy.get('#status')
155151
.should('be.visible')
156152
.and('contain', 'Inactive')
@@ -169,39 +165,37 @@ describe('Scheduler', () => {
169165
});
170166

171167
it('unable to display breadcrumb', () => {
172-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
173-
.should('be.visible')
174-
.and('contain', 'scheduler-cluster-1');
168+
cy.get('#cluster-id').should('be.visible').and('contain', 'scheduler-cluster-1');
175169

176-
cy.get(':nth-child(7) > .MuiTypography-root').should('be.visible').and('contain', '-');
170+
cy.get('#scheduler-host-name').should('be.visible').and('contain', '-');
177171
});
178172

179173
it('scheduler should render empty status', () => {
180-
// Show ID.
174+
// Displays the scheduler ID.
181175
cy.get('#id').should('contain', '-');
182176

183-
// Show Hostname.
177+
// Displays the scheduler hostname.
184178
cy.get('#hostname').should('contain', '-');
185179

186-
// Show IP.
180+
// Displays the scheduler IP.
187181
cy.get('#ip').should('contain', '-');
188182

189-
// Show Cluster ID.
183+
// Displays the scheduler cluster ID.
190184
cy.get('#cluster-id').should('contain', '-');
191185

192-
// Show Port.
186+
// Displays the scheduler port.
193187
cy.get('#port').should('contain', '-');
194188

195-
// Show Start.
189+
// Displays the scheduler status.
196190
cy.get('#status').should('contain', '-');
197191

198-
// Show Features.
192+
// Displays the scheduler features.
199193
cy.get('#features').should('contain', '-');
200194

201-
// Show Created At.
195+
// Displays the scheduler creation time.
202196
cy.get('#created-at').should('contain', '-');
203197

204-
// Show Updated At.
198+
// Displays the scheduler update time.
205199
cy.get('#updated-at').should('contain', '-');
206200
});
207201
});
@@ -224,47 +218,45 @@ describe('Scheduler', () => {
224218

225219
it('show error message', () => {
226220
// Show error message.
227-
cy.get('.MuiAlert-message').should('be.visible').and('contain', 'Failed to fetch');
221+
cy.get('#error-message').should('be.visible').and('contain', 'Failed to fetch');
228222

229223
// Close error message.
230224
cy.get('.MuiAlert-action > .MuiButtonBase-root').click();
231-
cy.get('.MuiAlert-message').should('not.exist');
225+
cy.get('#error-message').should('not.exist');
232226
});
233227

234228
it('unable to display breadcrumb', () => {
235-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
236-
.should('be.visible')
237-
.and('contain', 'scheduler-cluster-1');
229+
cy.get('#cluster-id').should('be.visible').and('contain', 'scheduler-cluster-1');
238230

239-
cy.get(':nth-child(7) > .MuiTypography-root').should('be.visible').and('contain', '-');
231+
cy.get('#scheduler-host-name').should('be.visible').and('contain', '-');
240232
});
241233

242234
it('scheduler should render empty status', () => {
243-
// Show ID.
235+
// Displays the scheduler ID.
244236
cy.get('#id').should('contain', '-');
245237

246-
// Show Hostname.
238+
// Displays the scheduler hostname.
247239
cy.get('#hostname').should('contain', '-');
248240

249-
// Show IP.
241+
// Displays the scheduler IP.
250242
cy.get('#ip').should('contain', '-');
251243

252-
// Show Cluster ID.
244+
// Displays the scheduler cluster ID.
253245
cy.get('#cluster-id').should('contain', '-');
254246

255-
// Show Port.
247+
// Displays the scheduler port.
256248
cy.get('#port').should('contain', '-');
257249

258-
// Show Start.
250+
// Displays the scheduler status.
259251
cy.get('#status').should('contain', '-');
260252

261-
// Show Features.
253+
// Displays the scheduler features.
262254
cy.get('#features').should('contain', '-');
263255

264-
// Show Created At.
256+
// Displays the scheduler creation time.
265257
cy.get('#created-at').should('contain', '-');
266258

267-
// Show Updated At.
259+
// Displays the scheduler update time.
268260
cy.get('#updated-at').should('contain', '-');
269261
});
270262
});

src/components/clusters/schedulers/show.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function Schedulers() {
7575
onClose={handleClose}
7676
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
7777
>
78-
<Alert onClose={handleClose} severity="error" sx={{ width: '100%' }}>
78+
<Alert id="error-message" onClose={handleClose} severity="error" sx={{ width: '100%' }}>
7979
{errorMessageText}
8080
</Alert>
8181
</Snackbar>
@@ -89,16 +89,24 @@ export default function Schedulers() {
8989
aria-label="breadcrumb"
9090
sx={{ mb: '2rem', mt: '1rem' }}
9191
>
92-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters`}>
92+
<RouterLink id="cluster" component={Link} underline="hover" color="inherit" to={`/clusters`}>
9393
clusters
9494
</RouterLink>
95-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters/${clusterID}`}>
95+
<RouterLink id="cluster-id" component={Link} underline="hover" color="inherit" to={`/clusters/${clusterID}`}>
9696
{`scheduler-cluster-${clusterID}`}
9797
</RouterLink>
98-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters/${clusterID}/schedulers`}>
98+
<RouterLink
99+
id="scheduler"
100+
component={Link}
101+
underline="hover"
102+
color="inherit"
103+
to={`/clusters/${clusterID}/schedulers`}
104+
>
99105
{`schedulers`}
100106
</RouterLink>
101-
<Typography color="text.primary">{scheduler?.host_name || '-'}</Typography>
107+
<Typography id="scheduler-host-name" color="text.primary">
108+
{scheduler?.host_name || '-'}
109+
</Typography>
102110
</Breadcrumbs>
103111
<Card className={styles.container}>
104112
<Box className={styles.headerContainer}>

0 commit comments

Comments
 (0)