Created
August 26, 2025 15:09
-
-
Save bbchriscesar/c49fd942c740737556ce4bf7e5f8d06f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
test('A user can copy a post in the feed card', async ({ page }) => { | |
const loginPage = new LoginPage(page); | |
const feedPage = new FeedPage(page); | |
const postText = TestHelpers.generateRandomPostText(); | |
await setupUserSession(loginPage, feedPage); | |
await feedPage.createPost(postText); | |
// Verify post creation | |
await expect(feedPage.sendingPostMessage).toBeVisible(); | |
await expect(feedPage.postSentMessage).toBeVisible(); | |
await page.waitForURL('**/feed'); | |
// Wait for feed to load and find the target card | |
await expect(async () => { | |
const count = await feedPage.feedItemCards.count(); | |
expect(count).toBeGreaterThanOrEqual(3); | |
}).toPass(); | |
const targetFeedCard = feedPage.getFeedCardWithText(postText); | |
await feedPage.scrollIntoView(targetFeedCard); | |
await expect(targetFeedCard).toBeVisible(); | |
// Copy the post link | |
const clipboardContent = await feedPage.copyPostLink(targetFeedCard); | |
// Verify that we got a valid URL from clipboard | |
expect(clipboardContent).toMatch(/^https?:\/\//); | |
// Navigate to the copied link | |
await feedPage.navigateToUrl(clipboardContent); | |
await page.waitForTimeout(5000); | |
// Verify we're on the correct page (should show the post in the modal) | |
await expect(feedPage.feedItemModalContainer).toBeVisible(); | |
const postContentInModal = feedPage.getPostContentInModal(postText); | |
await expect(postContentInModal).toBeVisible(); | |
await feedPage.clickCloseModal(); | |
await page.waitForURL('**/feed'); | |
// Clean up - delete the post | |
await feedPage.deletePost(targetFeedCard); | |
await expect(feedPage.successDeleteMessage).toBeVisible(); | |
await page.waitForURL('**/feed'); | |
// Verify post deletion | |
await expect(feedPage.feedItemCards.first()).toBeVisible(); | |
await expect(targetFeedCard).not.toBeVisible(); | |
}); | |
// Copy actions | |
async copyPostLink(feedCard: Locator): Promise<string> { | |
await this.clickManageMenu(feedCard); | |
await this.clickCopy(); | |
// Wait for copy operation to complete | |
await this.page.waitForTimeout(1000); | |
return await this.page.evaluate(async () => { | |
return await navigator.clipboard.readText(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment