Skip to content

Commit ec5510b

Browse files
pxoralehander92
authored andcommitted
test: Add stepping test for continue and next
1 parent 479917e commit ec5510b

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

src/frontend/types.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ type
12691269
flowMenuIsOpen*: bool
12701270
showBugReport*: bool
12711271
copyMessageActive*: bool
1272+
completeMoveId*: int
12721273

12731274
CalltraceEditorComponent* = ref object of Component
12741275
loading*: JsAssoc[cstring, bool]

src/frontend/ui/status.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ proc locationView(self: StatusComponent): VNode =
3737
tdiv(class = fmt"custom-tooltip {activeClass}"):
3838
text "Path copied to clipboard"
3939

40+
method onCompleteMove*(self: StatusComponent, response: MoveState) {.async.} =
41+
self.completeMoveId += 1
42+
4043
proc counterHandler(self: StatusComponent): void {.async.} =
4144
const SLOW_MESSAGE_TIME = 2.0 # seconds
4245
const MAXIMUM_TIME_ALLOWED = 180 # seconds
@@ -504,6 +507,9 @@ method render*(self: StatusComponent): VNode =
504507
# span(class="status-flow-buttons"):
505508
# flowButtonsView(self)
506509
# # createShellContainer(self)
510+
if data.startOptions.inTest:
511+
span(class = "test-movement"):
512+
text $self.completeMoveId
507513
span(class = "status-right"):
508514
locationView(self)
509515
if self.showNotifications:

ui-tests/tests/lib/ct_helpers.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,43 @@ export class CodetracerTestError extends Error {
362362
Object.setPrototypeOf(this, CodetracerTestError.prototype);
363363
}
364364
}
365+
366+
async function debugMovement(selector: string): Promise<void> {
367+
await page.locator("#debug").click();
368+
369+
const initialText = await page.locator(".test-movement").textContent();
370+
if (initialText === null) {
371+
throw new Error("Initial text was null");
372+
}
373+
374+
const initialValue = parseInt(initialText, 10);
375+
if (isNaN(initialValue)) {
376+
throw new Error(`Initial text was not a number: "${initialText}"`);
377+
}
378+
379+
await page.locator(selector).click();
380+
await readyOnCompleteMove(initialValue);
381+
382+
}
383+
384+
export async function clickContinue(): Promise<void> {
385+
await debugMovement("#continue-debug")
386+
}
387+
388+
export async function clickNext(): Promise<void> {
389+
await debugMovement("#next-debug")
390+
}
391+
392+
export async function readyOnCompleteMove(initialValue: number): Promise<void> {
393+
const movement = page.locator(".test-movement");
394+
const elementHandle = await movement.elementHandle();
395+
if (!elementHandle) throw new Error("Element not found");
396+
397+
await page.waitForFunction(
398+
({ el, expected }) => {
399+
const current = parseInt(el.textContent ?? "", 10);
400+
return !isNaN(current) && current !== expected;
401+
},
402+
{ el: await movement.evaluateHandle(el => el), expected: initialValue } // pass both in an object
403+
);
404+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { test, expect } from "@playwright/test";
2+
import {
3+
window,
4+
page,
5+
// wait,
6+
// debugCodetracer,
7+
readyOnEntryTest as readyOnEntry,
8+
clickNext,
9+
clickContinue,
10+
ctRun,
11+
} from "../lib/ct_helpers";
12+
import { StatusBar } from "../page_objects/status_bar";
13+
14+
ctRun("noir_example/");
15+
16+
const ENTRY_LINE = 17;
17+
18+
test("continue", async() => {
19+
await readyOnEntry();
20+
await clickContinue();
21+
});
22+
23+
test("next", async() => {
24+
await readyOnEntry();
25+
await clickNext();
26+
});

0 commit comments

Comments
 (0)