Skip to content

Commit 6c85692

Browse files
authored
chore: change seed peer e2e test (#507)
Signed-off-by: zhaoxinxin <1186037180@qq.com>
1 parent 45b6a16 commit 6c85692

File tree

2 files changed

+62
-58
lines changed

2 files changed

+62
-58
lines changed

cypress/e2e/seed-peers/seed-peer.cy.ts

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ describe('Seed peer', () => {
6767

6868
it('click the breadcrumb', () => {
6969
// Check for breadcrumb.
70-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
71-
.should('be.visible')
72-
.and('contain', 'seed-peer-cluster-1');
70+
cy.get('#seed-peer-cluster-id').should('be.visible').and('contain', 'seed-peer-cluster-1');
7371

74-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root').click();
72+
cy.get('#seed-peer-cluster-id').click();
7573

7674
// Then I see that the current page is the clusters/1!
7775
cy.url().should('include', '/clusters/1');
@@ -81,52 +79,48 @@ describe('Seed peer', () => {
8179
it('can display breadcrumb', () => {
8280
// Show isloading.
8381
cy.get('[data-testid="isloading"]').should('be.exist');
84-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
85-
.should('be.visible')
86-
.and('contain', 'seed-peer-cluster-1');
82+
cy.get('#seed-peer-cluster-id').should('be.visible').and('contain', 'seed-peer-cluster-1');
8783

88-
cy.get('.MuiBreadcrumbs-ol > :nth-child(7) > .MuiTypography-root')
89-
.should('be.visible')
90-
.and('contain', 'seed-peer-10');
84+
cy.get('#seed-peer-hostname').should('be.visible').and('contain', 'seed-peer-10');
9185

9286
cy.get('[data-testid="isloading"]').should('not.exist');
9387
});
9488

9589
it('can display active seed peer', () => {
96-
// Show ID.
90+
// Displays the seed peer ID.
9791
cy.get('#id').should('be.visible').and('contain', '10');
9892

99-
// Show Hostname.
93+
// Displays the seed peer hostname.
10094
cy.get('#hostname').should('be.visible').and('contain', 'seed-peer-10');
10195

102-
// Show IP.
96+
// Displays the seed peer IP.
10397
cy.get('#ip').should('be.visible').and('contain', '33.149.137.183');
10498

105-
// Show Cluster ID.
99+
// Displays the seed peer cluster ID.
106100
cy.get('#cluster-id').should('be.visible').and('contain', '1');
107101

108-
// Show Port.
102+
// Displays the seed peer port.
109103
cy.get('#port').should('be.visible').and('contain', '65006');
110104

111-
// Show Download Port.
105+
// Displays the seed peer Download Port.
112106
cy.get('#download-port').should('be.visible').and('contain', '65002');
113107

114-
// Show Object Storage Port.
108+
// Displays the seed peer Object Storage Port.
115109
cy.get('#object-storage-port').should('be.visible').and('contain', '443');
116110

117-
// Show Type.
111+
// Displays the seed peer Type.
118112
cy.get('#type').should('be.visible').and('contain', 'Supe');
119113

120-
// Show Active background color.
114+
// Displays the seed peer Active background color.
121115
cy.get('#status')
122116
.should('be.visible')
123117
.and('contain', 'Active')
124118
.and('have.css', 'background-color', 'rgb(0, 129, 112)');
125119

126-
// Show Created At.
120+
// Displays the seed peer Created At.
127121
cy.get('#created-at').should('have.text', '2023-11-11 20:09:08');
128122

129-
// Show Updated At.
123+
// Displays the seed peer Updated At.
130124
cy.get('#updated-at').should('have.text', '2023-11-11 20:09:13');
131125
});
132126

@@ -140,10 +134,10 @@ describe('Seed peer', () => {
140134

141135
cy.visit('/clusters/1/seed-peers/11');
142136

143-
// Show Hostname.
137+
// Displays the seed peer hostname.
144138
cy.get('#hostname').should('be.visible').and('contain', 'seed-peer-11');
145139

146-
// Show Inactive background color.
140+
// Displays the seed peer Inactive background color.
147141
cy.get('#status')
148142
.should('be.visible')
149143
.and('contain', 'Inactive')
@@ -163,45 +157,43 @@ describe('Seed peer', () => {
163157
});
164158

165159
it('unable to display breadcrumb', () => {
166-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
167-
.should('be.visible')
168-
.and('contain', 'seed-peer-cluster-1');
160+
cy.get('#seed-peer-cluster-id').should('be.visible').and('contain', 'seed-peer-cluster-1');
169161

170-
cy.get('.MuiBreadcrumbs-ol > :nth-child(7) > .MuiTypography-root').should('be.visible').and('contain', '-');
162+
cy.get('#seed-peer-hostname').should('be.visible').and('contain', '-');
171163
});
172164

173165
it('seed peer should render empty status', () => {
174-
// Show ID.
166+
// Displays the seed peer ID.
175167
cy.get('#id').should('contain', '-');
176168

177-
// Show Hostname.
169+
// Displays the seed peer hostname.
178170
cy.get('#hostname').should('contain', '-');
179171

180-
// Show IP.
172+
// Displays the seed peer IP.
181173
cy.get('#ip').should('contain', '-');
182174

183-
// Show Cluster ID.
175+
// Displays the seed peer cluster ID.
184176
cy.get('#cluster-id').should('contain', '-');
185177

186-
// Show Port.
178+
// Displays the seed peer port.
187179
cy.get('#port').should('contain', '-');
188180

189-
// Show Download Port.
181+
// Displays the seed peer Download Port.
190182
cy.get('#download-port').should('contain', '-');
191183

192-
// Show Object Storage Port.
184+
// Displays the seed peer Object Storage Port.
193185
cy.get('#object-storage-port').should('contain', '-');
194186

195-
// Show Type.
187+
// Displays the seed peer Type.
196188
cy.get('#type').should('contain', '-');
197189

198190
// Show Start.
199191
cy.get('#status').should('contain', '-');
200192

201-
// Show Created At.
193+
// Displays the seed peer Created At.
202194
cy.get('#created-at').should('contain', '-');
203195

204-
// Show Updated At.
196+
// Displays the seed peer Updated At.
205197
cy.get('#updated-at').should('contain', '-');
206198
});
207199
});
@@ -219,53 +211,51 @@ describe('Seed peer', () => {
219211

220212
it('show error message', () => {
221213
// Show error message.
222-
cy.get('.MuiAlert-message').should('be.visible').and('contain', 'Failed to fetch');
214+
cy.get('#error-message').should('be.visible').and('contain', 'Failed to fetch');
223215

224216
// Close error message.
225217
cy.get('.MuiAlert-action > .MuiButtonBase-root').click();
226-
cy.get('.MuiAlert-message').should('not.exist');
218+
cy.get('#error-message').should('not.exist');
227219
});
228220

229221
it('unable to display breadcrumb', () => {
230-
cy.get('.MuiBreadcrumbs-ol > :nth-child(3) > .MuiTypography-root')
231-
.should('be.visible')
232-
.and('contain', 'seed-peer-cluster-1');
222+
cy.get('#seed-peer-cluster-id').should('be.visible').and('contain', 'seed-peer-cluster-1');
233223

234-
cy.get('.MuiBreadcrumbs-ol > :nth-child(7) > .MuiTypography-root').should('be.visible').and('contain', '-');
224+
cy.get('#seed-peer-hostname').should('be.visible').and('contain', '-');
235225
});
236226

237227
it('seed peer should render empty status', () => {
238-
// Show ID.
228+
// Displays the seed peer ID.
239229
cy.get('#id').should('contain', '-');
240230

241-
// Show Hostname.
231+
// Displays the seed peer hostname.
242232
cy.get('#hostname').should('contain', '-');
243233

244-
// Show IP.
234+
// Displays the seed peer IP.
245235
cy.get('#ip').should('contain', '-');
246236

247-
// Show Cluster ID.
237+
// Displays the seed peer cluster ID.
248238
cy.get('#cluster-id').should('contain', '-');
249239

250-
// Show Port.
240+
// Displays the seed peer port.
251241
cy.get('#port').should('contain', '-');
252242

253-
// Show Download Port.
243+
// Displays the seed peer Download Port.
254244
cy.get('#download-port').should('contain', '-');
255245

256-
// Show Object Storage Port.
246+
// Displays the seed peer Object Storage Port.
257247
cy.get('#object-storage-port').should('contain', '-');
258248

259-
// Show Type.
249+
// Displays the seed peer Type.
260250
cy.get('#type').should('contain', '-');
261251

262252
// Show Start.
263253
cy.get('#status').should('contain', '-');
264254

265-
// Show Created At.
255+
// Displays the seed peer Created At.
266256
cy.get('#created-at').should('contain', '-');
267257

268-
// Show Updated At.
258+
// Displays the seed peer Updated At.
269259
cy.get('#updated-at').should('contain', '-');
270260
});
271261
});

src/components/clusters/seed-peers/show.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function SeedPeer() {
6767
onClose={handleClose}
6868
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
6969
>
70-
<Alert onClose={handleClose} severity="error" sx={{ width: '100%' }}>
70+
<Alert id="error-message" onClose={handleClose} severity="error" sx={{ width: '100%' }}>
7171
{errorMessageText}
7272
</Alert>
7373
</Snackbar>
@@ -81,16 +81,30 @@ export default function SeedPeer() {
8181
aria-label="breadcrumb"
8282
sx={{ mb: '2rem', mt: '1rem' }}
8383
>
84-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters`}>
84+
<RouterLink id="cluster" component={Link} underline="hover" color="inherit" to={`/clusters`}>
8585
clusters
8686
</RouterLink>
87-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters/${clusterID}`}>
87+
<RouterLink
88+
id="seed-peer-cluster-id"
89+
component={Link}
90+
underline="hover"
91+
color="inherit"
92+
to={`/clusters/${clusterID}`}
93+
>
8894
{`seed-peer-cluster-${clusterID}`}
8995
</RouterLink>
90-
<RouterLink component={Link} underline="hover" color="inherit" to={`/clusters/${clusterID}/seed-peers`}>
96+
<RouterLink
97+
id="seed-peers"
98+
component={Link}
99+
underline="hover"
100+
color="inherit"
101+
to={`/clusters/${clusterID}/seed-peers`}
102+
>
91103
seed-peers
92104
</RouterLink>
93-
<Typography color="text.primary">{seedPeer?.host_name || '-'}</Typography>
105+
<Typography id="seed-peer-hostname" color="text.primary">
106+
{seedPeer?.host_name || '-'}
107+
</Typography>
94108
</Breadcrumbs>
95109
<Card className={styles.container}>
96110
<Box className={styles.headerContainer}>

0 commit comments

Comments
 (0)