Skip to content

Commit

Permalink
test sending a message
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall007 committed May 14, 2024
1 parent 14b4574 commit 38c9c68
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tests/mattermost-smoketest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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",
Expand All @@ -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");

});

0 comments on commit 38c9c68

Please sign in to comment.