Skip to content

Commit be54193

Browse files
committed
test(playwright): multiple servers
1 parent a729e29 commit be54193

File tree

8 files changed

+62
-41
lines changed

8 files changed

+62
-41
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ docker compose up
147147
Browse to the local URL http://localhost:8080/
148148
The different server can be accessed by increasing the port number by 1.
149149

150+
### Integration tests
151+
152+
Currently, not all integration tests are migrated to Playwright. So there are Jasmine and Playwright tests.
153+
154+
#### Jasmine
155+
156+
```shell
157+
cd tobago-example/tobago-example-demo
158+
mvn clean verify -Pdocker -Pintegration-tests
159+
```
160+
161+
#### Playwright
162+
163+
Start servers as described in [Docker compose](#Docker-compose).
164+
165+
```shell
166+
cd tobago-example/tobago-example-demo
167+
npm run test
168+
```
169+
170+
* test with different browsers `npm run test`
171+
* test with Firefox`npm run test:firefox`
172+
* test with Google Chrome `npm run test:chrome`
173+
* test with different browsers on different servers `npm run test:all-servers`
174+
150175
# Issue Tracking
151176

152177
If you find any issues regarding MyFaces Tobago you can use

tobago-example/tobago-example-demo/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"homepage": "https://myfaces.apache.org/tobago/",
1515
"scripts": {
16-
"build": "npm-run-all --parallel ts css fa jasmine test",
16+
"build": "npm-run-all --parallel ts css fa jasmine",
1717
"css": "npm-run-all css-compile css-prefix css-minify",
1818
"css-lint": "echo 'Not implemented yet!'",
1919
"css-compile": "sass --style expanded --source-map --embed-sources --no-error-css --load-path=./ src/main/scss/demo.scss:src/main/webapp/css/demo.css",
@@ -33,7 +33,10 @@
3333
"rollup": "rollup --config",
3434
"update-check": "npx npm-check-updates",
3535
"update-execute": "npx npm-check-updates -u",
36-
"test": "echo 'Skipping'"
36+
"test": "npx playwright test",
37+
"test:chrome": "npx playwright test --project='Jetty - Google Chrome'",
38+
"test:firefox": "npx playwright test --project='Jetty - Firefox'",
39+
"test:all-servers": "npx playwright test --config=playwright.servers.config.ts"
3740
},
3841
"dependencies": {
3942
"font-awesome": "4.7.0",

tobago-example/tobago-example-demo/playwright.config.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* under the License.
1818
*/
1919

20-
import {defineConfig, devices} from "@playwright/test";
20+
import {devices, PlaywrightTestConfig} from "@playwright/test";
2121

22-
export default defineConfig({
22+
const defaultConfig: PlaywrightTestConfig = {
2323
testDir: "./src/test/typescript",
2424
outputDir: "./target/test-results",
2525
reporter: [["html", {outputFolder: "./target/playwright-report"}]],
@@ -44,18 +44,8 @@ export default defineConfig({
4444
{
4545
name: "Jetty - Safari",
4646
use: {baseURL: "http://localhost:8080", ...devices["Desktop Safari"]}
47-
},
48-
{
49-
name: "Open Liberty - Chromium",
50-
use: {baseURL: "http://localhost:8081", ...devices["Desktop Chrome"]}
51-
},
52-
{
53-
name: "Tomcat - Chromium",
54-
use: {baseURL: "http://localhost:8082", ...devices["Desktop Chrome"]}
55-
},
56-
{
57-
name: "TomEE - Chromium",
58-
use: {baseURL: "http://localhost:8083", ...devices["Desktop Chrome"]}
5947
}
6048
]
61-
});
49+
};
50+
51+
export default defaultConfig;

tobago-example/tobago-example-demo/src/test/typescript/base/Functions.ts renamed to tobago-example/tobago-example-demo/playwright.servers.config.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@
1717
* under the License.
1818
*/
1919

20-
import {Page, TestInfo, TestType} from "@playwright/test";
20+
import {devices, PlaywrightTestConfig} from "@playwright/test";
21+
import defaultConfig from "./playwright.config";
2122

22-
export async function goto(test: TestType<any, any>, page: Page, testInfo: TestInfo, url: string): Promise<void> {
23-
const baseURL = testInfo.project.use.baseURL;
24-
25-
try {
26-
const response = await fetch(baseURL);
27-
if (response.ok) {
28-
await page.goto(url);
29-
} else {
30-
test.skip(true, baseURL + " not available; " + response.status + " - " + response.statusText);
23+
const serversConfig: PlaywrightTestConfig = {
24+
...defaultConfig,
25+
projects: [
26+
...defaultConfig.projects,
27+
{
28+
name: "Open Liberty - Chromium",
29+
use: {baseURL: "http://localhost:8081", ...devices["Desktop Chrome"]}
30+
},
31+
{
32+
name: "Tomcat - Chromium",
33+
use: {baseURL: "http://localhost:8082", ...devices["Desktop Chrome"]}
34+
},
35+
{
36+
name: "TomEE - Chromium",
37+
use: {baseURL: "http://localhost:8083", ...devices["Desktop Chrome"]}
3138
}
32-
} catch {
33-
test.skip(true, baseURL + " not available");
34-
}
35-
}
39+
]
40+
};
41+
42+
export default serversConfig;

tobago-example/tobago-example-demo/src/test/typescript/columnSelector.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
*/
1919

2020
import {expect, test} from "@playwright/test";
21-
import {goto} from "./base/Functions";
2221

2322
test.describe("sheet/columnSelector/ajax/ajax.xhtml", () => {
2423

2524
test.beforeEach(async ({page}, testInfo) => {
26-
await goto(test, page, testInfo, "/content/900-test/sheet/columnSelector/ajax/ajax.xhtml");
25+
await page.goto("/content/900-test/sheet/columnSelector/ajax/ajax.xhtml");
2726
});
2827

2928
test("immediate=true, ajax=enabled", async ({page}) => {

tobago-example/tobago-example-demo/src/test/typescript/selectManyList.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
*/
1919

2020
import {expect, test} from "@playwright/test";
21-
import {goto} from "./base/Functions";
2221

2322
test.describe("900-test/2100-selectManyList/deselect/deselect.xhtml", () => {
2423

2524
test.beforeEach(async ({page}, testInfo) => {
26-
await goto(test, page, testInfo, "/content/900-test/selectManyList/deselect/deselect.xhtml");
25+
await page.goto("/content/900-test/selectManyList/deselect/deselect.xhtml");
2726
});
2827

2928
test("tc:selectManyList: deselect", async ({page}) => {

tobago-example/tobago-example-demo/src/test/typescript/sheet.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919

2020
import {expect, test} from "@playwright/test";
2121
import {Table} from "./base/bootstrap-variables";
22-
import {goto} from "./base/Functions";
2322

2423
test.describe("sheet/columnNode/ColumnNode.xhtml", () => {
2524

2625
test.beforeEach(async ({page}, testInfo) => {
27-
await goto(test, page, testInfo, "/content/900-test/sheet/columnNode/ColumnNode.xhtml");
26+
await page.goto("/content/900-test/sheet/columnNode/ColumnNode.xhtml");
2827
});
2928

3029
test("Open the 'World' node to see 'Carib' and 'Africa'", async ({page}) => {
@@ -124,7 +123,7 @@ test.describe("sheet/columnNode/ColumnNode.xhtml", () => {
124123
test.describe("sheet/columnPanel/ColumnPanel.xhtml", () => {
125124

126125
test.beforeEach(async ({page}, testInfo) => {
127-
await goto(test, page, testInfo, "content/900-test/sheet/columnPanel/ColumnPanel.xhtml");
126+
await page.goto("content/900-test/sheet/columnPanel/ColumnPanel.xhtml");
128127
});
129128

130129
test("Markup 'striped'", async ({page}) => {

tobago-example/tobago-example-demo/src/test/typescript/tabGroup.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
import {expect, Locator, test} from "@playwright/test";
2121
import {Color} from "./base/browser-styles";
2222
import {Card, Nav, Root} from "./base/bootstrap-variables";
23-
import {goto} from "./base/Functions";
2423

2524
test.describe("tabGroup/style/Style.xhtml", () => {
2625

2726
test.beforeEach(async ({page}, testInfo) => {
28-
await goto(test, page, testInfo, "/content/900-test/tabGroup/style/Style.xhtml");
27+
await page.goto("/content/900-test/tabGroup/style/Style.xhtml");
2928
});
3029

3130
test("tc:tabGroup: Tabgroup_Style", async ({page}) => {
@@ -207,7 +206,7 @@ test.describe("tabGroup/style/Style.xhtml", () => {
207206
test.describe("tabGroup/file_immediate/File_immediate.xhtml", () => {
208207

209208
test.beforeEach(async ({page}, testInfo) => {
210-
await goto(test, page, testInfo, "/content/900-test/tabGroup/file_immediate/File_immediate.xhtml");
209+
await page.goto("/content/900-test/tabGroup/file_immediate/File_immediate.xhtml");
211210
});
212211

213212
test("Select tab 'Two', press OK, select tab 'One', press OK", async ({page}) => {

0 commit comments

Comments
 (0)