Skip to content

Commit c71ce11

Browse files
committed
test branch
1 parent c2a5103 commit c71ce11

2 files changed

Lines changed: 79 additions & 80 deletions

File tree

tests/eecircuit.spec.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import { test } from '@playwright/test';
2-
import { testEEcircuit as testEEcircuit } from './lib/eecircuit-test';
3-
4-
5-
6-
7-
test('EEcircuit Prod', async ({ page }) => {
8-
9-
await testEEcircuit(page, 'https://eecircuit.com/');
1+
import { test } from "@playwright/test";
2+
import { testEEcircuit as testEEcircuit } from "./lib/eecircuit-test";
103

4+
test("EEcircuit Prod", async ({ page }) => {
5+
await testEEcircuit(page, "https://eecircuit.com/");
116
});
127

13-
14-
test('EEcircuit Next', async ({ page }) => {
15-
16-
await testEEcircuit(page, 'https://next.eecircuit.com/');
17-
18-
});
8+
test("EEcircuit Next", async ({ page }) => {
9+
await testEEcircuit(page, "https://test.eecircuit.com/");
10+
});

tests/lib/eecircuit-test.ts

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,96 @@
1-
import { test, expect, Page } from '@playwright/test';
2-
import { cloneAndGetLatestTag } from './getTags';
3-
import { compareCSVFiles } from './compareCSV';
4-
5-
1+
import { expect, Page, ConsoleMessage } from "@playwright/test";
2+
import { cloneAndGetLatestTag } from "./getTags";
3+
import { compareCSVFiles } from "./compareCSV";
64

75
export async function testEEcircuit(page: Page, url: string) {
8-
const consoleErrors: string[] = [];
9-
10-
let isSimCompleted: boolean = false;
11-
12-
// Listen for console errors
13-
page.on('console', (msg: any) => {
14-
if (msg.type() === 'error') {
15-
consoleErrors.push(msg.text());
16-
console.log('Error:', msg.text());
17-
}
6+
const consoleErrors: string[] = [];
187

19-
if (msg.text().startsWith('Simulation run completed')) {
20-
isSimCompleted = true;
8+
let isSimCompleted: boolean = false;
219

22-
};
23-
});
24-
25-
// Function to wait for the simulation to complete
26-
function waitForSimCompletion(): Promise<void> {
27-
return new Promise((resolve) => {
28-
const checkCompletion = () => {
29-
if (isSimCompleted) {
30-
resolve();
31-
} else {
32-
// Re-check after the next console message or event loop tick
33-
page.once('console', checkCompletion);
34-
}
35-
};
36-
checkCompletion();
37-
});
10+
// Listen for console errors
11+
page.on("console", (msg: ConsoleMessage) => {
12+
if (msg.type() === "error") {
13+
consoleErrors.push(msg.text());
14+
console.log("Error:", msg.text());
3815
}
3916

17+
if (msg.text().startsWith("Simulation run completed")) {
18+
isSimCompleted = true;
19+
}
20+
});
21+
22+
// Function to wait for the simulation to complete
23+
function waitForSimCompletion(): Promise<void> {
24+
return new Promise((resolve) => {
25+
const checkCompletion = () => {
26+
if (isSimCompleted) {
27+
resolve();
28+
} else {
29+
// Re-check after the next console message or event loop tick
30+
page.once("console", checkCompletion);
31+
}
32+
};
33+
checkCompletion();
34+
});
35+
}
4036

41-
await page.goto(url);
37+
await page.goto(url);
4238

43-
await expect(page).toHaveTitle(/EEcircuit/);
39+
await expect(page).toHaveTitle(/EEcircuit/);
4440

45-
await page.getByRole('button', { name: 'Run' }).click();
41+
await page.getByRole("button", { name: "Run" }).click();
4642

47-
await page.getByRole('button', { name: 'De-select all' }).click();
48-
await page.getByRole('button', { name: 'Select all', exact: true }).click();
49-
await page.getByRole('button', { name: 'De-select all' }).click();
50-
await page.locator('label').filter({ hasText: 'v(2)' }).locator('span').first().click();
51-
await page.getByRole('button', { name: 'Colorize' }).click();
52-
await page.getByRole('button', { name: 'Reset' }).click();
53-
await page.getByRole('button', { name: 'Settings' }).click();
54-
//await page.getByLabel('Close').click();
43+
await page.getByRole("button", { name: "De-select all" }).click();
44+
await page.getByRole("button", { name: "Select all", exact: true }).click();
45+
await page.getByRole("button", { name: "De-select all" }).click();
46+
await page
47+
.locator("label")
48+
.filter({ hasText: "v(2)" })
49+
.locator("span")
50+
.first()
51+
.click();
52+
await page.getByRole("button", { name: "Colorize" }).click();
53+
await page.getByRole("button", { name: "Reset" }).click();
54+
await page.getByRole("button", { name: "Settings" }).click();
55+
//await page.getByLabel('Close').click();
5556

56-
await page.getByRole('button', { name: 'Run' }).click();
57+
await page.getByRole("button", { name: "Run" }).click();
5758

58-
await page.waitForTimeout(1000);
59-
expect(consoleErrors.length).toBe(0);
59+
await page.waitForTimeout(1000);
60+
expect(consoleErrors.length).toBe(0);
6061

61-
await page.getByRole('tab', { name: 'Info' }).click();
62+
await page.getByRole("tab", { name: "Info" }).click();
6263

63-
// Wait for simulation to complete without using a timeout
64-
await waitForSimCompletion();
64+
// Wait for simulation to complete without using a timeout
65+
await waitForSimCompletion();
6566

66-
const text = await page.getByLabel('info', { exact: true }).inputValue();
67+
const text = await page.getByLabel("info", { exact: true }).inputValue();
6768

68-
const match = text.match(/ngspice-(\d+)/);
69-
const number = match ? parseInt(match[1]) : null;
69+
const match = text.match(/ngspice-(\d+)/);
70+
const number = match ? parseInt(match[1]) : null;
7071

71-
console.log('ngspice version from EEcircuit:', number);
72+
console.log("ngspice version from EEcircuit:", number);
7273

73-
const tag = await cloneAndGetLatestTag('https://github.com/danchitnis/ngspice-sf-mirror', './tests/repos');
74+
const tag = await cloneAndGetLatestTag(
75+
"https://github.com/danchitnis/ngspice-sf-mirror",
76+
"./tests/repos"
77+
);
7478

75-
const version = parseInt(tag?.split('-')[1] ?? '');
79+
const version = parseInt(tag?.split("-")[1] ?? "");
7680

77-
console.log('ngspice version from repo:', version);
81+
console.log("ngspice version from repo:", version);
7882

79-
expect(number).toBe(version);
83+
expect(number).toBe(version);
8084

81-
await page.getByRole('tab', { name: 'CSV' }).click();
82-
const downloadPromise = page.waitForEvent('download');
83-
await page.getByRole('button', { name: 'Download' }).click();
85+
await page.getByRole("tab", { name: "CSV" }).click();
86+
const downloadPromise = page.waitForEvent("download");
87+
await page.getByRole("button", { name: "Download" }).click();
8488

85-
const download = await downloadPromise;
86-
await download.saveAs('./tests/output/' + download.suggestedFilename());
89+
const download = await downloadPromise;
90+
await download.saveAs("./tests/output/" + download.suggestedFilename());
8791

88-
const compare = await compareCSVFiles('./tests/lib/EEcircuit.csv', './tests/output/' + download.suggestedFilename());
89-
}
92+
await compareCSVFiles(
93+
"./tests/lib/EEcircuit.csv",
94+
"./tests/output/" + download.suggestedFilename()
95+
);
96+
}

0 commit comments

Comments
 (0)