diff --git a/src/mods/redsquare/redsquare_page.ts b/src/mods/redsquare/redsquare_page.ts index edff2a2..afeb886 100644 --- a/src/mods/redsquare/redsquare_page.ts +++ b/src/mods/redsquare/redsquare_page.ts @@ -7,28 +7,25 @@ export default class RedsquarePage extends ModulePage { super(page, "/redsquare"); } - async openChat() { - - } - async createNewTweet() { - const newTweetButton = this.page.locator('#new-tweet'); - await newTweetButton.click() - const tweetTextArea = this.page.locator('#post-tweet-textarea'); - await expect(tweetTextArea).toBeVisible(); + const selectors = { + newTweetButton: '#new-tweet', + tweetTextArea: '#post-tweet-textarea', + postTweetButton: '#post-tweet-button', + tweetTextElement: '.tweet-text' + }; + await this.page.locator(selectors.newTweetButton).click(); + await this.page.locator(selectors.tweetTextArea).waitFor(); const tweetText = "Hello, this is a test tweet!"; - await tweetTextArea.fill(tweetText); + await this.page.locator(selectors.tweetTextArea).fill(tweetText); - const postTweetButton = this.page.locator('#post-tweet-button'); - await postTweetButton.click(); + await this.page.locator(selectors.postTweetButton).click(); + await this.page.locator(`${selectors.tweetTextElement}`, { hasText: tweetText }).waitFor(); - await this.page.waitForTimeout(5000); - - const tweetTextElement = this.page.locator('.tweet-text', { hasText: tweetText }); - - await expect(tweetTextElement).toBeVisible(); + await expect(this.page.locator(`${selectors.tweetTextElement}`)).toBeVisible(); } + } diff --git a/tests/mods/chat.spec.ts b/tests/mods/chat.spec.ts index 7b5ad59..faea6b8 100644 --- a/tests/mods/chat.spec.ts +++ b/tests/mods/chat.spec.ts @@ -13,8 +13,8 @@ test("chat loading in arcade", async ({ page }) => { let chatManager = await page.locator('.chat-manager-list> .saito-user').click(); let chatInput = await page.$(".chat-footer > .saito-input > #text-input"); - expect(chatInput).toBeTruthy(); + expect(chatInput).toBeTruthy(); let testText = "E2E Test"; @@ -33,7 +33,6 @@ test("chat loading in arcade", async ({ page }) => { chatMsg = await page.$(".chat-body > .saito-user:last-child > .saito-userline"); expect(chatMsg).toBeTruthy(); - let text = await chatMsg.innerText(); console.log(text, testText) expect(text.trim()).toEqual(testText.trim()); diff --git a/tests/mods/redsquare.spec.ts b/tests/mods/redsquare.spec.ts index 96f8df3..0b3dcb2 100644 --- a/tests/mods/redsquare.spec.ts +++ b/tests/mods/redsquare.spec.ts @@ -1,10 +1,9 @@ -import { expect, test } from '@playwright/test'; +import { test } from '@playwright/test'; import Redsquare from "../../src/mods/redsquare/redsquare_page"; test("Should load redsquare", async ({ page }) => { let redsquare = new Redsquare(page); await redsquare.goto(); - // await arcade.createChessGame(); }); test("Should create new tweets", async ({ page }) => {