Skip to content

Commit 90fb1bd

Browse files
committed
wip
1 parent de59c6a commit 90fb1bd

File tree

7 files changed

+197
-74
lines changed

7 files changed

+197
-74
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ dist
105105
/test-results/
106106
/playwright-report/
107107
/playwright/.cache/
108+
/test-results/
109+
/playwright-report/
110+
/playwright/.cache/

infra/po/login.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Locator } from "@playwright/test";
2+
3+
export class LoginPage {
4+
/**
5+
* @param {import('playwright').Page} page
6+
*/
7+
8+
page;
9+
usernameTb: Locator;
10+
passwordTb: Locator;
11+
signInBtn: Locator;
12+
siginInToggle: Locator;
13+
14+
constructor(page) {
15+
this.page = page;
16+
this.siginInToggle = page.locator("span:has-text('Sign in')");
17+
this.usernameTb = page.locator('input[name="username"]');
18+
this.passwordTb = page.locator('input[name="password"]');
19+
this.signInBtn = page.locator('input:has-text("Sign in")');
20+
// await page.locator("span:has-text('Sign in')").click()
21+
// // Fill input[name="username"]
22+
// await page.locator('input[name="username"]').fill('admin');
23+
24+
// // Fill input[name="password"]
25+
// await page.locator('input[name="password"]').fill('adminadmin');
26+
27+
// // Click input:has-text("Sign in")
28+
// await Promise.all([
29+
// page.locator('input:has-text("Sign in")').click(),
30+
31+
32+
33+
}
34+
async navigate() {
35+
await this.page.goto('http://localhost:8080');
36+
}
37+
38+
async clickOnSignInToggle() {
39+
await this.siginInToggle.click();
40+
}
41+
async fillUsername(username: string){
42+
await this.usernameTb.fill(username);
43+
}
44+
async fillPassword(password: string){
45+
await this.passwordTb.fill(password);
46+
}
47+
async clickOnSignInBtn(){
48+
await this.signInBtn.click();
49+
}
50+
}
51+
module.exports = { LoginPage };

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const config: PlaywrightTestConfig = {
4040

4141
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4242
trace: 'on-first-retry',
43+
headless: false
4344
},
4445

4546
/* Configure projects for major browsers */

tests/google.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
4+
test.describe("Search", ()=> {
5+
test('Search for specfic string in Google', async ({ page }) => {
6+
7+
// Go to https://www.google.com/
8+
await page.goto('https://www.google.com/');
9+
await page.locator("[name='q']").fill("Cheese");
10+
11+
// Click text=חיפוש ב-Google >> nth=1
12+
await page.locator('text=חיפוש ב-Google').nth(1).click();
13+
await expect(page).toHaveTitle('Cheese - חיפוש ב-Google');
14+
15+
// Go to https://en.wikipedia.org/wiki/Cheese
16+
await page.goto('https://en.wikipedia.org/wiki/Cheese');
17+
18+
});
19+
});

tests/test-openproject-flat.spec.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { test, expect, type Page } from '@playwright/test';
2+
3+
async function performLogin(page: Page) {
4+
await page.goto('http://localhost:8080/');
5+
6+
await page.locator("span:has-text('Sign in')").click()
7+
// Fill input[name="username"]
8+
await page.locator('input[name="username"]').fill('admin');
9+
10+
// Fill input[name="password"]
11+
await page.locator('input[name="password"]').fill('adminadmin');
12+
13+
// Click input:has-text("Sign in")
14+
await Promise.all([
15+
page.locator('input:has-text("Sign in")').click(),
16+
page.waitForNavigation(),
17+
]);
18+
19+
20+
await expect(page).toHaveURL('http://localhost:8080/');
21+
22+
}
23+
24+
25+
test.describe('Task', () => {
26+
test.beforeEach(async ({ page }) => {
27+
await performLogin(page);
28+
29+
30+
});
31+
test('create task', async ({ page }) => {
32+
await page.locator("#projects-menu i").click();
33+
34+
await page.locator("#ui-id-5 >> text=Selenium project").click();
35+
await page.locator("#main-menu-work-packages >> text=Work packages").click();
36+
37+
await page.locator("text=Create Include projects >> [aria-label='Create new work package']").click();
38+
await page.locator("div#types-context-menu a[aria-label='Task']").click();
39+
let task_name = "Task " + Math.random();
40+
await page.locator("id=wp-new-inline-edit--field-subject").fill(task_name);
41+
await page.locator("button:has-text('Save')").click();
42+
await page.locator("[aria-label='Activate Filter']").click();
43+
await page.locator("id=filter-by-text-input").fill(task_name);
44+
await page.locator("a[title='Close form']").click();
45+
await page.locator("button[title='Close details view'] i.icon-close.icon-no-color").click();
46+
await page.locator("text='(1 - 1/1)'").waitFor();
47+
let locator = page.locator("i.icon-show-more-horizontal");
48+
await locator.hover();
49+
await locator.click();
50+
await page.locator("[aria-label='Delete']").click();
51+
52+
await page.locator("button:has-text('Confirm')").click();
53+
await page.locator("text=Successfully deleted work packages.").waitFor();
54+
await page.locator("text=No work packages to display.").waitFor();
55+
56+
});
57+
58+
});

tests/test-openproject-po.spec.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { test, expect, type Page } from '@playwright/test';
2+
import {LoginPage} from '../infra/po/login';
3+
4+
async function performLogin(page: Page) {
5+
const loginPage = new LoginPage(page);
6+
await loginPage.navigate();
7+
await loginPage.clickOnSignInToggle();
8+
await loginPage.fillUsername("admin");
9+
await loginPage.fillPassword("adminadmin");
10+
await loginPage.clickOnSignInBtn();
11+
// await page.goto('http://localhost:8080/');
12+
13+
// await page.locator("span:has-text('Sign in')").click()
14+
// // Fill input[name="username"]
15+
// await page.locator('input[name="username"]').fill('admin');
16+
17+
// // Fill input[name="password"]
18+
// await page.locator('input[name="password"]').fill('adminadmin');
19+
20+
// // Click input:has-text("Sign in")
21+
// await Promise.all([
22+
// page.locator('input:has-text("Sign in")').click(),
23+
// page.waitForNavigation(),
24+
// ]);
25+
26+
27+
await expect(page).toHaveURL('http://localhost:8080/');
28+
29+
}
30+
31+
32+
test.describe('Task', () => {
33+
test.beforeEach(async ({ page }) => {
34+
await performLogin(page);
35+
36+
37+
});
38+
test('create task', async ({ page }) => {
39+
await page.locator("#projects-menu i").click();
40+
41+
await page.locator("#ui-id-5 >> text=Selenium project").click();
42+
await page.locator("#main-menu-work-packages >> text=Work packages").click();
43+
44+
await page.locator("text=Create Include projects >> [aria-label='Create new work package']").click();
45+
await page.locator("div#types-context-menu a[aria-label='Task']").click();
46+
let task_name = "Task " + Math.random();
47+
await page.locator("id=wp-new-inline-edit--field-subject").fill(task_name);
48+
await page.locator("button:has-text('Save')").click();
49+
await page.locator("[aria-label='Activate Filter']").click();
50+
await page.locator("id=filter-by-text-input").fill(task_name);
51+
await page.locator("a[title='Close form']").click();
52+
await page.locator("button[title='Close details view'] i.icon-close.icon-no-color").click();
53+
await page.locator("text='(1 - 1/1)'").waitFor();
54+
let locator = page.locator("i.icon-show-more-horizontal");
55+
await locator.hover();
56+
await locator.click();
57+
await page.locator("[aria-label='Delete']").click();
58+
59+
await page.locator("button:has-text('Confirm')").click();
60+
await page.locator("text=Successfully deleted work packages.").waitFor();
61+
await page.locator("text=No work packages to display.").waitFor();
62+
63+
});
64+
65+
});

tests/test-openproject.spec.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)