This commit is contained in:
commit
c70a1d2806
27
.github/workflows/playwright.yml
vendored
Normal file
27
.github/workflows/playwright.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
name: Playwright Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps
|
||||
- name: Run Playwright tests
|
||||
run: npx playwright test
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# Distribution
|
||||
dist
|
||||
out
|
||||
build
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
*.log*
|
||||
logs
|
||||
|
||||
# Environment
|
||||
*.env*
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"deno.enable": true,
|
||||
"deno.lint": true
|
||||
}
|
9
deno.json
Normal file
9
deno.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run --watch main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@std/assert": "jsr:@std/assert@1"
|
||||
},
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
56
deno.lock
generated
Normal file
56
deno.lock
generated
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@std/assert@1": "1.0.7",
|
||||
"jsr:@std/internal@^1.0.5": "1.0.5",
|
||||
"npm:@playwright/test@*": "1.48.2",
|
||||
"npm:@types/node@*": "22.5.4",
|
||||
"npm:playwright@*": "1.48.2"
|
||||
},
|
||||
"jsr": {
|
||||
"@std/assert@1.0.7": {
|
||||
"integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3",
|
||||
"dependencies": [
|
||||
"jsr:@std/internal"
|
||||
]
|
||||
},
|
||||
"@std/internal@1.0.5": {
|
||||
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
|
||||
}
|
||||
},
|
||||
"npm": {
|
||||
"@playwright/test@1.48.2": {
|
||||
"integrity": "sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==",
|
||||
"dependencies": [
|
||||
"playwright"
|
||||
]
|
||||
},
|
||||
"@types/node@22.5.4": {
|
||||
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
|
||||
"dependencies": [
|
||||
"undici-types"
|
||||
]
|
||||
},
|
||||
"fsevents@2.3.2": {
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
|
||||
},
|
||||
"playwright-core@1.48.2": {
|
||||
"integrity": "sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA=="
|
||||
},
|
||||
"playwright@1.48.2": {
|
||||
"integrity": "sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==",
|
||||
"dependencies": [
|
||||
"fsevents",
|
||||
"playwright-core"
|
||||
]
|
||||
},
|
||||
"undici-types@6.19.8": {
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"jsr:@std/assert@1"
|
||||
]
|
||||
}
|
||||
}
|
113
main.ts
Normal file
113
main.ts
Normal file
@ -0,0 +1,113 @@
|
||||
import playwright from "npm:playwright";
|
||||
|
||||
if (import.meta.main) {
|
||||
main();
|
||||
}
|
||||
|
||||
const devSpacename = Deno.env.get("BAS_DEVSPACE")!;
|
||||
|
||||
async function main() {
|
||||
const browser = await playwright.chromium.launch({
|
||||
headless: false,
|
||||
});
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
// stuff
|
||||
await page.goto(Deno.env.get("BAS_URL")!);
|
||||
await page.locator(`text=${Deno.env.get("BAS_PROFILE")!}`).click();
|
||||
await page
|
||||
.getByLabel("Email or User Name")
|
||||
.fill(Deno.env.get("BAS_USERNAME")!);
|
||||
await page.getByLabel("Password").fill(Deno.env.get("BAS_PASSWORD")!);
|
||||
await page.waitForTimeout(500);
|
||||
await page.getByText("Keep me signed in").check();
|
||||
await page.waitForTimeout(500);
|
||||
await page.getByText("Continue").click();
|
||||
await page.waitForLoadState();
|
||||
await page.waitForURL("**/index.html");
|
||||
|
||||
// Request manager without iframe directly
|
||||
await page.goto(Deno.env.get("BAS_URL")! + "/workspace-manager-ui/");
|
||||
await page.waitForTimeout(1000);
|
||||
console.log(`Loaded management page`);
|
||||
|
||||
// const pageSource = await page.content();
|
||||
// console.log(JSON.stringify(pageSource));
|
||||
|
||||
const devSpaceEl = await findCorrectDevspace(page);
|
||||
if (!devSpaceEl) {
|
||||
console.log;
|
||||
throw Error(`Could not find devspace: ${devSpacename}`);
|
||||
}
|
||||
await startDevSpace(devSpaceEl);
|
||||
await loadVSCode(devSpaceEl);
|
||||
// await expect(page.locator('css=a.runningStatus')).toBeVisible()
|
||||
|
||||
// await expect(spaces.locator('a.runningStatus')).toHaveText('RUNNING');
|
||||
// spaces.locator('a.hyperlink').click()
|
||||
// spaces..
|
||||
|
||||
// Close on done
|
||||
await new Promise((resolve) => {
|
||||
page.on("close", resolve); // <-- add this
|
||||
});
|
||||
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
async function findCorrectDevspace(page: playwright.Page) {
|
||||
const rows = await page
|
||||
.locator('div.dev-spaces-row:has-text("' + devSpacename + '")')
|
||||
.all();
|
||||
|
||||
let findFullStack = false;
|
||||
if (rows.length > 1) {
|
||||
console.log(`Found multiple "${devSpacename}" dev spaces`);
|
||||
findFullStack = true;
|
||||
}
|
||||
|
||||
for (const el of rows) {
|
||||
console.log(`Checking dev space row`);
|
||||
const fullstack = await el
|
||||
.locator(
|
||||
'div.left-row:has-text("Full-Stack Application Using Productivity Tools")'
|
||||
)
|
||||
.isVisible();
|
||||
|
||||
if (fullstack) {
|
||||
console.log(`Found the fullstack dev space row`);
|
||||
}
|
||||
|
||||
// Skip non-fullstack lines if they exist for that name
|
||||
if (findFullStack && !fullstack) {
|
||||
continue;
|
||||
}
|
||||
return el;
|
||||
}
|
||||
}
|
||||
|
||||
async function startDevSpace(devSpaceEl: playwright.Locator) {
|
||||
const running = await devSpaceEl
|
||||
.locator('div.text-center a:has-text("RUNNING")')
|
||||
.isVisible();
|
||||
|
||||
if (running) {
|
||||
console.log(`Dev Space already running`);
|
||||
return true;
|
||||
}
|
||||
|
||||
await devSpaceEl.locator('button[id^="startButton"]').click()
|
||||
|
||||
await devSpaceEl
|
||||
.locator('div.text-center a:has-text("STARTING")')
|
||||
.isVisible();
|
||||
console.log(`starting...`)
|
||||
|
||||
}
|
||||
|
||||
async function loadVSCode(devSpaceEl: playwright.Locator) {
|
||||
console.log(`Opening VSCode dev space`)
|
||||
await devSpaceEl.locator('a:has-text("' + devSpacename + '")').click();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user