-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(test): add test for emoji picker (#162)
- Loading branch information
Showing
7 changed files
with
310 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,4 @@ $RECYCLE.BIN/ | |
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
/downloads/ |
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,40 @@ | ||
import MainPage from "../MainPage"; | ||
import { type Locator, type Page } from "@playwright/test"; | ||
|
||
export class CombinedSelector extends MainPage { | ||
readonly combinedSelector: Locator; | ||
readonly emojiContainer: Locator; | ||
readonly footerTabs: Locator; | ||
readonly footerTabsEmojiButton: Locator; | ||
readonly footerTabsGifButton: Locator; | ||
readonly footerTabsStickerButton: Locator; | ||
readonly giphySelector: Locator; | ||
readonly stickerSelector: Locator; | ||
|
||
constructor(public readonly page: Page) { | ||
super(page); | ||
this.combinedSelector = this.page.getByTestId("combined-selector"); | ||
this.emojiContainer = this.page.getByTestId("emoji-container"); | ||
this.footerTabs = this.page.getByTestId(".pill-tabs"); | ||
this.footerTabsEmojiButton = this.page.getByTestId("button-Emojis"); | ||
this.footerTabsGifButton = this.page.getByTestId("button-GIFs"); | ||
this.footerTabsStickerButton = this.page.getByTestId("button-Stickers"); | ||
this.giphySelector = this.page.getByTestId("giphy-selector"); | ||
this.stickerSelector = this.page.getByTestId("sticker-selector"); | ||
} | ||
|
||
async goToEmojisTab() { | ||
await this.footerTabsEmojiButton.click(); | ||
await this.emojiContainer.waitFor({ state: "visible" }); | ||
} | ||
|
||
async goToGifsTab() { | ||
await this.footerTabsGifButton.click(); | ||
await this.giphySelector.waitFor({ state: "visible" }); | ||
} | ||
|
||
async goToStickersTab() { | ||
await this.footerTabsStickerButton.click(); | ||
await this.stickerSelector.waitFor({ state: "visible" }); | ||
} | ||
} |
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,124 @@ | ||
import { CombinedSelector } from "./CombinedSelector"; | ||
import { type Locator, type Page, expect } from "@playwright/test"; | ||
|
||
export class EmojiPicker extends CombinedSelector { | ||
readonly categoryNav: Locator; | ||
readonly categoryNavLink: Locator; | ||
readonly emojiSection: Locator; | ||
readonly emojiSectionEmojis: Locator; | ||
readonly emojiSectionLabel: Locator; | ||
readonly emojiSectionList: Locator; | ||
readonly emojiContainerSearchInput: Locator; | ||
readonly emojiContainerSizeLabel: Locator; | ||
readonly emojiContainerSizeRangeSelector: Locator; | ||
readonly emojiContainerSizeRangeSelectorInput: Locator; | ||
readonly emojiContainerSizeSection: Locator; | ||
readonly emojiSelector: Locator; | ||
readonly frequentlyUsedSection: Locator; | ||
readonly skinToneSelector: Locator; | ||
readonly skinToneSelectorButton: Locator; | ||
|
||
constructor(public readonly page: Page) { | ||
super(page); | ||
this.categoryNav = this.page.getByTestId("emoji-category-nav"); | ||
this.emojiContainerSearchInput = this.page.getByTestId( | ||
"emoji-container-search-input", | ||
); | ||
this.emojiContainerSizeLabel = this.page.getByTestId( | ||
"emoji-container-size-label", | ||
); | ||
this.emojiContainerSizeRangeSelector = this.page | ||
.getByTestId("emoji-container-size-section") | ||
.getByTestId("range-selector"); | ||
this.emojiContainerSizeRangeSelectorInput = this.page | ||
.getByTestId("emoji-container-size-section") | ||
.getByTestId("range-selector") | ||
.getByTestId("range-selector-input"); | ||
this.emojiContainerSizeSection = this.page.getByTestId( | ||
"emoji-container-size-section", | ||
); | ||
this.emojiSelector = this.page.getByTestId("emoji-selector"); | ||
this.frequentlyUsedSection = this.page.getByTestId( | ||
"frequently-used-section", | ||
); | ||
this.skinToneSelector = this.page.getByTestId("skin-tone-selector"); | ||
this.skinToneSelectorButton = this.page.getByTestId( | ||
"skin-tone-selector-button", | ||
); | ||
} | ||
|
||
async changeSkinToneEmoji(index: number) { | ||
await this.skinToneSelector.click(); | ||
await this.page.locator(".skin-tone-popup").waitFor({ state: "visible" }); | ||
const skinToneButton = this.page | ||
.getByTestId("skin-tone-selector-button") | ||
.nth(index); | ||
await skinToneButton.click(); | ||
await this.page.locator(".skin-tone-popup").waitFor({ state: "detached" }); | ||
} | ||
|
||
async changeEmojiSizeView(size: string) { | ||
await this.emojiContainerSizeRangeSelectorInput.fill(size); | ||
} | ||
|
||
async navigateThroughEmojiCategories(category: string) { | ||
const locator = this.page.getByTestId("category-link-" + category); | ||
await locator.click(); | ||
const section = this.page.getByTestId(category + "-section"); | ||
await section.waitFor({ state: "visible" }); | ||
} | ||
|
||
async searchEmoji(emoji: string) { | ||
await this.emojiContainerSearchInput.fill(emoji); | ||
} | ||
|
||
async selectEmoji(emoji: string) { | ||
await this.page | ||
.getByTestId("emoji-container") | ||
.locator("span") | ||
.filter({ | ||
hasText: emoji, | ||
}) | ||
.click(); | ||
} | ||
|
||
async validateEmojiCategories(expectedCategories: string[]) { | ||
// Define an array to store section names | ||
const sectionNames = []; | ||
|
||
// Select all section elements (assuming they have a data-cy attribute ending with '-section') | ||
const sections = await this.page.$$(`section[data-cy$="-section"]`); | ||
|
||
// Loop through each section and find its corresponding label | ||
for (const section of sections) { | ||
// Find the label within the current section that ends with '-label' | ||
const label = await section.$(`label[data-cy$="-label"]`); | ||
if (label) { | ||
const sectionName = await label.textContent(); | ||
sectionNames.push(sectionName.trim()); | ||
} | ||
} | ||
expect(sectionNames).toEqual(expectedCategories); | ||
} | ||
|
||
async validateNumberOfEmojisPerSection( | ||
section: string, | ||
expectedNumber: number, | ||
) { | ||
const emojisCount = await this.page | ||
.getByTestId(section + "-section") | ||
.locator("span") | ||
.count(); | ||
expect(emojisCount).toEqual(expectedNumber); | ||
} | ||
|
||
async validateSingleEmojiSize(emoji: string, expectedSize: string) { | ||
const emojiLocator = this.page | ||
.getByTestId("emoji-container") | ||
.locator("span") | ||
.filter({ | ||
hasText: emoji, | ||
}); | ||
await expect(emojiLocator).toHaveCSS("font-size", expectedSize); | ||
} | ||
} |
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,11 @@ | ||
import MainPage from "../MainPage"; | ||
import { type Locator, type Page } from "@playwright/test"; | ||
|
||
export class GifPicker extends MainPage { | ||
readonly combinedSelector: Locator; | ||
|
||
constructor(public readonly page: Page) { | ||
super(page); | ||
this.combinedSelector = this.page.getByTestId("combined-selector"); | ||
} | ||
} |
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,11 @@ | ||
import MainPage from "../MainPage"; | ||
import { type Locator, type Page } from "@playwright/test"; | ||
|
||
export class StickerPicker extends MainPage { | ||
readonly combinedSelector: Locator; | ||
|
||
constructor(public readonly page: Page) { | ||
super(page); | ||
this.combinedSelector = this.page.getByTestId("combined-selector"); | ||
} | ||
} |
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
Oops, something went wrong.