Skip to content

Commit 28def64

Browse files
committed
chore(): update cypress test for server dashboard page
1 parent 60038e3 commit 28def64

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

cypress/e2e/server-page-spec.cy.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
describe('Server page contains expected information', () => {
2-
it('passes', () => {
3-
const expectedEndpoints = [
4-
'/api/bikes',
5-
'/api/cats',
6-
'/api/images',
7-
'/api/json',
8-
'/api/lambda',
9-
'/api/markdown',
10-
'/api/posts',
11-
'/api/users',
12-
'/api/videos',
13-
'/api/error',
14-
];
15-
cy.visit('/');
16-
cy.get('h1').contains('Running');
2+
it('passes', () => {
3+
const expectedEndpoints = [
4+
'/api/bikes',
5+
'/api/cats',
6+
'/api/images',
7+
'/api/json',
8+
'/api/lambda',
9+
'/api/markdown',
10+
'/api/posts',
11+
'/api/users',
12+
'/api/videos',
13+
'/api/error',
14+
];
15+
cy.visit('/');
16+
cy.get('[cy-data="server_status"]').contains('Running');
1717

18-
cy.get('h3').contains('Server Address');
19-
cy.get('h3').contains('Server Port');
20-
cy.get('h3').contains('Server URL Prefix');
21-
cy.get('h3').contains('API endpoints');
18+
cy.get('[cy-data="server_address"]').contains('Server Address');
19+
cy.get('[cy-data="server_port"]').contains('Server Port');
20+
cy.get('[cy-data="server_prefix"]').contains('Server URL Prefix');
21+
cy.get('[cy-data="server_label"]').contains('API endpoints*');
2222

23-
cy.get('[cy-data="server_address"]').contains('localhost');
24-
cy.get('[cy-data="server_port"]').contains('8000');
25-
cy.get('[cy-data="url_prefix"]').contains('api');
23+
cy.get('[cy-data="server_address"]').contains('localhost');
24+
cy.get('[cy-data="server_port"]').contains('8000');
25+
cy.get('[cy-data="url_prefix"]').contains('api');
2626

27-
const endpoints = cy.get('[cy-data="endpoint"]');
27+
const endpoints = cy.get('[cy-data="endpoint"]');
2828

29-
endpoints.should('have.length', expectedEndpoints.length);
29+
endpoints.should('have.length', expectedEndpoints.length);
3030

31-
endpoints.each((endpoint) => {
32-
expect(expectedEndpoints).to.include(endpoint.text());
33-
});
34-
});
31+
endpoints.each((endpoint) => {
32+
expect(expectedEndpoints).to.include(endpoint.text());
33+
});
34+
});
3535
});

src/utilities/server-page.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ const homePage = (apiPaths: string[]) => [
362362
<main>
363363
<section class="info-sticky">
364364
<h1>Mock Server</h1>
365-
<div class="status-box">
365+
<div class="status-box" cy-data="server_status">
366366
<span class="status" id="server-status">
367367
<span class="status-tick" id="status-icon" aria-label="running" title="Running">
368368
<!-- SVG will be dynamically updated here -->
@@ -372,13 +372,13 @@ const homePage = (apiPaths: string[]) => [
372372
</span>
373373
</div>
374374
<ul class="info-list">
375-
<li><span class="info-label">Server Address:</span><span class="highlight" cy-data="server_address">localhost</span></li>
376-
<li><span class="info-label">Server Port:</span><span class="highlight" cy-data="server_port">${env?.SERVER_PORT?.toUpperCase() ?? 'NONE'}</span></li>
377-
<li><span class="info-label">Server URL Prefix:</span><span class="highlight" cy-data="url_prefix">${env?.USE_API_URL_PREFIX?.toLowerCase() ?? 'NONE'}</span></li>
375+
<li><span class="info-label" cy-data="server_address">Server Address:</span><span class="highlight" cy-data="server_address">localhost</span></li>
376+
<li><span class="info-label" cy-data="server_port">Server Port:</span><span class="highlight" cy-data="server_port">${env?.SERVER_PORT?.toUpperCase() ?? 'NONE'}</span></li>
377+
<li><span class="info-label" cy-data="server_prefix">Server URL Prefix:</span><span class="highlight" cy-data="url_prefix">${env?.USE_API_URL_PREFIX?.toLowerCase() ?? 'NONE'}</span></li>
378378
</ul>
379379
</section>
380380
<section>
381-
<div style="margin-bottom: 8px; font-size: 1.13rem; color: var(--text-muted); font-weight: 600;">API endpoints*</div>
381+
<div style="margin-bottom: 8px; font-size: 1.13rem; color: var(--text-muted); font-weight: 600;" cy-data="server_label">API endpoints*</div>
382382
<div class="endpoints">
383383
${apiPaths.map((path) => `<a class="endpoint-link" cy-data="endpoint" href="/${prefix}${path}">/${prefix}${path}</a>`).join('')}
384384
</div>

0 commit comments

Comments
 (0)