Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 738f486

Browse files
committed
chore: add server delay input to speed up Row Detail Cypress tests
1 parent 6729d98 commit 738f486

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/app/examples/grid-rowdetail.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ <h2>
3333
<button class="btn btn-outline-secondary btn-xs btn-icon" (click)="changeDetailViewRowCount()" data-test="set-count-btn">
3434
Set
3535
</button>
36+
<label for="serverdelay" class="ms-2">Server Delay: </label>
37+
<input
38+
id="serverdelay"
39+
[(ngModel)]="serverWaitDelay"
40+
type="number"
41+
data-test="server-delay"
42+
style="height: 26px; width: 55px"
43+
title="input a fake timer delay to simulate slow server response"
44+
/>
3645
</span>
3746
</div>
3847
<div class="alert alert-{{ flashAlertType }} col-sm-6" *ngIf="message" data-test="flash-msg">

src/app/examples/grid-rowdetail.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { RowDetailViewComponent } from './rowdetail-view.component';
1313
import { RowDetailPreloadComponent } from './rowdetail-preload.component';
1414

15+
const FAKE_SERVER_DELAY = 250;
1516
const NB_ITEMS = 1000;
1617

1718
@Component({
@@ -36,6 +37,7 @@ export class GridRowDetailComponent implements OnDestroy, OnInit {
3637
detailViewRowCount = 9;
3738
flashAlertType = 'info';
3839
message = '';
40+
serverWaitDelay = FAKE_SERVER_DELAY;
3941

4042
angularGridReady(angularGrid: AngularGridInstance) {
4143
this.angularGrid = angularGrid;
@@ -297,7 +299,7 @@ export class GridRowDetailComponent implements OnDestroy, OnInit {
297299

298300
// resolve the data after delay specified
299301
resolve(itemDetail);
300-
}, 1000);
302+
}, this.serverWaitDelay);
301303
});
302304
}
303305

test/cypress/e2e/example21.cy.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ describe('Example 21 - Row Detail View', () => {
1313
.each(($child, index) => expect($child.text()).to.eq(titles[index]));
1414
});
1515

16+
it('should change server delay to 40ms for faster testing', () => {
17+
cy.get('[data-test="set-count-btn"]').click();
18+
cy.get('[data-test="server-delay"]').type('{backspace}');
19+
});
20+
1621
it('should display first few rows of Task 0 to 5', () => {
1722
const expectedTasks = ['Task 0', 'Task 1', 'Task 2', 'Task 3', 'Task 4', 'Task 5'];
1823

0 commit comments

Comments
 (0)