testdriverai 7.2.9 → 7.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/testdriver.yml +127 -0
- package/.testdriver/last-sandbox +7 -0
- package/agent/events.js +1 -0
- package/agent/index.js +71 -54
- package/agent/lib/sandbox.js +11 -1
- package/agents.md +393 -0
- package/debug/01-table-initial.png +0 -0
- package/debug/02-after-ai-explore.png +0 -0
- package/debug/02-after-scroll.png +0 -0
- package/docs/docs.json +87 -126
- package/docs/v7/_drafts/caching.mdx +2 -2
- package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
- package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
- package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
- package/docs/v7/_drafts/screenshot.mdx +155 -0
- package/docs/v7/_drafts/writing-tests.mdx +25 -0
- package/docs/v7/{api/act.mdx → ai.mdx} +27 -27
- package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
- package/docs/v7/aws-setup.mdx +338 -0
- package/docs/v7/caching.mdx +128 -0
- package/docs/v7/ci-cd.mdx +605 -0
- package/docs/v7/{api/click.mdx → click.mdx} +4 -4
- package/docs/v7/cloud.mdx +120 -0
- package/docs/v7/customizing-devices.mdx +129 -0
- package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -78
- package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
- package/docs/v7/{api/elements.mdx → elements.mdx} +1 -54
- package/docs/v7/enterprise.mdx +116 -0
- package/docs/v7/examples.mdx +5 -0
- package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
- package/docs/v7/{api/find.mdx → find.mdx} +17 -21
- package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
- package/docs/v7/generating-tests.mdx +36 -0
- package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
- package/docs/v7/locating-elements.mdx +71 -0
- package/docs/v7/making-assertions.mdx +32 -0
- package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
- package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
- package/docs/v7/performing-actions.mdx +51 -0
- package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
- package/docs/v7/quickstart.mdx +162 -0
- package/docs/v7/reusable-code.mdx +240 -0
- package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
- package/docs/v7/running-tests.mdx +181 -0
- package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
- package/docs/v7/secrets.mdx +115 -0
- package/docs/v7/self-hosted.mdx +66 -0
- package/docs/v7/{api/type.mdx → type.mdx} +3 -3
- package/docs/v7/variables.mdx +111 -0
- package/docs/v7/waiting-for-elements.mdx +66 -0
- package/docs/v7/what-is-testdriver.mdx +54 -0
- package/lib/vitest/hooks.mjs +80 -68
- package/package.json +1 -1
- package/sdk.d.ts +22 -9
- package/sdk.js +177 -44
- package/test/manual/reconnect-provision.test.mjs +49 -0
- package/test/manual/reconnect-signin.test.mjs +41 -0
- package/test/testdriver/ai.test.mjs +30 -0
- package/test/testdriver/setup/testHelpers.mjs +0 -1
- package/test/testdriver/windows-installer.test.mjs +61 -0
- package/tests/table-sort-enrollments.test.mjs +72 -0
- package/tests/table-sort-experiment.test.mjs +42 -0
- package/tests/table-sort-setup.test.mjs +59 -0
- package/vitest.config.mjs +1 -0
- package/docs/v7/api/assertions.mdx +0 -403
- package/docs/v7/api/sandbox.mdx +0 -404
- package/docs/v7/features/ai-native.mdx +0 -413
- package/docs/v7/features/application-logs.mdx +0 -353
- package/docs/v7/features/browser-logs.mdx +0 -414
- package/docs/v7/features/cache-management.mdx +0 -402
- package/docs/v7/features/continuous-testing.mdx +0 -346
- package/docs/v7/features/data-driven-testing.mdx +0 -441
- package/docs/v7/features/easy-to-write.mdx +0 -280
- package/docs/v7/features/enterprise.mdx +0 -656
- package/docs/v7/features/fast.mdx +0 -406
- package/docs/v7/features/managed-sandboxes.mdx +0 -384
- package/docs/v7/features/network-monitoring.mdx +0 -568
- package/docs/v7/features/parallel-execution.mdx +0 -381
- package/docs/v7/features/powerful.mdx +0 -531
- package/docs/v7/features/sandbox-customization.mdx +0 -229
- package/docs/v7/features/stable.mdx +0 -473
- package/docs/v7/features/system-performance.mdx +0 -616
- package/docs/v7/features/test-analytics.mdx +0 -373
- package/docs/v7/features/test-cases.mdx +0 -393
- package/docs/v7/features/test-replays.mdx +0 -408
- package/docs/v7/features/test-reports.mdx +0 -308
- package/docs/v7/getting-started/debugging-tests.mdx +0 -382
- package/docs/v7/getting-started/quickstart.mdx +0 -90
- package/docs/v7/getting-started/running-tests.mdx +0 -173
- package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
- package/docs/v7/getting-started/writing-tests.mdx +0 -534
- package/docs/v7/overview/what-is-testdriver.mdx +0 -386
- package/docs/v7/presets/chrome-extension.mdx +0 -248
- package/docs/v7/presets/chrome.mdx +0 -300
- package/docs/v7/presets/electron.mdx +0 -460
- package/docs/v7/presets/vscode.mdx +0 -417
- package/docs/v7/presets/webapp.mdx +0 -393
- package/vitest.config.js +0 -18
- /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
- /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
- /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
- /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
- /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
- /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
- /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestDriver SDK - Reconnect Test Part 2: Sign In
|
|
3
|
+
*
|
|
4
|
+
* This test reconnects to the sandbox provisioned by reconnect-provision.test.mjs
|
|
5
|
+
* and clicks the Sign In button.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Run this within 2 minutes of reconnect-provision.test.mjs completing.
|
|
8
|
+
* The sandbox auto-terminates after the keepAlive TTL (default 2 minutes).
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* 1. npm test -- test/testdriver/reconnect-provision.test.mjs
|
|
12
|
+
* 2. (within 2 minutes) npm test -- test/testdriver/reconnect-signin.test.mjs
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, it } from "vitest";
|
|
16
|
+
import { TestDriver } from "../../lib/vitest/hooks.mjs";
|
|
17
|
+
|
|
18
|
+
describe("Reconnect Test - Part 2: Sign In", () => {
|
|
19
|
+
|
|
20
|
+
it("should reconnect to existing sandbox and click Sign In", async (context) => {
|
|
21
|
+
|
|
22
|
+
const testdriver = TestDriver(context, { newSandbox: true, headless: false, reconnect: true });
|
|
23
|
+
|
|
24
|
+
// Provision Chrome and navigate to login page
|
|
25
|
+
await testdriver.provision.chrome({
|
|
26
|
+
url: 'http://testdriver-sandbox.vercel.app/login',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Click on Sign In button - the page should already be loaded from provision test
|
|
30
|
+
const signInButton = await testdriver.find(
|
|
31
|
+
"Sign In, black button below the password field",
|
|
32
|
+
);
|
|
33
|
+
await signInButton.click();
|
|
34
|
+
|
|
35
|
+
// Assert that an error shows that fields are required
|
|
36
|
+
const result = await testdriver.assert(
|
|
37
|
+
"an error shows that fields are required",
|
|
38
|
+
);
|
|
39
|
+
expect(result).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestDriver SDK - AI Test (Vitest)
|
|
3
|
+
* Tests the AI exploratory loop (ai) functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { TestDriver } from "../../lib/vitest/hooks.mjs";
|
|
8
|
+
|
|
9
|
+
describe("AI Test", () => {
|
|
10
|
+
it("should use ai to search for testdriver on Google", async (context) => {
|
|
11
|
+
const testdriver = TestDriver(context, { newSandbox: true });
|
|
12
|
+
|
|
13
|
+
// provision.chrome() automatically calls ready() and starts dashcam
|
|
14
|
+
await testdriver.provision.chrome({
|
|
15
|
+
url: 'https://duckduckgo.com',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Use ai to search for testdriver
|
|
19
|
+
let aiRes = await testdriver.ai("click on the empty search box, type 'testdriver', and hit enter.");
|
|
20
|
+
|
|
21
|
+
console.log("AI response:", aiRes);
|
|
22
|
+
|
|
23
|
+
// Assert the search results are displayed
|
|
24
|
+
const result = await testdriver.assert(
|
|
25
|
+
"search results for testdriver are visible",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(result).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestDriver SDK - Windows Installer Example (Vitest)
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to download and install a Windows application
|
|
5
|
+
* using PowerShell commands, then launch and interact with it.
|
|
6
|
+
*
|
|
7
|
+
* Based on the v6 GitButler provisioning workflow.
|
|
8
|
+
*
|
|
9
|
+
* Run: TD_OS=windows npx vitest run examples/windows-installer.test.mjs
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, expect, it } from "vitest";
|
|
13
|
+
import { TestDriver } from "../../lib/vitest/hooks.mjs";
|
|
14
|
+
|
|
15
|
+
const isLinux = (process.env.TD_OS || "linux") === "linux";
|
|
16
|
+
|
|
17
|
+
describe("Windows App Installation", () => {
|
|
18
|
+
|
|
19
|
+
it.skipIf(isLinux)("should download, install, and launch GitButler on Windows", async (context) => {
|
|
20
|
+
// Alternative approach using provision.installer helper
|
|
21
|
+
const testdriver = TestDriver(context, {
|
|
22
|
+
newSandbox: true,
|
|
23
|
+
os: 'windows'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Download the MSI installer
|
|
27
|
+
const installerPath = await testdriver.provision.installer({
|
|
28
|
+
url: 'https://app.gitbutler.com/downloads/release/windows/x86_64/msi',
|
|
29
|
+
launch: false, // Don't auto-launch, we'll install manually
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// The installer should be an .msi or .exe file
|
|
33
|
+
expect(installerPath).toMatch(/\.(msi|exe)$/i);
|
|
34
|
+
|
|
35
|
+
// Install the MSI silently (check which type it is)
|
|
36
|
+
if (installerPath.toLowerCase().endsWith('.msi')) {
|
|
37
|
+
await testdriver.exec('pwsh',
|
|
38
|
+
`Start-Process msiexec.exe -ArgumentList "/i \`"${installerPath}\`" /qn /norestart" -Wait`,
|
|
39
|
+
120000
|
|
40
|
+
);
|
|
41
|
+
} else {
|
|
42
|
+
await testdriver.exec('pwsh',
|
|
43
|
+
`Start-Process "${installerPath}" -ArgumentList "/S" -Wait`,
|
|
44
|
+
120000
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Verify installation by checking if executable exists
|
|
49
|
+
const verifyScript = `
|
|
50
|
+
$exePath = "C:\\Program Files\\GitButler\\gitbutler-tauri.exe"
|
|
51
|
+
if (Test-Path $exePath) {
|
|
52
|
+
Write-Host "GitButler installed successfully at $exePath"
|
|
53
|
+
} else {
|
|
54
|
+
Write-Error "GitButler not found"
|
|
55
|
+
exit 1
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
await testdriver.exec('pwsh', verifyScript, 5000);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
3
|
+
*
|
|
4
|
+
* 1. Open page: https://practicetestautomation.com/practice-test-table/
|
|
5
|
+
* 2. Set Sort by = Enrollments
|
|
6
|
+
* 3. Verify visible rows are ordered from smallest to largest enrollment
|
|
7
|
+
* 4. Verify numbers with commas sort correctly
|
|
8
|
+
* 5. Fails if the sort is lexicographic (string-based) instead of numeric
|
|
9
|
+
*
|
|
10
|
+
* EXPECTED: This test should PASS if enrollments are sorted ascending numerically
|
|
11
|
+
* This test should FAIL if sort is lexicographic or descending
|
|
12
|
+
*/
|
|
13
|
+
import { describe, expect, it } from "vitest";
|
|
14
|
+
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
15
|
+
|
|
16
|
+
describe("Table Sort - Enrollments", () => {
|
|
17
|
+
|
|
18
|
+
it("should sort enrollments numerically ascending", async (context) => {
|
|
19
|
+
const testdriver = TestDriver(context, {
|
|
20
|
+
newSandbox: true,
|
|
21
|
+
headless: false
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Step 1: Open the page
|
|
25
|
+
await testdriver.provision.chrome({
|
|
26
|
+
url: 'https://practicetestautomation.com/practice-test-table/',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Scroll down to see the Sort by dropdown
|
|
30
|
+
await testdriver.scroll("down");
|
|
31
|
+
await testdriver.scroll("down");
|
|
32
|
+
|
|
33
|
+
// Step 2: Find and click the Sort by dropdown
|
|
34
|
+
const sortDropdown = await testdriver.find("Sort by dropdown", { timeout: 15000 });
|
|
35
|
+
console.log("Sort by dropdown found:", sortDropdown.found());
|
|
36
|
+
expect(sortDropdown.found()).toBeTruthy();
|
|
37
|
+
await sortDropdown.click();
|
|
38
|
+
|
|
39
|
+
// Select "Enrollments" from the dropdown options
|
|
40
|
+
const enrollmentsOption = await testdriver.find("Enrollments option", { timeout: 10000 });
|
|
41
|
+
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
42
|
+
expect(enrollmentsOption.found()).toBeTruthy();
|
|
43
|
+
await enrollmentsOption.click();
|
|
44
|
+
|
|
45
|
+
// Scroll to the TOP of the page to see the first rows of the sorted table
|
|
46
|
+
await testdriver.scroll("up");
|
|
47
|
+
await testdriver.scroll("up");
|
|
48
|
+
await testdriver.scroll("up");
|
|
49
|
+
|
|
50
|
+
// Small wait for sort to complete
|
|
51
|
+
await testdriver.pressKeys([""]); // No-op to add small delay
|
|
52
|
+
|
|
53
|
+
// Scroll down just enough to see the table header and first data rows
|
|
54
|
+
await testdriver.scroll("down");
|
|
55
|
+
|
|
56
|
+
// Step 3: Verify the sort is NUMERIC ASCENDING (smallest to largest)
|
|
57
|
+
// For numeric ascending: 10 < 11 < 50 < 1000 < 1200 < 1365
|
|
58
|
+
// If lexicographic: "1,000" < "10" < "11" < "1,200" < "1365" < "50" (wrong - strings compare char by char)
|
|
59
|
+
//
|
|
60
|
+
// The TEST PASSES if first rows show small numbers like 10, 11, 50
|
|
61
|
+
// The TEST FAILS if first rows show large numbers like 1000, 1200, 1365
|
|
62
|
+
const sortResult = await testdriver.assert(
|
|
63
|
+
"The table is sorted by Enrollments in ASCENDING numeric order. " +
|
|
64
|
+
"The FIRST visible enrollment numbers in the table should be the SMALLEST values. " +
|
|
65
|
+
"For example, if the data contains values like 10, 11, 50, 1000, and 1365, " +
|
|
66
|
+
"then 10 or 11 should appear at the TOP of the sorted table. " +
|
|
67
|
+
"If a large number like 1365 appears first, the sort is WRONG (descending or lexicographic)."
|
|
68
|
+
);
|
|
69
|
+
console.log("Numeric ascending sort assertion result:", sortResult);
|
|
70
|
+
expect(sortResult).toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experiment file - reconnects to existing sandbox
|
|
3
|
+
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
4
|
+
* Run AFTER table-sort-setup.test.mjs passes (within 2 minutes)
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
8
|
+
|
|
9
|
+
describe("Table Sort Experiment", () => {
|
|
10
|
+
|
|
11
|
+
it("should sort by Enrollments and verify numeric ordering", async (context) => {
|
|
12
|
+
const testdriver = TestDriver(context, {
|
|
13
|
+
newSandbox: true,
|
|
14
|
+
headless: false,
|
|
15
|
+
reconnect: true // Reconnects to last sandbox
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// NO provision here! The sandbox is already running from setup.test.mjs
|
|
19
|
+
|
|
20
|
+
// Click on the Sort By dropdown and select Enrollments
|
|
21
|
+
const sortDropdown = await testdriver.find("Sort By dropdown");
|
|
22
|
+
console.log("Sort dropdown found:", sortDropdown.found());
|
|
23
|
+
await sortDropdown.click();
|
|
24
|
+
|
|
25
|
+
// Select Enrollments from the dropdown
|
|
26
|
+
const enrollmentsOption = await testdriver.find("Enrollments option in dropdown");
|
|
27
|
+
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
28
|
+
await enrollmentsOption.click();
|
|
29
|
+
|
|
30
|
+
// Verify the table is now sorted by enrollments (ascending, numeric)
|
|
31
|
+
// The numbers should be ordered from smallest to largest: 10, 11, 50, 1000, 1,200
|
|
32
|
+
// If lexicographic: 1,000, 1,200, 10, 11, 50 (wrong - strings sort by first character)
|
|
33
|
+
const result = await testdriver.assert("The table shows enrollment numbers in ascending numeric order where smaller numbers like 10 or 11 appear before larger numbers like 1000 or 1200");
|
|
34
|
+
console.log("Sort assertion result:", result);
|
|
35
|
+
expect(result).toBeTruthy();
|
|
36
|
+
|
|
37
|
+
// Also verify numbers with commas sort correctly (1,200 should be after 1,000)
|
|
38
|
+
const commaResult = await testdriver.assert("Numbers with commas like 1,000 and 1,200 are sorted correctly as numbers, not as text");
|
|
39
|
+
console.log("Comma sort assertion:", commaResult);
|
|
40
|
+
expect(commaResult).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
3
|
+
*
|
|
4
|
+
* 1. Open page: https://practicetestautomation.com/practice-test-table/
|
|
5
|
+
* 2. Set Sort by = Enrollments
|
|
6
|
+
* 3. Verify visible rows are ordered from smallest to largest enrollment
|
|
7
|
+
* 4. Verify numbers with commas sort correctly
|
|
8
|
+
* 5. Fails if the sort is lexicographic
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
12
|
+
|
|
13
|
+
describe("Table Sort - Enrollments", () => {
|
|
14
|
+
|
|
15
|
+
it("should sort enrollments numerically ascending", async (context) => {
|
|
16
|
+
const testdriver = TestDriver(context, {
|
|
17
|
+
newSandbox: true,
|
|
18
|
+
headless: false
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Step 1: Open the page
|
|
22
|
+
await testdriver.provision.chrome({
|
|
23
|
+
url: 'https://practicetestautomation.com/practice-test-table/',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Wait for page to load - find the Sort By dropdown
|
|
27
|
+
const sortDropdown = await testdriver.find("Sort By dropdown or select box", { timeout: 30000 });
|
|
28
|
+
console.log("Sort dropdown found:", sortDropdown.found());
|
|
29
|
+
expect(sortDropdown.found()).toBeTruthy();
|
|
30
|
+
|
|
31
|
+
// Step 2: Click the Sort By dropdown
|
|
32
|
+
await sortDropdown.click();
|
|
33
|
+
|
|
34
|
+
// Select "Enrollments" from the dropdown options
|
|
35
|
+
const enrollmentsOption = await testdriver.find("Enrollments option in the dropdown list", { timeout: 10000 });
|
|
36
|
+
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
37
|
+
await enrollmentsOption.click();
|
|
38
|
+
|
|
39
|
+
// Step 3 & 4: Verify the sort is numeric ascending (not lexicographic)
|
|
40
|
+
// If numeric: smaller numbers (10, 11, 50) come before larger numbers (1000, 1200)
|
|
41
|
+
// If lexicographic: would sort as strings (1,000 before 10 because '1' < '1')
|
|
42
|
+
const sortResult = await testdriver.assert(
|
|
43
|
+
"The table enrollment column is sorted in ascending NUMERIC order: " +
|
|
44
|
+
"smaller enrollment numbers like 10, 11, 50 appear BEFORE larger numbers like 1000 or 1200. " +
|
|
45
|
+
"This is correct numeric sorting, not alphabetical/lexicographic sorting."
|
|
46
|
+
);
|
|
47
|
+
console.log("Numeric sort assertion result:", sortResult);
|
|
48
|
+
expect(sortResult).toBeTruthy();
|
|
49
|
+
|
|
50
|
+
// Step 5: Verify numbers with commas are handled correctly
|
|
51
|
+
// 1,200 should be treated as 1200 (greater than 1000), not as a string
|
|
52
|
+
const commaResult = await testdriver.assert(
|
|
53
|
+
"Any enrollment numbers with commas (like 1,200 or 1,000) are sorted correctly as numbers, " +
|
|
54
|
+
"with 1,000 appearing before 1,200 in ascending order"
|
|
55
|
+
);
|
|
56
|
+
console.log("Comma number sorting result:", commaResult);
|
|
57
|
+
expect(commaResult).toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
});
|