Skip to content

Commit 9875d2f

Browse files
authored
fix tests on localhost (#469)
1 parent 4f55dff commit 9875d2f

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

playwright.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export default defineConfig({
7171
],
7272

7373
/* Run your local dev server before starting the tests */
74-
// webServer: {
75-
// command: 'npm run start',
76-
// url: 'http://127.0.0.1:3000',
77-
// reuseExistingServer: !process.env.CI,
78-
// },
74+
webServer: {
75+
command: "npm run build && npx vite preview --port 5173",
76+
url: "http://localhost:5173",
77+
reuseExistingServer: !process.env.CI,
78+
timeout: 120000,
79+
},
7980
});

src/components/Instructions/InstructionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const InstructionItem = forwardRef(
128128
<TableRow
129129
ref={ref}
130130
className={classNames({ "opacity-50": isLast }, "overflow-hidden")}
131-
test-id="instruction-item"
131+
data-testid="instruction-item"
132132
style={{
133133
backgroundColor,
134134
color,

src/components/MemoryPreview/MemoryInfinite.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const MemoryCell = ({
7373
>
7474
{isEqualAcrossWorkers ? (
7575
<Tooltip delayDuration={100} open={isPageTooltipDisabled ? false : undefined}>
76-
<TooltipTrigger data-test-id="memory-cell">
76+
<TooltipTrigger data-testid="memory-cell">
7777
{valueToNumeralSystem(value, numeralSystem, numeralSystem ? 2 : 3, false)}
7878
</TooltipTrigger>
7979

@@ -89,7 +89,7 @@ export const MemoryCell = ({
8989
<Tooltip delayDuration={0}>
9090
<TooltipTrigger asChild>
9191
<span
92-
data-test-id="memory-cell"
92+
data-testid="memory-cell"
9393
className="font-inconsolata"
9494
dangerouslySetInnerHTML={{
9595
__html: numeralSystem ? "&quest;&#8288;&quest;&#8288;" : "&quest;&#8288;&quest;&#8288;&quest;&#8288;",

src/components/Registers/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const Registers = ({
185185
"text-xs whitespace-nowrap": statusValue === Status.HOST,
186186
})}
187187
style={getStatusStyles(isDarkMode, statusValue)}
188-
test-id="program-status"
188+
data-testid="program-status"
189189
>
190190
{displayText}
191191
</span>

tests/memory-range.spec.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,31 @@ test("Should modify memory ranges", async ({ page }) => {
66
await selectPVM(page, "@typeberry");
77
await openProgram(page, "storeU16");
88

9+
// Wait for program to load and initialize
10+
await page.waitForTimeout(2000);
11+
912
await page.getByRole("tab", { name: "Ranges" }).click();
1013
await page.getByLabel("Start").click();
1114
await page.getByLabel("Start").fill("131072");
1215
await page.getByRole("button", { name: "Add" }).click();
1316

14-
await expect(page.locator("[data-test-id='memory-cell']").first()).toContainText("00", { timeout: 2000 });
15-
await expect(page.locator("[data-test-id='memory-cell']").nth(1)).toContainText("00", { timeout: 2000 });
17+
await expect(page.getByTestId("memory-cell").first()).toContainText("00", { timeout: 2000 });
18+
await expect(page.getByTestId("memory-cell").nth(1)).toContainText("00", { timeout: 2000 });
1619

1720
await step(page);
1821

19-
await expect(page.locator("[data-test-id='memory-cell']").first()).toContainText("78", { timeout: 2000 });
20-
await expect(page.locator("[data-test-id='memory-cell']").nth(1)).toContainText("56", { timeout: 2000 });
22+
await expect(page.getByTestId("memory-cell").first()).toContainText("78", { timeout: 2000 });
23+
await expect(page.getByTestId("memory-cell").nth(1)).toContainText("56", { timeout: 2000 });
2124
});
2225

2326
test("Should show interpretations", async ({ page }) => {
2427
await openDebugger(page);
2528
await selectPVM(page, "@typeberry");
2629
await openProgram(page, "storeU16");
2730

31+
// Wait for program to load and initialize
32+
await page.waitForTimeout(2000);
33+
2834
await page.getByRole("tab", { name: "Ranges" }).click();
2935
await page.getByLabel("Start").click();
3036
await page.getByLabel("Start").fill("131072");
@@ -42,6 +48,9 @@ test("Should not show interpretations for longer memory chunks", async ({ page }
4248
await selectPVM(page, "@typeberry");
4349
await openProgram(page, "storeU16");
4450

51+
// Wait for program to load and initialize
52+
await page.waitForTimeout(2000);
53+
4554
await page.getByRole("tab", { name: "Ranges" }).click();
4655
await page.getByLabel("Start").click();
4756
await page.getByLabel("Start").fill("131072");
@@ -61,6 +70,9 @@ test("Should show diffs between PVMs", async ({ page }) => {
6170
await selectPVM(page, "typeberry");
6271
await openProgram(page, "storeU16");
6372

73+
// Wait for program to load and initialize
74+
await page.waitForTimeout(2000);
75+
6476
await page.getByRole("tab", { name: "Ranges" }).click();
6577
await page.getByLabel("Start").click();
6678
await page.getByLabel("Start").fill("131072");

tests/run-program.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ async function runProgramTest(page: Page, pvmType: string) {
1212
// Test the "Run" button functionality
1313
await page.click('button:has-text("Run")');
1414

15-
// Wait for execution to complete
16-
await page.waitForTimeout(5000);
15+
// Wait for execution to complete (increased timeout for local environment)
16+
const programStatus = page.getByTestId("program-status");
17+
await expect(programStatus).toHaveText("HALT", { timeout: 15000 });
1718

18-
const programStatus = page.locator('[test-id="program-status"]');
19-
await expect(programStatus).toHaveText("HALT");
20-
21-
// const jumpIndInstructionParent = page.locator('div[test-id="instruction-item"]:has(span:has-text("JUMP_IND"))');
19+
// const jumpIndInstructionParent = page.locator('div[data-testid="instruction-item"]:has(span:has-text("JUMP_IND"))');
2220
// await expect(jumpIndInstructionParent).toHaveCSS('background-color', 'rgb(76, 175, 80)');
2321
}
2422

0 commit comments

Comments
 (0)