Skip to content

Commit ab9455c

Browse files
committed
fix:e2e test cases
1 parent 53b580b commit ab9455c

File tree

2 files changed

+11
-76
lines changed

2 files changed

+11
-76
lines changed

ui/tests/e2e/json-editor.spec.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ import { test, expect } from '@playwright/test';
22
import { jsonEditorApp } from '../pages/jsoneditorpage';
33

44
test.describe(" Json editor App at entry", () => {
5-
let jsoneditorapp;
5+
let app;
66

77
test('Should Apply all the Json app tests', async ({page}) => {
8-
jsoneditorapp = new jsonEditorApp(page);
9-
await jsoneditorapp.openJsonApp()
10-
await jsoneditorapp.fillJsonApp()
11-
await jsoneditorapp.formatJson()
12-
await jsoneditorapp.compactJson()
13-
await jsoneditorapp.transformJson()
14-
await jsoneditorapp.repairJson()
15-
await jsoneditorapp.undoAction()
16-
await jsoneditorapp.redoAction()
8+
app = new jsonEditorApp(page);
9+
await app.navigateEntryPage()
10+
await app.validateJsonApp()
1711
});
1812

1913
});

ui/tests/pages/jsoneditorpage.ts

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Locator, Page, Frame } from '@playwright/test';
1+
import { Locator, Page, Frame, expect } from '@playwright/test';
22
import { elements } from '../elements/jsoneditor.elements';
33

44
export class jsonEditorApp {
@@ -7,74 +7,15 @@ export class jsonEditorApp {
77
this.page = page;
88
}
99

10-
async openJsonApp() {
10+
async navigateEntryPage() {
1111
await this.page
12-
.goto(`${process.env.ENV_URL}/#!/stack/${process.env.STACK_UID}/content-type/test_json_editor/en-us/entry/create`);
13-
12+
.goto(`${process.env.ENV_URL}/#!/stack/${process.env.STACK_UID}/content-type/test_json_editor/en-us/entry/create`);
1413
}
1514

16-
async fillJsonApp(){
17-
18-
await this.page.frameLocator('[data-testid="app-extension-frame"]').locator('div').filter({ hasText: /^\{\}$/ }).nth(1).click();
19-
20-
await this.page
21-
.frameLocator('[data-testid="app-extension-frame"]')
22-
.getByRole('textbox')
23-
.press('ArrowLeft');
24-
25-
await this.page
26-
.frameLocator(elements.FrameLocator)
27-
.getByRole('textbox')
28-
.fill('date : today');
29-
30-
await this.page
31-
.frameLocator(elements.FrameLocator)
32-
.locator('div')
33-
.filter({ hasText: /^\{date : today\}$/ })
34-
.nth(1)
35-
.click();
36-
}
37-
38-
async formatJson(){
39-
await this.page
40-
.frameLocator(elements.FrameLocator)
41-
.getByRole('button', { name: elements.formatJsonName })
42-
.click();
43-
}
44-
45-
async compactJson(){
46-
await this.page
47-
.frameLocator(elements.FrameLocator)
48-
.getByRole('button', { name: elements.compactJsonName })
49-
.click();
50-
}
51-
52-
async transformJson(){
53-
await this.page
54-
.frameLocator(elements.FrameLocator)
55-
.getByRole('button', { name: elements.transformJsonName})
56-
.click();
57-
}
58-
59-
async repairJson(){
60-
await this.page
61-
.frameLocator(elements.FrameLocator)
62-
.getByRole('button', { name: elements.repairJsonName })
63-
.click();
64-
}
65-
66-
async undoAction(){
67-
await this.page
68-
.frameLocator(elements.FrameLocator)
69-
.getByRole('button', { name: elements.undoJsonAction })
70-
.click();
71-
}
72-
73-
async redoAction(){
74-
await this.page
75-
.frameLocator(elements.FrameLocator)
76-
.getByRole('button', { name: elements.redoJsonAction })
77-
.click();
15+
async validateJsonApp() {
16+
const appFrameLocator = await this.page.frameLocator('[data-testid="app-extension-frame"]')
17+
await appFrameLocator.locator('div').filter({ hasText: /^\{\}$/ }).nth(1).click();
18+
await expect(appFrameLocator.locator('div').filter({ hasText: /^\{\}$/ }).nth(1)).toBeVisible();
7819
}
7920

8021
};

0 commit comments

Comments
 (0)