Skip to content

Commit 0c49006

Browse files
author
aligneddev
committed
fixed e2e, .net 10.0.500
1 parent c9f2bbc commit 0c49006

3 files changed

Lines changed: 36 additions & 32 deletions

File tree

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
33
"rollForward": "latestFeature",
4-
"version": "10.0.500"
4+
"version": "10.0.200"
55
}
66
}
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,60 @@
1-
import { defineConfig, devices } from '@playwright/test'
1+
import { defineConfig, devices } from "@playwright/test";
22

3-
const isCI = !!process.env.CI
4-
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://localhost:9000'
3+
const isCI = !!process.env.CI;
4+
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:9000";
5+
const e2eApiUrl =
6+
process.env.PLAYWRIGHT_API_BASE_URL ?? "http://localhost:55436";
57

68
/**
79
* E2E smoke tests for BikeTracking frontend (User Login feature).
810
*
911
* Prerequisites:
12+
* Preferred: launch the full Aspire stack: (`dotnet run --project src/BikeTracking.AppHost`)
13+
* OR
1014
* - Vite dev server running on http://localhost:9000 (`npm run dev`)
11-
* - .NET API running on http://localhost:5436 (`dotnet run --project src/BikeTracking.Api`)
12-
* OR launch the full Aspire stack: (`dotnet run --project src/BikeTracking.AppHost`)
15+
* - .NET API running on http://localhost:55436 (`dotnet run --no-launch-profile --project src/BikeTracking.Api`)
1316
*
1417
* Run: npx playwright test (from src/BikeTracking.Frontend)
1518
*/
1619
export default defineConfig({
17-
testDir: './tests/e2e',
20+
testDir: "./tests/e2e",
1821
fullyParallel: false,
1922
forbidOnly: isCI,
2023
retries: isCI ? 1 : 0,
2124
workers: 1,
22-
reporter: [['list'], ['html', { open: 'never' }]],
25+
reporter: [["list"], ["html", { open: "never" }]],
2326
use: {
2427
baseURL,
25-
trace: 'on-first-retry',
28+
trace: "on-first-retry",
2629
},
2730
webServer: [
2831
{
29-
command: 'dotnet run --project ../BikeTracking.Api',
30-
url: 'http://localhost:5436/',
31-
reuseExistingServer: !isCI,
32-
stdout: 'pipe',
33-
stderr: 'pipe',
32+
command: "dotnet run --no-launch-profile --project ../BikeTracking.Api",
33+
url: `${e2eApiUrl}/`,
34+
reuseExistingServer: false,
35+
stdout: "pipe",
36+
stderr: "pipe",
3437
timeout: 180000,
3538
env: {
39+
ASPNETCORE_URLS: e2eApiUrl,
3640
// Use a dedicated E2E database so test runs never touch the local dev DB.
3741
// ASP.NET Core maps ConnectionStrings__<name> to ConnectionStrings[name].
38-
ConnectionStrings__BikeTracking: 'Data Source=biketracking.e2e.db',
42+
ConnectionStrings__BikeTracking: "Data Source=biketracking.e2e.db",
3943
},
4044
},
4145
{
42-
command: 'npm run dev -- --host localhost --port 9000',
43-
url: 'http://localhost:9000/login',
44-
reuseExistingServer: !isCI,
45-
stdout: 'pipe',
46-
stderr: 'pipe',
46+
command: `VITE_API_BASE_URL=${e2eApiUrl} npm run dev -- --host localhost --port 9000`,
47+
url: "http://localhost:9000/login",
48+
reuseExistingServer: false,
49+
stdout: "pipe",
50+
stderr: "pipe",
4751
timeout: 120000,
4852
},
4953
],
5054
projects: [
5155
{
52-
name: 'chromium',
53-
use: { ...devices['Desktop Chrome'] },
56+
name: "chromium",
57+
use: { ...devices["Desktop Chrome"] },
5458
},
5559
],
56-
})
60+
});

src/BikeTracking.Frontend/tests/e2e/record-ride.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ test.describe("004-record-ride e2e", () => {
4343
await page
4444
.getByLabel(/date & time/i)
4545
.fill(toDateTimeLocalValue(new Date()));
46-
await page.getByLabel(/miles/i).fill("12.34");
47-
await page.getByLabel(/duration/i).fill("41");
48-
await page.getByLabel(/temperature/i).fill("68");
46+
await page.locator("#miles").fill("12.34");
47+
await page.locator("#rideMinutes").fill("41");
48+
await page.locator("#temperature").fill("68");
4949
await page.getByRole("button", { name: "Record Ride" }).click();
5050

5151
await expect(page.getByText(/ride recorded successfully/i)).toBeVisible();
@@ -61,18 +61,18 @@ test.describe("004-record-ride e2e", () => {
6161
await page
6262
.getByLabel(/date & time/i)
6363
.fill(toDateTimeLocalValue(new Date()));
64-
await page.getByLabel(/miles/i).fill("9.75");
65-
await page.getByLabel(/duration/i).fill("35");
66-
await page.getByLabel(/temperature/i).fill("61");
64+
await page.locator("#miles").fill("9.75");
65+
await page.locator("#rideMinutes").fill("35");
66+
await page.locator("#temperature").fill("61");
6767
await page.getByRole("button", { name: "Record Ride" }).click();
6868
await expect(page.getByText(/ride recorded successfully/i)).toBeVisible();
6969

7070
await page.goto("/miles");
7171
await page.getByRole("link", { name: "Record Ride" }).click();
7272
await expect(page).toHaveURL("/rides/record");
7373

74-
await expect(page.getByLabel(/miles/i)).toHaveValue("9.75");
75-
await expect(page.getByLabel(/duration/i)).toHaveValue("35");
76-
await expect(page.getByLabel(/temperature/i)).toHaveValue("61");
74+
await expect(page.locator("#miles")).toHaveValue("9.75");
75+
await expect(page.locator("#rideMinutes")).toHaveValue("35");
76+
await expect(page.locator("#temperature")).toHaveValue("61");
7777
});
7878
});

0 commit comments

Comments
 (0)