-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Need to debug a few as the playwright tests are not coming out consistent. (IE: running sqlite test by itself works 100% but when running with the others, it seems to fail ... )
- Loading branch information
Showing
12 changed files
with
643 additions
and
38 deletions.
There are no files selected for viewing
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { execSync, spawn } from "child_process"; | ||
import { test as RillTest } from "../utils/test"; | ||
|
||
import path from "node:path"; | ||
import { DuckDB, waitForTable } from "../utils/sourceHelpers"; | ||
|
||
//DuckDB requires 1 worker as it doesnt allow concurrency, will fail otherwise. | ||
|
||
test.describe("Read DuckDB Table, then read into Rill", () => { | ||
async function ensureDuckDBInstalled() { | ||
try { | ||
// Check if DuckDB is installed | ||
execSync("duckdb --version", { stdio: "ignore" }); | ||
console.log("DuckDB is already installed."); | ||
} catch (err) { | ||
console.log("DuckDB not found. Installing..."); | ||
// Install DuckDB (example for macOS/Linux using wget) | ||
// https://github.com/duckdb/duckdb/releases/latest/download/duckdb_cli-linux-amd64.zip | ||
try { | ||
execSync( | ||
` | ||
wget https://github.com/duckdb/duckdb/releases/download/v1.1.3/duckdb_cli-osx-universal.zip && | ||
unzip duckdb_cli-osx-universal.zip && | ||
chmod +x duckdb && | ||
sudo mv duckdb /usr/local/bin/ | ||
`, | ||
{ stdio: "inherit" }, | ||
); | ||
|
||
console.log("DuckDB installed successfully."); | ||
} catch (error) { | ||
console.error("DuckDB installation failed:", error); | ||
} | ||
console.log("DuckDB installed successfully."); | ||
} | ||
} | ||
|
||
test.beforeAll(async () => { | ||
await ensureDuckDBInstalled(); | ||
const currentDir = process.cwd(); | ||
const dbPath = path.resolve(currentDir, "test/data/playwright.db"); | ||
const commands = [ | ||
`.open ${dbPath}`, | ||
"select count(*) from sales;", | ||
"select count(*) from customer_data;", | ||
".exit", | ||
]; | ||
console.log(`Running DuckDB commands against: ${dbPath}`); | ||
|
||
await new Promise((resolve, reject) => { | ||
const cli = spawn("duckdb", [], { shell: true }); | ||
|
||
let output = ""; | ||
cli.stdout.on("data", (data) => { | ||
output += data.toString(); | ||
}); | ||
|
||
cli.stderr.on("data", (data) => { | ||
console.error(`Error: ${data}`); | ||
}); | ||
|
||
cli.on("close", (code) => { | ||
if (code === 0) { | ||
console.log("DuckDB CLI execution completed successfully."); | ||
const salesCountMatch = output.match(/100000/); // Expected count for sales | ||
const customerCountMatch = output.match(/10000/); // Expected count for customer_data | ||
|
||
expect(salesCountMatch).not.toBeNull(); | ||
expect(customerCountMatch).not.toBeNull(); | ||
resolve(); | ||
} else { | ||
reject(new Error(`DuckDB CLI exited with code ${code}`)); | ||
} | ||
}); | ||
|
||
// Write commands to DuckDB CLI | ||
commands.forEach((cmd) => cli.stdin.write(`${cmd}\n`)); | ||
cli.stdin.end(); | ||
}); | ||
}); | ||
|
||
test("Validate data in DuckDB", async () => { | ||
console.log("Validation complete in beforeAll."); | ||
}); | ||
|
||
console.log("Checked DuckDB with sales and customer_data tables."); | ||
console.log("Starting Rill Developer..."); | ||
|
||
RillTest("Reading Source into Rill", async ({ page }) => { | ||
// Test loading the 'sales' table | ||
await Promise.all([ | ||
waitForTable(page, "sources/sales.yaml", [ | ||
"sale_date", | ||
"sale_id", | ||
"duration_ms", | ||
"customer_id", | ||
"sales_amount_usd", | ||
"products", | ||
"discounts", | ||
"region", | ||
"is_online", | ||
]), | ||
DuckDB(page, "sales"), // Ensure the `sales` dataset is loaded | ||
]); | ||
|
||
console.log("Sales table validated."); | ||
|
||
// Test loading the 'customer_data' table | ||
await Promise.all([ | ||
waitForTable(page, "sources/customer_data.yaml", [ | ||
"customer_id", | ||
"name", | ||
"email", | ||
"signup_date", | ||
"preferences", | ||
"total_spent_usd", | ||
"loyalty_tier", | ||
"is_active", | ||
]), | ||
DuckDB(page, "customer_data"), // Ensure the `customer_data` dataset is loaded | ||
]); | ||
|
||
console.log("Customer data table validated."); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { test } from "@playwright/test"; | ||
import { test as RillTest } from "../utils/test"; | ||
import { addFolderWithCheck } from "../utils/sourceHelpers"; | ||
|
||
/// Blank Folder test | ||
/// In this test we create a `untilted_file`, create a second one to ensure `_1` is appended | ||
|
||
test.describe("Creating a Folder... and making a source.", () => { | ||
RillTest("Creating Folder", async ({ page }) => { | ||
// create folder file | ||
await Promise.all([addFolderWithCheck(page, "untitled_folder_3")]); | ||
await Promise.all([addFolderWithCheck(page, "untitled_folder_1")]); | ||
await Promise.all([addFolderWithCheck(page, "untitled_folder_")]); | ||
// create folder in subfolder | ||
await page.locator('span:has-text("untitled_folder_2")').last().hover(); | ||
await page.getByLabel("untitled_folder_2 actions menu trigger").click(); | ||
await page.getByRole("menuitem", { name: "New Folder" }).first().click(); | ||
|
||
// check that the folder exists, | ||
await page.waitForSelector("#nav-\\/untitled_folder_2\\/untitled_folder", { | ||
timeout: 5000, | ||
}); | ||
await page | ||
.locator('[aria-label="/untitled_folder_2/untitled_folder"]') | ||
.isVisible(); | ||
|
||
// create another for proper "_1" append | ||
await page.locator('span:has-text("untitled_folder_2")').last().hover(); | ||
await page.getByLabel("untitled_folder_2 actions menu trigger").click(); | ||
await page.getByRole("menuitem", { name: "New Folder" }).first().click(); | ||
|
||
await page.waitForSelector( | ||
"#nav-\\/untitled_folder_2\\/untitled_folder_1", | ||
{ timeout: 5000 }, | ||
); | ||
await page | ||
.locator('[aria-label="/untitled_folder_2/untitled_folder_1"]') | ||
.isVisible(); | ||
}); | ||
}); |
Oops, something went wrong.