Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/migration-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Migration Agent

on:
workflow_dispatch:
push:
branches:
- migration

jobs:
run-agent:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies (if present)
run: |
if [ -f playwrite/package.json ]; then
cd playwrite
npm ci
npx playwright install --with-deps
else
echo "No package.json in playwrite/, skipping npm install"
fi

- name: Run migration agent (convert)
run: |
cd playwrite
node githubcopilot-agent/index.js convert

- name: Run converted tests (if present)
if: ${{ always() }}
run: |
if [ -f playwrite/package.json ]; then
cd playwrite
npm run test:all || true
else
echo "No package.json in playwrite/, skipping tests"
fi

- name: Upload converted artifacts
uses: actions/upload-artifact@v4
with:
name: converted-files
path: playwrite/converted/**
21 changes: 21 additions & 0 deletions playwrite/converted/pages/ContactsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Page } from 'playwright';

export class ContactsPage {
constructor(private page: Page) {}

async verifyContactsLabel() {
return await this.page.isVisible(`xpath=//td[contains(text(),\'Contacts\')]`);
}

async selectContactsByName(name) {
// TODO: Add implementation
}

async createNewContact(title, ftName, ltName, comp) {
await this.page.fill('#first_name', ftName);
await this.page.fill('#surname', ltName);
await this.page.fill('[name="client_lookup"]', comp);
await this.page.click(`xpath=//input[@type=\'submit\' and @value=\'Save\']`);
}

}
6 changes: 6 additions & 0 deletions playwrite/converted/pages/DealsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Page } from 'playwright';

export class DealsPage {
constructor(private page: Page) {}

}
33 changes: 33 additions & 0 deletions playwrite/converted/pages/HomePage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Page } from 'playwright';

export class HomePage {
constructor(private page: Page) {}

async verifyHomePageTitle() {
return await this.page.title();
}

async verifyCorrectUserName() {
// TODO: Add implementation
}

async clickOnContactsLink() {
await this.page.click(`xpath=//a[contains(text(),\'Contacts\')]`);
// Page transition to ContactsPage
}

async clickOnDealsLink() {
await this.page.click(`xpath=//a[contains(text(),\'Deals\')]`);
// Page transition to DealsPage
}

async clickOnTasksLink() {
await this.page.click(`xpath=//a[contains(text(),\'Tasks\')]`);
// Page transition to TasksPage
}

async clickOnNewContactLink() {
await this.page.click(`xpath=//a[contains(text(),\'New Contact\')]`);
}

}
22 changes: 22 additions & 0 deletions playwrite/converted/pages/LoginPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Page } from 'playwright';

export class LoginPage {
constructor(private page: Page) {}

async validateLoginPageTitle() {
return await this.page.title();
}

async validateCRMImage() {
return await this.page.isVisible(`xpath=//img[contains(@class,\'img-responsive\')]`);
}

async login(un, pwd) {
await this.page.fill('[name="username"]', un);
await this.page.fill('[name="password"]', pwd);
await this.page.click(`xpath=//input[@type=\'submit\']`);
// JavaScript executor call (review manually)
// Page transition to HomePage
}

}
6 changes: 6 additions & 0 deletions playwrite/converted/pages/SignUpPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Page } from 'playwright';

export class SignUpPage {
constructor(private page: Page) {}

}
6 changes: 6 additions & 0 deletions playwrite/converted/pages/TasksPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Page } from 'playwright';

export class TasksPage {
constructor(private page: Page) {}

}
35 changes: 35 additions & 0 deletions playwrite/converted/tests/ContactsPageTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { chromium } from 'playwright';
import { ContactsPage } from '../pages/ContactsPage';
import { HomePage } from '../pages/HomePage';
import { LoginPage } from '../pages/LoginPage';

(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
const BASE_URL = process.env.BASE_URL || 'https://www.freecrm.com';
await page.goto(BASE_URL);
const contactsPage = new ContactsPage(page);
const homePage = new HomePage(page);
const loginPage = new LoginPage(page);

try {
// @Test: verifyContactsPageLabel

// @Test: selectSingleContactsTest
await contactsPage.selectContactsByName("test2 test2");

// @Test: selectMultipleContactsTest
await contactsPage.selectContactsByName("test2 test2");
await contactsPage.selectContactsByName("ui uiii");

// @Test: validateCreateNewContact
await homePage.clickOnNewContactLink();
await contactsPage.createNewContact(title, firstName, lastName, company);

console.log('All tests passed!');
} catch (err) {
console.error('Test failed:', err);
} finally {
await browser.close();
}
})();
11 changes: 11 additions & 0 deletions playwrite/converted/tests/FreeCrmTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { chromium } from 'playwright';

(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
const BASE_URL = process.env.BASE_URL || 'https://www.freecrm.com';

try {
console.log('Converted test executed (you must review and run it manually).');
} catch (err) { console.error(err); } finally { await browser.close(); }
})();
32 changes: 32 additions & 0 deletions playwrite/converted/tests/HomePageTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { chromium } from 'playwright';
import { ContactsPage } from '../pages/ContactsPage';
import { HomePage } from '../pages/HomePage';
import { LoginPage } from '../pages/LoginPage';

(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
const BASE_URL = process.env.BASE_URL || 'https://www.freecrm.com';
await page.goto(BASE_URL);
const contactsPage = new ContactsPage(page);
const homePage = new HomePage(page);
const loginPage = new LoginPage(page);

try {
// @Test: verifyHomePageTitleTest
await homePage.verifyHomePageTitle();

// @Test: verifyUserNameTest
await testUtil.switchToFrame();

// @Test: verifyContactsLinkTest
await testUtil.switchToFrame();
await homePage.clickOnContactsLink();

console.log('All tests passed!');
} catch (err) {
console.error('Test failed:', err);
} finally {
await browser.close();
}
})();
29 changes: 29 additions & 0 deletions playwrite/converted/tests/LoginPageTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { chromium } from 'playwright';
import { HomePage } from '../pages/HomePage';
import { LoginPage } from '../pages/LoginPage';

(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
const BASE_URL = process.env.BASE_URL || 'https://www.freecrm.com';
await page.goto(BASE_URL);
const homePage = new HomePage(page);
const loginPage = new LoginPage(page);

try {
// @Test: loginPageTitleTest
await loginPage.validateLoginPageTitle();

// @Test: crmLogoImageTest
await loginPage.validateCRMImage();

// @Test: loginTest
await loginPage.login('username', 'password');

console.log('All tests passed!');
} catch (err) {
console.error('Test failed:', err);
} finally {
await browser.close();
}
})();
26 changes: 26 additions & 0 deletions playwrite/githubcopilot-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
GitHub Copilot Migration Agent (simple wrapper)

Purpose
- Provide a small CLI that wraps the existing Java->Playwright converter and the test runner.

Quick usage
From `playwrite/` folder:

```powershell
# Run the converter
node githubcopilot-agent/index.js convert

# List converted files
node githubcopilot-agent/index.js list

# Run all converted tests
node githubcopilot-agent/index.js run-tests
```

Notes
- This agent is a lightweight wrapper that calls the converter located at `tools/javaToPlaywright.cjs`.
- The agent is intentionally simple so it is safe to extend with additional checks, pre-processing, or post-processing steps in future.

Extending
- Add flags to `index.js` to enable incremental conversion or to pass custom paths.
- Add authentication/credential sync code to pull config values from `src/main/java/.../config.properties` and populate `.env` for tests.
66 changes: 66 additions & 0 deletions playwrite/githubcopilot-agent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env node
// Simple GitHub Copilot-style migration agent wrapper for Java -> Playwright
// Usage: node index.js convert

const { spawnSync } = require('child_process');
const path = require('path');
const fs = require('fs');

const repoRoot = path.join(__dirname, '..');
const toolsDir = path.join(repoRoot, 'tools');
const converter = path.join(toolsDir, 'javaToPlaywright.cjs');
const convertedDir = path.join(repoRoot, 'converted');

function runConverter() {
if (!fs.existsSync(converter)) {
console.error('Converter not found at', converter);
process.exit(1);
}
console.log('Running converter...');
const res = spawnSync('node', [converter], { stdio: 'inherit', cwd: repoRoot });
process.exit(res.status || 0);
}

function listConverted() {
if (!fs.existsSync(convertedDir)) {
console.log('No converted directory found');
return;
}
console.log('Converted pages:');
const pages = fs.readdirSync(path.join(convertedDir, 'pages')).filter(f => f.endsWith('.ts'));
pages.forEach(p => console.log(' -', p));
console.log('\nConverted tests:');
const tests = fs.readdirSync(path.join(convertedDir, 'tests')).filter(f => f.endsWith('.ts'));
tests.forEach(t => console.log(' -', t));
}

function runAllTests() {
console.log('Running test runner (npm run test:all)');
const res = spawnSync('npm', ['run', 'test:all'], { stdio: 'inherit', cwd: repoRoot, shell: true });
process.exit(res.status || 0);
}

function help() {
console.log('GitHub Copilot Migration Agent — Commands:');
console.log(' convert Run the Java->Playwright converter');
console.log(' list List converted files (pages & tests)');
console.log(' run-tests Run all converted tests via the project test runner');
console.log(' help Show this help');
}

(async function main() {
const cmd = process.argv[2] || 'help';
switch (cmd) {
case 'convert':
runConverter();
break;
case 'list':
listConverted();
break;
case 'run-tests':
runAllTests();
break;
default:
help();
}
})();
13 changes: 13 additions & 0 deletions playwrite/githubcopilot-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "githubcopilot-migration-agent",
"version": "0.1.0",
"private": true,
"bin": {
"gc-migrate": "index.js"
},
"scripts": {
"convert": "node index.js convert",
"list": "node index.js list",
"run-tests": "node index.js run-tests"
}
}
Loading