Skip to content

Commit 786ec9d

Browse files
committed
test: Create note and type
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent 03d9f80 commit 786ec9d

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

playwright/e2e/basic.spec.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
import { expect, test } from '@playwright/test'
2-
import { login } from '../support/login'
1+
import { expect, test } from "@playwright/test";
2+
import { login } from "../support/login";
3+
import { NoteEditor } from "../support/sections/NoteEditor";
34

4-
test.describe('Basic checks', () => {
5-
test.beforeEach(async ({ page }) => {
6-
await login(page)
7-
})
5+
test.describe("Basic checks", () => {
6+
test.beforeEach(async ({ page }) => {
7+
await login(page);
8+
});
89

9-
test('Notes app is visible', async ({ page }) => {
10-
await page.goto('/index.php/apps/notes/')
11-
await expect(page).toHaveTitle(/Notes/)
12-
})
13-
})
10+
test("Notes app is visible", async ({ page }) => {
11+
await page.goto("/index.php/apps/notes/");
12+
await expect(page).toHaveTitle(/Notes/);
13+
});
14+
15+
test("Create note and type", async ({ page }) => {
16+
await page.goto("/index.php/apps/notes/");
17+
await page
18+
.locator("#app-navigation-vue")
19+
.getByRole("button", { name: "New note" })
20+
.click();
21+
const editor = new NoteEditor(page);
22+
await editor.type("Hello from Playwright");
23+
await expect(editor.content).toContainText("Hello from Playwright");
24+
});
25+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Locator, Page } from "@playwright/test";
2+
3+
export class NoteEditor {
4+
public readonly el: Locator;
5+
public readonly content: Locator;
6+
7+
constructor(public readonly page: Page) {
8+
this.el = this.page.locator(".editor").first();
9+
this.content = this.el.getByRole("textbox");
10+
}
11+
12+
public async type(keys: string): Promise<void> {
13+
await this.content.pressSequentially(keys);
14+
}
15+
}

0 commit comments

Comments
 (0)