Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[playwright] Update documentation #13489

Merged
merged 1 commit into from
Mar 14, 2024
Merged
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
24 changes: 12 additions & 12 deletions examples/playwright/docs/EXTENSIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Commands and menu items are handled by their label, so no further customization
Simply interact with them via the menu or quick commands.

```typescript
const app = await TheiaApp.load(page);
const app = await TheiaAppLoader.load({ playwright, browser });
const menuBar = app.menuBar;

const yourMenu = await menuBar.openMenu("Your Menu");
const yourItem = await mainMenu.menuItemByName("Your Item");
const yourMenu = await menuBar.openMenu('Your Menu');
const yourItem = await mainMenu.menuItemByName('Your Item');

expect(await yourItem?.hasSubmenu()).toBe(true);
```
Expand All @@ -30,14 +30,14 @@ export class MyTheiaApp extends TheiaApp {
}

export class MyToolbar extends TheiaPageObject {
selector = "div#myToolbar";
selector = 'div#myToolbar';
async clickItem1(): Promise<void> {
await this.page.click(`${this.selector} .item1`);
}
}

const ws = new TheiaWorkspace(["src/tests/resources/sample-files1"]);
const app = await MyTheiaApp.loadApp(page, MyTheiaApp, ws);
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
const app = await TheiaAppLoader.load({ playwright, browser }, ws, MyTheiaApp);
await app.toolbar.clickItem1();
```

Expand All @@ -55,9 +55,9 @@ export class MyView extends TheiaView {
constructor(public app: TheiaApp) {
super(
{
tabSelector: "#shell-tab-my-view", // the id of the tab
viewSelector: "#my-view-container", // the id of the view container
viewName: "My View", // the user visible view name
tabSelector: '#shell-tab-my-view', // the id of the tab
viewSelector: '#my-view-container', // the id of the view container
viewName: 'My View', // the user visible view name
},
app
);
Expand All @@ -66,7 +66,7 @@ export class MyView extends TheiaView {
async clickMyButton(): Promise<void> {
await this.activate();
const viewElement = await this.viewElement();
const button = await viewElement?.waitForSelector("#idOfMyButton");
const button = await viewElement?.waitForSelector('#idOfMyButton');
await button?.click();
}
}
Expand All @@ -83,7 +83,7 @@ As an example, `MyView` above introduces a method that allows to click a button.
To use this custom page object in a test, we pass our custom page object as a parameter when opening the view with `app.openView`.

```typescript
const app = await TheiaApp.load(page, ws);
const app = await TheiaAppLoader.load({ playwright, browser });
const myView = await app.openView(MyView);
await myView.clickMyButton();
```
Expand All @@ -94,7 +94,7 @@ As a reference for custom views and editors, please refer to the existing page o
Custom status indicators are supported with the same mechanism. They are accessed via `TheiaApp.statusBar`.

```typescript
const app = await TheiaApp.load(page);
const app = await TheiaAppLoader.load({ playwright, browser });
const problemIndicator = await app.statusBar.statusIndicator(
TheiaProblemIndicator
);
Expand Down
20 changes: 10 additions & 10 deletions examples/playwright/docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,35 @@ Using the `TheiaApp` instance, we open an editor of type `TheiaTextEditor`, whic
At any time, we can also get information from the text editor, such as obtaining dirty state and verify whether this information is what we expect.

```typescript
test("should undo and redo text changes and correctly update the dirty state", async () => {
test('should undo and redo text changes and correctly update the dirty state', async ({ playwright, browser }) => {
// 1. set up workspace contents and open Theia app
const ws = new TheiaWorkspace(["src/tests/resources/sample-files1"]);
const app = await TheiaApp.load(page, ws);
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
app = await TheiaAppLoader.load( { playwright, browser }, ws);

// 2. open Theia text editor
const sampleTextEditor = await app.openEditor(
"sample.txt",
'sample.txt',
TheiaTextEditor
);

// 3. make a change and verify contents and dirty
await sampleTextEditor.replaceLineWithLineNumber("change", 1);
await sampleTextEditor.replaceLineWithLineNumber('change', 1);
expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
"change"
'change'
);
expect(await sampleTextEditor.isDirty()).toBe(true);

// 4. undo and verify contents and dirty state
await sampleTextEditor.undo(2);
expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
"this is just a sample file"
'this is just a sample file'
);
expect(await sampleTextEditor.isDirty()).toBe(false);

// 5. undo and verify contents and dirty state
await sampleTextEditor.redo(2);
expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
"change"
'change'
);
expect(await sampleTextEditor.isDirty()).toBe(true);

Expand All @@ -81,9 +81,9 @@ test("should undo and redo text changes and correctly update the dirty state", a
await sampleTextEditor.close();

// 7. reopen editor and verify dirty state
const reopenedEditor = await app.openEditor("sample.txt", TheiaTextEditor);
const reopenedEditor = await app.openEditor('sample.txt', TheiaTextEditor);
expect(await reopenedEditor.textContentOfLineByLineNumber(1)).toBe(
"change"
'change'
);

await reopenedEditor.close();
Expand Down
Loading