From 38c9c68292aab969f51821091bfdc8de3edb0b43 Mon Sep 17 00:00:00 2001 From: Marshall Cottrell Date: Tue, 14 May 2024 13:32:39 -0400 Subject: [PATCH] test sending a message --- tests/mattermost-smoketest.spec.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/mattermost-smoketest.spec.ts b/tests/mattermost-smoketest.spec.ts index 22be325a..6e78c032 100644 --- a/tests/mattermost-smoketest.spec.ts +++ b/tests/mattermost-smoketest.spec.ts @@ -9,34 +9,35 @@ export const currentDateTime = () => { }; async function loginToMattermost(page: Page) { - await page.goto("https://chat.uds.dev/"); - await page.goto("https://chat.uds.dev/landing#/"); + await page.goto("https://chat.uds.dev/login"); await page.getByRole("link", { name: "View in Browser" }).click(); await page.getByRole("link", { name: "Gitlab Icon GitLab" }).click(); - await page.getByLabel("Username or email").click(); await page.getByLabel("Username or email").fill("doug"); - await page.getByLabel("Password").click(); await page.getByLabel("Password").fill("unicorn123!@#"); await page.getByRole("button", { name: "Log In" }).click(); - await page.waitForURL( - /\/preparing-workspace|\/unicorns\/channels\/town-square/, - ); } async function setupWorkspace(page: Page) { - await page.getByPlaceholder("Organization name").click(); await page.getByPlaceholder("Organization name").fill("Unicorns"); await page.getByTestId("continue").click(); await page.getByRole("button", { name: "Skip" }).click(); await page.getByRole("button", { name: "Finish setup" }).click(); await page.waitForURL(/\/unicorns\/channels\/town-square/); await page.locator("button").filter({ hasText: "7" }).click(); + const button = page.locator('role=button[name="Not now"]'); if (await button.isVisible()) { await button.click(); } } +async function sendMessage(page: Page) { + const messageBox = page.getByRole('textbox', { name: 'Write to Town Square' }); + await messageBox.fill('Hello world!'); + await messageBox.press('Enter'); + await expect(page.locator('#post-list .post-message__text').last()).toContainText('Hello world!'); +} + test("test mattermost login, init and message", async ({ page, context }) => { await loginToMattermost(page); @@ -48,11 +49,10 @@ test("test mattermost login, init and message", async ({ page, context }) => { await page.waitForURL(/\/unicorns\/channels\/town-square/); } - expect( - page.getByLabel("set status").locator("div").filter({ hasText: "@doug" }), - ).toBeTruthy(); expect(page.url()).toContain("/unicorns/channels/town-square"); + await sendMessage(page); + const cookies = await context.cookies(); const keycloakCookie = cookies.find( (cookie) => cookie.name === "KEYCLOAK_SESSION", @@ -61,5 +61,4 @@ test("test mattermost login, init and message", async ({ page, context }) => { expect(keycloakCookie).toBeDefined(); expect(keycloakCookie?.value).not.toBe(""); expect(keycloakCookie?.domain).toContain("sso.uds.dev"); - });