-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b42707b
commit e18aae7
Showing
40 changed files
with
358 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { TextField } from "../inputs/TextField"; | ||
import { TextField } from "../components"; | ||
import { textfieldStory } from "./utils/url-helper"; | ||
|
||
test.describe("textArea Class with Storybook", () => { | ||
let textField; | ||
let textfieldLocator; | ||
let textFieldLocator; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto(textfieldStory); | ||
const frame = page.frameLocator("[id='storybook-preview-iframe']"); | ||
textfieldLocator = frame.locator('[data-testid="text-field_input"]'); | ||
textField = new TextField(page, textfieldLocator, "Test text field"); | ||
textFieldLocator = frame.locator('[data-testid="text-field_input"]'); | ||
textField = new TextField(page, textFieldLocator, "Test text field"); | ||
}); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
test("set text in text field", async ({ page }) => { | ||
test("set text in text field", async () => { | ||
await textField.setText("Test Text"); | ||
await textField.exitEditMode(); | ||
// eslint-disable-next-line playwright/missing-playwright-await | ||
expect(textField.locator).toHaveValue("Test Text"); | ||
await expect(textField.locator).toHaveValue("Test Text"); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
5 changes: 2 additions & 3 deletions
5
packages/testkit/buttons/Button.ts → packages/testkit/components/Button.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/testkit/inputs/Checkbox.ts → packages/testkit/components/Checkbox.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/testkit/pickers/ColorPicker.ts → packages/testkit/components/ColorPicker.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Locator, Page } from "@playwright/test"; | ||
import { BaseElement } from "./BaseElement"; | ||
import { Search } from "./Search"; | ||
import { ListItem } from "./ListItem"; | ||
|
||
export class Combobox extends BaseElement { | ||
private searchInput: Search; | ||
/** | ||
* Create a Combobox. | ||
* @param {Page} page - The Playwright page object. | ||
* @param {Locator} locator - The locator for the Combobox element. | ||
* @param {string} elementReportName - The name for reporting purposes. | ||
*/ | ||
constructor(page: Page, locator: Locator, elementReportName: string) { | ||
super(page, locator, elementReportName); | ||
this.searchInput = new Search(page, this.locator.locator("[role='search']"), `${elementReportName} Search Input`); | ||
} | ||
|
||
/** | ||
* Select an item from the combobox. | ||
* @param {string} item - The name of the item to select. | ||
* @returns {Promise<void>} | ||
*/ | ||
async selectItem(item: string): Promise<void> { | ||
await this.searchInput.setText(item); | ||
const comboBoxItem = new ListItem( | ||
this.page, | ||
this.locator.locator(`[role='listbox']:has-text("${item}")`), | ||
`Select Combobox Item: ${item}` | ||
); | ||
await comboBoxItem.click(); | ||
} | ||
} |
13 changes: 9 additions & 4 deletions
13
packages/testkit/popover/Dialog.ts → packages/testkit/components/Dialog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/testkit/inputs/Dropdown.ts → packages/testkit/components/Dropdown.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/testkit/navigation/List.ts → packages/testkit/components/List.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/testkit/navigation/ListItem.ts → packages/testkit/components/ListItem.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { test, Page, Locator } from "@playwright/test"; | ||
import { MenuItem } from "./MenuItem"; | ||
import { BaseElement } from "./BaseElement"; | ||
|
||
/** | ||
* Class representing a List element. | ||
* Extends the BaseElement class. | ||
*/ | ||
export class Menu extends BaseElement { | ||
private items: MenuItem[]; | ||
private itemsInitialized: boolean; | ||
|
||
/** | ||
* Create a Menu. | ||
* @param {Page} page - The Playwright page object. | ||
* @param {Locator} locator - The locator for the List element. | ||
* @param {string} elementReportName - The name for reporting purposes. | ||
*/ | ||
constructor(page: Page, locator: Locator, elementReportName: string) { | ||
super(page, locator, elementReportName); | ||
this.items = []; | ||
this.itemsInitialized = false; | ||
} | ||
|
||
/** | ||
* Initialize list items if they are not already initialized. | ||
* @returns {Promise<void>} | ||
*/ | ||
async initializeItemsIfNeeded(): Promise<void> { | ||
await test.step(`Initialize ${this.elementReportName} if needed`, async () => { | ||
if (!this.itemsInitialized) { | ||
await this.initializeItems(); | ||
this.itemsInitialized = true; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Initialize the list items by locating all list elements. | ||
* @returns {Promise<void>} | ||
*/ | ||
async initializeItems(): Promise<void> { | ||
await test.step(`Initialize ${this.elementReportName}`, async () => { | ||
await this.waitForElementsGroup(this.locator.locator("[role='menuitem']"), this.elementReportName); | ||
const listElements = await this.locator.locator("[role='menuitem']").all(); | ||
this.items = await Promise.all( | ||
listElements.map(async locator => { | ||
const itemName = await locator.innerText(); | ||
return new MenuItem(this.page, locator, `Menu Item: ${itemName}`); | ||
}) | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* Get a menu item by its name. | ||
* @param {string} itemName - The name of the item to retrieve. | ||
* @returns {ListItem | undefined} The list item with the specified name or undefined if not found. | ||
*/ | ||
getItemByName(itemName: string): MenuItem | undefined { | ||
return this.items.find(item => item.elementReportName.includes(itemName)); | ||
} | ||
|
||
/** | ||
* Select a menu item. | ||
* @param {string} listItem - The name of the item to select. | ||
* @returns {Promise<void>} | ||
*/ | ||
async selectItem(listItem: string): Promise<void> { | ||
await this.initializeItemsIfNeeded(); | ||
let menuItem = this.getItemByName(listItem); | ||
if (!menuItem) { | ||
// If the item is not in the initialized list, create it dynamically | ||
menuItem = new MenuItem(this.page, this.locator.getByText(`${listItem}`), `Menu Item: ${listItem}`); | ||
} | ||
await menuItem.scrollIntoView(); | ||
await menuItem.click(); | ||
} | ||
} |
Oops, something went wrong.