From 861f546af6b609dcf7f649f9ec3b47f1f2a3b196 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 13:14:54 -0600 Subject: [PATCH 01/16] did some cleanup in existing code --- e2e/playwright/package.json | 1 + e2e/playwright/tests/test.list.ts | 8 +-- e2e/playwright/tests/todo_plugin.spec.ts | 62 ++++++++++++------------ 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/e2e/playwright/package.json b/e2e/playwright/package.json index 18aac110..d9b3fdd5 100644 --- a/e2e/playwright/package.json +++ b/e2e/playwright/package.json @@ -2,6 +2,7 @@ "name": "plugin-e2e-tests", "scripts": { "test": "PW_SLOMO=200 npm run test --prefix ../../../mattermost/e2e-tests/playwright -- --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts'", + "test-ui": "PW_SLOMO=200 npm run test --prefix ../../../mattermost/e2e-tests/playwright -- --ui --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts'", "test-ci": "PW_HEADLESS=true npm test", "test-slomo": "npm run test-slomo --prefix ../../../mattermost/e2e-tests/playwright -- --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts", "debug": "npm test -- --debug", diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index 732baaf3..9b9d3f38 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -1,9 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {test} from '@playwright/test'; -import core from './todo_plugin.spec'; +import { test } from "@playwright/test"; +import core from "./todo_plugin.spec"; -import '../support/init_test'; +import "../support/init_test"; -test.describe(core.connected); +test.describe("setup", core.setup); diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 745e6bb6..01f55346 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -6,37 +6,37 @@ // - [*] indicates an assertion (e.g. * Check the title) // *************************************************************** -import {expect, test} from '@e2e-support/test_fixture'; -import SlashCommandSuggestions from 'support/components/slash_commands'; -import {fillMessage, getTodoBotDMPageURL} from 'support/utils'; +import { expect, test } from "@e2e-support/test_fixture"; +import SlashCommandSuggestions from "support/components/slash_commands"; +import { fillMessage, getTodoBotDMPageURL } from "support/utils"; export default { - connected: () => { - test.describe('available commands', () => { - test('with just the main command', async ({pages, page, pw}) => { - - const {adminClient, adminUser} = await pw.getAdminClient(); - if (adminUser === null) { - throw new Error('can not get adminUser'); - } - const dmURL = await getTodoBotDMPageURL(adminClient, '', adminUser.id); - await page.goto(dmURL, {waitUntil: 'load'}); - - const c = new pages.ChannelsPage(page); - const slash = new SlashCommandSuggestions(page.locator('#suggestionList')); - - // # Run incomplete command to trigger help - await fillMessage('/todo', page); - - // * Assert suggestions are visible - await expect(slash.container).toBeVisible(); - - // * Assert help is visible - await expect(slash.getItemTitleNth(0)).toHaveText('todo [command]'); - - await expect(slash.getItemDescNth(0)).toHaveText('Available commands: list, add, pop, send, settings, help'); - }); - }); - }, + setup: () => { + test("checking available commands", async ({ pages, page, pw }) => { + const { adminClient, adminUser } = await pw.getAdminClient(); + if (adminUser === null) { + throw new Error("can not get adminUser"); + } + const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); + await page.goto(dmURL, { waitUntil: "load" }); + + const c = new pages.ChannelsPage(page); + const slash = new SlashCommandSuggestions( + page.locator("#suggestionList") + ); + + // # Run incomplete command to trigger help + await fillMessage("/todo", page); + + // * Assert suggestions are visible + await expect(slash.container).toBeVisible(); + + // * Assert help is visible + await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); + + await expect(slash.getItemDescNth(0)).toHaveText( + "Available commands: list, add, pop, send, settings, help" + ); + }); + }, }; - From b88c7d02acd28991c01d896850579dd6b045b1cc Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 14:49:09 -0600 Subject: [PATCH 02/16] wrote test for help command --- e2e/playwright/package.json | 2 +- e2e/playwright/tests/test.list.ts | 4 + e2e/playwright/tests/todo_plugin.spec.ts | 95 +++++++++++++++++++----- 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/e2e/playwright/package.json b/e2e/playwright/package.json index d9b3fdd5..133a4525 100644 --- a/e2e/playwright/package.json +++ b/e2e/playwright/package.json @@ -2,7 +2,7 @@ "name": "plugin-e2e-tests", "scripts": { "test": "PW_SLOMO=200 npm run test --prefix ../../../mattermost/e2e-tests/playwright -- --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts'", - "test-ui": "PW_SLOMO=200 npm run test --prefix ../../../mattermost/e2e-tests/playwright -- --ui --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts'", + "test-ui": "PW_SLOMO=200 npm run test --prefix ../../../mattermost/e2e-tests/playwright -- --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts' --ui", "test-ci": "PW_HEADLESS=true npm test", "test-slomo": "npm run test-slomo --prefix ../../../mattermost/e2e-tests/playwright -- --project=chrome --config='../../../mattermost-plugin-todo/e2e/playwright/playwright.config.ts", "debug": "npm test -- --debug", diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index 9b9d3f38..b3925947 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -6,4 +6,8 @@ import core from "./todo_plugin.spec"; import "../support/init_test"; +// Test if plugin is setup correctly test.describe("setup", core.setup); + +// Test various plugin actions +test.describe("actions", core.actions); diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 01f55346..dc7126e4 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -7,36 +7,95 @@ // *************************************************************** import { expect, test } from "@e2e-support/test_fixture"; +import Client4 from "@mattermost/client/client4"; +import { UserProfile } from "@mattermost/types/users"; import SlashCommandSuggestions from "support/components/slash_commands"; import { fillMessage, getTodoBotDMPageURL } from "support/utils"; +let adminClient: Client4, adminUser: UserProfile | null; + +test.beforeEach(async ({ page, pw }) => { + const data = await pw.getAdminClient(); + adminClient = data.adminClient; + adminUser = data.adminUser; + if (adminUser === null) { + throw new Error("can not get adminUser"); + } + const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); + await page.goto(dmURL, { waitUntil: "load" }); +}); + export default { setup: () => { test("checking available commands", async ({ pages, page, pw }) => { - const { adminClient, adminUser } = await pw.getAdminClient(); - if (adminUser === null) { - throw new Error("can not get adminUser"); + if (adminUser) { + const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); + await page.goto(dmURL, { waitUntil: "load" }); + const c = new pages.ChannelsPage(page); + const slash = new SlashCommandSuggestions( + page.locator("#suggestionList") + ); + + // # Run command to trigger todo + await fillMessage("/todo", page); + + // * Assert suggestions are visible + await expect(slash.container).toBeVisible(); + + // * Assert todo [command] is visible + await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); + + await expect(slash.getItemDescNth(0)).toHaveText( + "Available commands: list, add, pop, send, settings, help" + ); } - const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); - await page.goto(dmURL, { waitUntil: "load" }); + }); + }, + actions: () => { + test("help action", async ({ pages, page, pw }) => { + if (adminUser) { + const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); + await page.goto(dmURL, { waitUntil: "load" }); + const c = new pages.ChannelsPage(page); + const slash = new SlashCommandSuggestions( + page.locator("#suggestionList") + ); + + // # Run command to trigger help + await c.postMessage("/todo help"); + + // # Grab the last post + const post = await c.getLastPost(); + const postBody = post.container.locator( + ".post-message__text-container" + ); + + // * Assert /todo add [message] command is visible + await expect(postBody).toContainText(`add [message]`); - const c = new pages.ChannelsPage(page); - const slash = new SlashCommandSuggestions( - page.locator("#suggestionList") - ); + // * Assert /todo list command is visible + await expect(postBody).toContainText("list"); - // # Run incomplete command to trigger help - await fillMessage("/todo", page); + // * Assert /todo list [listName] command is visible + await expect(postBody).toContainText("list [listName]"); - // * Assert suggestions are visible - await expect(slash.container).toBeVisible(); + // * Assert /todo pop command is visible + await expect(postBody).toContainText("pop"); - // * Assert help is visible - await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); + // * Assert /todo send [user] [message] command is visible + await expect(postBody).toContainText("send [user] [message]"); - await expect(slash.getItemDescNth(0)).toHaveText( - "Available commands: list, add, pop, send, settings, help" - ); + // * Assert /todo settings summary [on, off] command is visible + await expect(postBody).toContainText("settings summary [on, off]"); + + // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible + await expect(postBody).toContainText( + "settings allow_incoming_task_requests [on, off]" + ); + + // * Assert /todo help command is visible + await expect(postBody).toContainText("help"); + } }); }, }; From 72396b4ca9fb760eb4065031bbb2feaf37df5963 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 16:19:18 -0600 Subject: [PATCH 03/16] code cleanup --- e2e/playwright/tests/todo_plugin.spec.ts | 106 ++++++++++------------- 1 file changed, 45 insertions(+), 61 deletions(-) diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index dc7126e4..ba7a419f 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -7,17 +7,11 @@ // *************************************************************** import { expect, test } from "@e2e-support/test_fixture"; -import Client4 from "@mattermost/client/client4"; -import { UserProfile } from "@mattermost/types/users"; import SlashCommandSuggestions from "support/components/slash_commands"; import { fillMessage, getTodoBotDMPageURL } from "support/utils"; -let adminClient: Client4, adminUser: UserProfile | null; - test.beforeEach(async ({ page, pw }) => { - const data = await pw.getAdminClient(); - adminClient = data.adminClient; - adminUser = data.adminUser; + const { adminClient, adminUser } = await pw.getAdminClient(); if (adminUser === null) { throw new Error("can not get adminUser"); } @@ -28,74 +22,64 @@ test.beforeEach(async ({ page, pw }) => { export default { setup: () => { test("checking available commands", async ({ pages, page, pw }) => { - if (adminUser) { - const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); - await page.goto(dmURL, { waitUntil: "load" }); - const c = new pages.ChannelsPage(page); - const slash = new SlashCommandSuggestions( - page.locator("#suggestionList") - ); - - // # Run command to trigger todo - await fillMessage("/todo", page); - - // * Assert suggestions are visible - await expect(slash.container).toBeVisible(); - - // * Assert todo [command] is visible - await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); - - await expect(slash.getItemDescNth(0)).toHaveText( - "Available commands: list, add, pop, send, settings, help" - ); - } + const c = new pages.ChannelsPage(page); + const slash = new SlashCommandSuggestions( + page.locator("#suggestionList") + ); + + // # Run command to trigger todo + await fillMessage("/todo", page); + + // * Assert suggestions are visible + await expect(slash.container).toBeVisible(); + + // * Assert todo [command] is visible + await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); + + await expect(slash.getItemDescNth(0)).toHaveText( + "Available commands: list, add, pop, send, settings, help" + ); }); }, actions: () => { test("help action", async ({ pages, page, pw }) => { - if (adminUser) { - const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); - await page.goto(dmURL, { waitUntil: "load" }); - const c = new pages.ChannelsPage(page); - const slash = new SlashCommandSuggestions( - page.locator("#suggestionList") - ); + const c = new pages.ChannelsPage(page); + const slash = new SlashCommandSuggestions( + page.locator("#suggestionList") + ); - // # Run command to trigger help - await c.postMessage("/todo help"); + // # Run command to trigger help + await c.postMessage("/todo help"); - // # Grab the last post - const post = await c.getLastPost(); - const postBody = post.container.locator( - ".post-message__text-container" - ); + // # Grab the last post + const post = await c.getLastPost(); + const postBody = post.container.locator(".post-message__text-container"); - // * Assert /todo add [message] command is visible - await expect(postBody).toContainText(`add [message]`); + // * Assert /todo add [message] command is visible + await expect(postBody).toContainText(`add [message]`); - // * Assert /todo list command is visible - await expect(postBody).toContainText("list"); + // * Assert /todo list command is visible + await expect(postBody).toContainText("list"); - // * Assert /todo list [listName] command is visible - await expect(postBody).toContainText("list [listName]"); + // * Assert /todo list [listName] command is visible + await expect(postBody).toContainText("list [listName]"); - // * Assert /todo pop command is visible - await expect(postBody).toContainText("pop"); + // * Assert /todo pop command is visible + await expect(postBody).toContainText("pop"); - // * Assert /todo send [user] [message] command is visible - await expect(postBody).toContainText("send [user] [message]"); + // * Assert /todo send [user] [message] command is visible + await expect(postBody).toContainText("send [user] [message]"); - // * Assert /todo settings summary [on, off] command is visible - await expect(postBody).toContainText("settings summary [on, off]"); + // * Assert /todo settings summary [on, off] command is visible + await expect(postBody).toContainText("settings summary [on, off]"); - // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible - await expect(postBody).toContainText( - "settings allow_incoming_task_requests [on, off]" - ); + // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible + await expect(postBody).toContainText( + "settings allow_incoming_task_requests [on, off]" + ); - // * Assert /todo help command is visible - await expect(postBody).toContainText("help"); - } + // * Assert /todo help command is visible + await expect(postBody).toContainText("help"); }); }, }; From 201c38ac4f1dd8fe6c63793a619bbdc69a64817d Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 16:23:56 -0600 Subject: [PATCH 04/16] removed unused code --- e2e/playwright/tests/todo_plugin.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index ba7a419f..eefa13b2 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -22,7 +22,6 @@ test.beforeEach(async ({ page, pw }) => { export default { setup: () => { test("checking available commands", async ({ pages, page, pw }) => { - const c = new pages.ChannelsPage(page); const slash = new SlashCommandSuggestions( page.locator("#suggestionList") ); @@ -44,9 +43,6 @@ export default { actions: () => { test("help action", async ({ pages, page, pw }) => { const c = new pages.ChannelsPage(page); - const slash = new SlashCommandSuggestions( - page.locator("#suggestionList") - ); // # Run command to trigger help await c.postMessage("/todo help"); From 0f78845a305d8d4570c18555843429d2fad846c9 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 19:50:31 -0600 Subject: [PATCH 05/16] fixed tsc errors and added helper function in support utils --- e2e/playwright/support/utils.ts | 76 +++++++++++++++--------- e2e/playwright/tests/todo_plugin.spec.ts | 13 ++-- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index b13ce154..7e707688 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -1,60 +1,78 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {Page} from '@playwright/test'; +import type { Page } from "@playwright/test"; -import {UserProfile} from '@mattermost/types/users'; -import Client4 from '@mattermost/client/client4'; +import Client4 from "@mattermost/client/client4"; +import { UserProfile } from "@mattermost/types/users"; export const waitForNewMessages = async (page: Page) => { - await page.waitForTimeout(1000); + await page.waitForTimeout(1000); - // This should be able to be waited based on locators instead of pure time-based - // The following code work "almost" always. Commented for now to have green tests. - // await page.locator('#postListContent').getByTestId('NotificationSeparator').getByText('New Messages').waitFor(); + // This should be able to be waited based on locators instead of pure time-based + // The following code work "almost" always. Commented for now to have green tests. + // await page.locator('#postListContent').getByTestId('NotificationSeparator').getByText('New Messages').waitFor(); }; -export const getTodoBotDMPageURL = async (client: Client4, teamName: string, userId: string) => { - let team = teamName; - if (team === '') { - const teams = await client.getTeamsForUser(userId); - team = teams[0].name; - } - return `${team}/messages/@todo`; +export const getTodoBotDMPageURL = async ( + client: Client4, + teamName: string, + userId: string +) => { + let team = teamName; + if (team === "") { + const teams = await client.getTeamsForUser(userId); + team = teams[0].name; + } + return `${team}/messages/@todo`; }; -export const fillTextField = async (name: string, value: string, page: Page) => { - await page.getByTestId(`${name}`).fill(value); +export const fillTextField = async ( + name: string, + value: string, + page: Page +) => { + await page.getByTestId(`${name}`).fill(value); }; export const submitDialog = async (page: Page) => { - await page.click('#interactiveDialogSubmit'); + await page.click("#interactiveDialogSubmit"); }; export const fillMessage = async (message: string, page: Page) => { - await fillTextField('post_textbox', message, page ) + await fillTextField("post_textbox", message, page); }; export const postMessage = async (message: string, page: Page) => { - await fillMessage(message, page) - await page.getByTestId('SendMessageButton').click(); + await fillMessage(message, page); + await page.getByTestId("SendMessageButton").click(); }; -export const cleanUpBotDMs = async (client: Client4, userId: UserProfile['id'], botUsername: string) => { - const bot = await client.getUserByUsername(botUsername); +export const cleanUpBotDMs = async ( + client: Client4, + userId: UserProfile["id"], + botUsername: string +) => { + const bot = await client.getUserByUsername(botUsername); - const userIds = [userId, bot.id]; - const channel = await client.createDirectChannel(userIds); - const posts = await client.getPosts(channel.id); + const userIds = [userId, bot.id]; + const channel = await client.createDirectChannel(userIds); + const posts = await client.getPosts(channel.id); - const deletePostPromises = Object.keys(posts.posts).map(client.deletePost); - await Promise.all(deletePostPromises); + const deletePostPromises = Object.keys(posts.posts).map(client.deletePost); + await Promise.all(deletePostPromises); }; export const getSlackAttachmentLocatorId = (postId: string) => { - return `#post_${postId} .attachment__body`; + return `#post_${postId} .attachment__body`; }; export const getPostMessageLocatorId = (postId: string) => { - return `#post_${postId} .post-message`; + return `#post_${postId} .post-message`; +}; + +export const getLastPost = async (page: Page) => { + const lastPost = page.getByTestId("postView").last(); + await lastPost.waitFor(); + return lastPost; }; diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index eefa13b2..64834b46 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -8,7 +8,12 @@ import { expect, test } from "@e2e-support/test_fixture"; import SlashCommandSuggestions from "support/components/slash_commands"; -import { fillMessage, getTodoBotDMPageURL } from "support/utils"; +import { + fillMessage, + getLastPost, + getTodoBotDMPageURL, + postMessage, +} from "support/utils"; test.beforeEach(async ({ page, pw }) => { const { adminClient, adminUser } = await pw.getAdminClient(); @@ -45,11 +50,11 @@ export default { const c = new pages.ChannelsPage(page); // # Run command to trigger help - await c.postMessage("/todo help"); + postMessage("/todo help", page); // # Grab the last post - const post = await c.getLastPost(); - const postBody = post.container.locator(".post-message__text-container"); + const post = await getLastPost(page); + const postBody = post.locator(".post-message__text-container"); // * Assert /todo add [message] command is visible await expect(postBody).toContainText(`add [message]`); From 4d5aa7055ae479d85a2c9ac18350624c712af621 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sun, 3 Dec 2023 20:12:05 -0600 Subject: [PATCH 06/16] reverted prettier changes --- e2e/playwright/support/utils.ts | 4 ++-- e2e/playwright/tests/test.list.ts | 2 +- e2e/playwright/tests/todo_plugin.spec.ts | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index 7e707688..f5aeb2a3 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -1,10 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type { Page } from "@playwright/test"; +import type {Page} from "@playwright/test"; import Client4 from "@mattermost/client/client4"; -import { UserProfile } from "@mattermost/types/users"; +import {UserProfile} from "@mattermost/types/users"; export const waitForNewMessages = async (page: Page) => { await page.waitForTimeout(1000); diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index b3925947..e245f86d 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import { test } from "@playwright/test"; +import {test} from "@playwright/test"; import core from "./todo_plugin.spec"; import "../support/init_test"; diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 64834b46..9e726a46 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -6,13 +6,13 @@ // - [*] indicates an assertion (e.g. * Check the title) // *************************************************************** -import { expect, test } from "@e2e-support/test_fixture"; +import {expect, test} from "@e2e-support/test_fixture"; import SlashCommandSuggestions from "support/components/slash_commands"; import { - fillMessage, - getLastPost, - getTodoBotDMPageURL, - postMessage, + fillMessage, + getLastPost, + getTodoBotDMPageURL, + postMessage, } from "support/utils"; test.beforeEach(async ({ page, pw }) => { From dedc5efd29392dbd3a96ed676c92e68a764ecab2 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Mon, 4 Dec 2023 17:40:35 -0600 Subject: [PATCH 07/16] prettier changes reverted --- e2e/playwright/support/utils.ts | 71 ++++++++++-------------- e2e/playwright/tests/test.list.ts | 6 +- e2e/playwright/tests/todo_plugin.spec.ts | 54 ++++++++---------- 3 files changed, 56 insertions(+), 75 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index f5aeb2a3..ae929391 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -1,74 +1,63 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {Page} from "@playwright/test"; +import type {Page} from '@playwright/test'; + +import Client4 from '@mattermost/client/client4'; +import {UserProfile} from '@mattermost/types/users'; -import Client4 from "@mattermost/client/client4"; -import {UserProfile} from "@mattermost/types/users"; export const waitForNewMessages = async (page: Page) => { - await page.waitForTimeout(1000); + await page.waitForTimeout(1000); - // This should be able to be waited based on locators instead of pure time-based - // The following code work "almost" always. Commented for now to have green tests. - // await page.locator('#postListContent').getByTestId('NotificationSeparator').getByText('New Messages').waitFor(); + // This should be able to be waited based on locators instead of pure time-based + // The following code work "almost" always. Commented for now to have green tests. + // await page.locator('#postListContent').getByTestId('NotificationSeparator').getByText('New Messages').waitFor(); }; -export const getTodoBotDMPageURL = async ( - client: Client4, - teamName: string, - userId: string -) => { - let team = teamName; - if (team === "") { - const teams = await client.getTeamsForUser(userId); - team = teams[0].name; - } - return `${team}/messages/@todo`; +export const getTodoBotDMPageURL = async (client: Client4, teamName: string, userId: string) => { + let team = teamName; + if (team === '') { + const teams = await client.getTeamsForUser(userId); + team = teams[0].name; + } + return `${team}/messages/@todo`; }; -export const fillTextField = async ( - name: string, - value: string, - page: Page -) => { - await page.getByTestId(`${name}`).fill(value); +export const fillTextField = async (name: string, value: string, page: Page) => { + await page.getByTestId(`${name}`).fill(value); }; export const submitDialog = async (page: Page) => { - await page.click("#interactiveDialogSubmit"); + await page.click('#interactiveDialogSubmit'); }; export const fillMessage = async (message: string, page: Page) => { - await fillTextField("post_textbox", message, page); + await fillTextField('post_textbox', message, page ) }; export const postMessage = async (message: string, page: Page) => { - await fillMessage(message, page); - await page.getByTestId("SendMessageButton").click(); + await fillMessage(message, page) + await page.getByTestId('SendMessageButton').click(); }; -export const cleanUpBotDMs = async ( - client: Client4, - userId: UserProfile["id"], - botUsername: string -) => { - const bot = await client.getUserByUsername(botUsername); +export const cleanUpBotDMs = async (client: Client4, userId: UserProfile['id'], botUsername: string) => { + const bot = await client.getUserByUsername(botUsername); - const userIds = [userId, bot.id]; - const channel = await client.createDirectChannel(userIds); - const posts = await client.getPosts(channel.id); + const userIds = [userId, bot.id]; + const channel = await client.createDirectChannel(userIds); + const posts = await client.getPosts(channel.id); - const deletePostPromises = Object.keys(posts.posts).map(client.deletePost); - await Promise.all(deletePostPromises); + const deletePostPromises = Object.keys(posts.posts).map(client.deletePost); + await Promise.all(deletePostPromises); }; export const getSlackAttachmentLocatorId = (postId: string) => { - return `#post_${postId} .attachment__body`; + return `#post_${postId} .attachment__body`; }; export const getPostMessageLocatorId = (postId: string) => { - return `#post_${postId} .post-message`; + return `#post_${postId} .post-message`; }; export const getLastPost = async (page: Page) => { diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index e245f86d..ae2f53a5 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -1,10 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {test} from "@playwright/test"; -import core from "./todo_plugin.spec"; +import {test} from '@playwright/test'; +import core from './todo_plugin.spec'; -import "../support/init_test"; +import '../support/init_test'; // Test if plugin is setup correctly test.describe("setup", core.setup); diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 9e726a46..9358dedd 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -6,81 +6,73 @@ // - [*] indicates an assertion (e.g. * Check the title) // *************************************************************** -import {expect, test} from "@e2e-support/test_fixture"; -import SlashCommandSuggestions from "support/components/slash_commands"; -import { - fillMessage, - getLastPost, - getTodoBotDMPageURL, - postMessage, -} from "support/utils"; +import {expect, test} from '@e2e-support/test_fixture'; +import SlashCommandSuggestions from 'support/components/slash_commands'; +import {fillMessage, getLastPost, getTodoBotDMPageURL, postMessage, } from 'support/utils'; test.beforeEach(async ({ page, pw }) => { - const { adminClient, adminUser } = await pw.getAdminClient(); + const {adminClient, adminUser} = await pw.getAdminClient(); if (adminUser === null) { - throw new Error("can not get adminUser"); + throw new Error('can not get adminUser'); } - const dmURL = await getTodoBotDMPageURL(adminClient, "", adminUser.id); - await page.goto(dmURL, { waitUntil: "load" }); + const dmURL = await getTodoBotDMPageURL(adminClient, '', adminUser.id); + await page.goto(dmURL, {waitUntil: 'load'}); }); export default { setup: () => { - test("checking available commands", async ({ pages, page, pw }) => { - const slash = new SlashCommandSuggestions( - page.locator("#suggestionList") - ); + test('checking available commands', async ({ page }) => { + const slash = new SlashCommandSuggestions(page.locator('#suggestionList')); // # Run command to trigger todo - await fillMessage("/todo", page); + await fillMessage('/todo', page); // * Assert suggestions are visible await expect(slash.container).toBeVisible(); // * Assert todo [command] is visible - await expect(slash.getItemTitleNth(0)).toHaveText("todo [command]"); + await expect(slash.getItemTitleNth(0)).toHaveText('todo [command]'); - await expect(slash.getItemDescNth(0)).toHaveText( - "Available commands: list, add, pop, send, settings, help" - ); + await expect(slash.getItemDescNth(0)).toHaveText('Available commands: list, add, pop, send, settings, help'); }); }, actions: () => { - test("help action", async ({ pages, page, pw }) => { + test('help action', async ({ pages, page, pw }) => { const c = new pages.ChannelsPage(page); // # Run command to trigger help - postMessage("/todo help", page); + postMessage('/todo help', page); // # Grab the last post const post = await getLastPost(page); - const postBody = post.locator(".post-message__text-container"); + const postBody = post.locator('.post-message__text-container'); // * Assert /todo add [message] command is visible await expect(postBody).toContainText(`add [message]`); // * Assert /todo list command is visible - await expect(postBody).toContainText("list"); + await expect(postBody).toContainText('list'); // * Assert /todo list [listName] command is visible - await expect(postBody).toContainText("list [listName]"); + await expect(postBody).toContainText('list [listName]'); // * Assert /todo pop command is visible - await expect(postBody).toContainText("pop"); + await expect(postBody).toContainText('pop'); // * Assert /todo send [user] [message] command is visible - await expect(postBody).toContainText("send [user] [message]"); + await expect(postBody).toContainText('send [user] [message]'); // * Assert /todo settings summary [on, off] command is visible - await expect(postBody).toContainText("settings summary [on, off]"); + await expect(postBody).toContainText('settings summary [on, off]'); // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible await expect(postBody).toContainText( - "settings allow_incoming_task_requests [on, off]" + 'settings allow_incoming_task_requests [on, off]' ); // * Assert /todo help command is visible - await expect(postBody).toContainText("help"); + await expect(postBody).toContainText('help'); }); }, }; + From 985cba83a70987b3a1edbf808d7f0421378b2289 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Mon, 4 Dec 2023 17:42:02 -0600 Subject: [PATCH 08/16] addressed PR comments --- e2e/playwright/tests/todo_plugin.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 9358dedd..d8c29d86 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -36,8 +36,8 @@ export default { await expect(slash.getItemDescNth(0)).toHaveText('Available commands: list, add, pop, send, settings, help'); }); }, - actions: () => { - test('help action', async ({ pages, page, pw }) => { + commands: () => { + test('help', async ({ pages, page, pw }) => { const c = new pages.ChannelsPage(page); // # Run command to trigger help @@ -48,7 +48,7 @@ export default { const postBody = post.locator('.post-message__text-container'); // * Assert /todo add [message] command is visible - await expect(postBody).toContainText(`add [message]`); + await expect(postBody).toContainText('add [message]'); // * Assert /todo list command is visible await expect(postBody).toContainText('list'); From 49d90b9b8e864809a9381a6f421eb51c1a869d51 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Mon, 4 Dec 2023 17:42:37 -0600 Subject: [PATCH 09/16] removed extra line --- e2e/playwright/support/utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index ae929391..65bc7b1c 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -6,7 +6,6 @@ import type {Page} from '@playwright/test'; import Client4 from '@mattermost/client/client4'; import {UserProfile} from '@mattermost/types/users'; - export const waitForNewMessages = async (page: Page) => { await page.waitForTimeout(1000); From 37abad14a15f8bfb60196d4b403625744c360a49 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Mon, 4 Dec 2023 18:17:43 -0600 Subject: [PATCH 10/16] fixed issue with incorrect import --- e2e/playwright/tests/test.list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index ae2f53a5..78b2abe0 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -10,4 +10,4 @@ import '../support/init_test'; test.describe("setup", core.setup); // Test various plugin actions -test.describe("actions", core.actions); +test.describe("actions", core.commands); From 7b53add8294a447ca3bc34b465bd7567016ed338 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Fri, 8 Dec 2023 10:56:54 -0600 Subject: [PATCH 11/16] fixing test names and invocation methods --- e2e/playwright/tests/test.list.ts | 6 +++--- e2e/playwright/tests/todo_plugin.spec.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index 78b2abe0..dca2dc64 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -2,12 +2,12 @@ // See LICENSE.txt for license information. import {test} from '@playwright/test'; -import core from './todo_plugin.spec'; +import commands from './todo_plugin.spec'; import '../support/init_test'; // Test if plugin is setup correctly -test.describe("setup", core.setup); +test.describe("setup", commands.setup); // Test various plugin actions -test.describe("actions", core.commands); +test.describe("testing help command", commands.help); diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index d8c29d86..36625a04 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -10,7 +10,7 @@ import {expect, test} from '@e2e-support/test_fixture'; import SlashCommandSuggestions from 'support/components/slash_commands'; import {fillMessage, getLastPost, getTodoBotDMPageURL, postMessage, } from 'support/utils'; -test.beforeEach(async ({ page, pw }) => { +test.beforeEach(async ({page, pw}) => { const {adminClient, adminUser} = await pw.getAdminClient(); if (adminUser === null) { throw new Error('can not get adminUser'); @@ -21,7 +21,7 @@ test.beforeEach(async ({ page, pw }) => { export default { setup: () => { - test('checking available commands', async ({ page }) => { + test('checking available commands', async ({page}) => { const slash = new SlashCommandSuggestions(page.locator('#suggestionList')); // # Run command to trigger todo @@ -36,8 +36,9 @@ export default { await expect(slash.getItemDescNth(0)).toHaveText('Available commands: list, add, pop, send, settings, help'); }); }, - commands: () => { - test('help', async ({ pages, page, pw }) => { + + help: () => { + test('help', async ({pages, page, pw}) => { const c = new pages.ChannelsPage(page); // # Run command to trigger help @@ -73,6 +74,6 @@ export default { // * Assert /todo help command is visible await expect(postBody).toContainText('help'); }); - }, + } }; From b07e0cd05a4809eb7b4713023591bf505e31b8aa Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Fri, 8 Dec 2023 15:43:36 -0600 Subject: [PATCH 12/16] refactored code to get DM URL and teamName --- e2e/playwright/support/utils.ts | 23 ++++++++++++----------- e2e/playwright/tests/todo_plugin.spec.ts | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index 65bc7b1c..0725ffba 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -14,13 +14,14 @@ export const waitForNewMessages = async (page: Page) => { // await page.locator('#postListContent').getByTestId('NotificationSeparator').getByText('New Messages').waitFor(); }; -export const getTodoBotDMPageURL = async (client: Client4, teamName: string, userId: string) => { - let team = teamName; - if (team === '') { - const teams = await client.getTeamsForUser(userId); - team = teams[0].name; - } - return `${team}/messages/@todo`; +export const getTeamName = async (client: Client4, userId: string) => { + const teams = await client.getTeamsForUser(userId); + const team = teams[0].name; + return team; +}; + +export const getBotDMPageURL = async (client: Client4, userId: string, teamName: string, botUsername: string) => { + return `${teamName}/messages/${botUsername}`; }; export const fillTextField = async (name: string, value: string, page: Page) => { @@ -32,7 +33,7 @@ export const submitDialog = async (page: Page) => { }; export const fillMessage = async (message: string, page: Page) => { - await fillTextField('post_textbox', message, page ) + await fillTextField('post_textbox', message, page) }; export const postMessage = async (message: string, page: Page) => { @@ -60,7 +61,7 @@ export const getPostMessageLocatorId = (postId: string) => { }; export const getLastPost = async (page: Page) => { - const lastPost = page.getByTestId("postView").last(); - await lastPost.waitFor(); - return lastPost; + const lastPost = page.getByTestId("postView").last(); + await lastPost.waitFor(); + return lastPost; }; diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 36625a04..dba785e7 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -8,14 +8,27 @@ import {expect, test} from '@e2e-support/test_fixture'; import SlashCommandSuggestions from 'support/components/slash_commands'; -import {fillMessage, getLastPost, getTodoBotDMPageURL, postMessage, } from 'support/utils'; +import {fillMessage, getBotDMPageURL, getLastPost, getTeamName, postMessage, } from 'support/utils'; + +const botUserName = 'todo'; +let teamName = ''; + +test.beforeAll(async ({pw}) => { + const {adminClient, adminUser} = await pw.getAdminClient(); + if (adminUser === null) { + throw new Error('can not get adminUser'); + } + if (teamName === '') { + teamName = await getTeamName(adminClient, adminUser.id) + } +}); test.beforeEach(async ({page, pw}) => { const {adminClient, adminUser} = await pw.getAdminClient(); if (adminUser === null) { throw new Error('can not get adminUser'); } - const dmURL = await getTodoBotDMPageURL(adminClient, '', adminUser.id); + const dmURL = await getBotDMPageURL(adminClient, adminUser.id, teamName, botUserName); await page.goto(dmURL, {waitUntil: 'load'}); }); From b0c2d52f9a1697bb850a9020fa016b48d6d980ec Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Fri, 8 Dec 2023 15:49:31 -0600 Subject: [PATCH 13/16] refactored getLastPost method --- e2e/playwright/support/utils.ts | 3 ++- e2e/playwright/tests/todo_plugin.spec.ts | 19 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index 0725ffba..d895e529 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -63,5 +63,6 @@ export const getPostMessageLocatorId = (postId: string) => { export const getLastPost = async (page: Page) => { const lastPost = page.getByTestId("postView").last(); await lastPost.waitFor(); - return lastPost; + const postBody = lastPost.locator('.post-message__text-container'); + return postBody; }; diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index dba785e7..b4509d75 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -58,34 +58,33 @@ export default { postMessage('/todo help', page); // # Grab the last post - const post = await getLastPost(page); - const postBody = post.locator('.post-message__text-container'); + const lastPost = await getLastPost(page); // * Assert /todo add [message] command is visible - await expect(postBody).toContainText('add [message]'); + await expect(lastPost).toContainText('add [message]'); // * Assert /todo list command is visible - await expect(postBody).toContainText('list'); + await expect(lastPost).toContainText('list'); // * Assert /todo list [listName] command is visible - await expect(postBody).toContainText('list [listName]'); + await expect(lastPost).toContainText('list [listName]'); // * Assert /todo pop command is visible - await expect(postBody).toContainText('pop'); + await expect(lastPost).toContainText('pop'); // * Assert /todo send [user] [message] command is visible - await expect(postBody).toContainText('send [user] [message]'); + await expect(lastPost).toContainText('send [user] [message]'); // * Assert /todo settings summary [on, off] command is visible - await expect(postBody).toContainText('settings summary [on, off]'); + await expect(lastPost).toContainText('settings summary [on, off]'); // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible - await expect(postBody).toContainText( + await expect(lastPost).toContainText( 'settings allow_incoming_task_requests [on, off]' ); // * Assert /todo help command is visible - await expect(postBody).toContainText('help'); + await expect(lastPost).toContainText('help'); }); } }; From 9680eff26b7c95611ef11d552cc6d580468be569 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Fri, 8 Dec 2023 16:05:13 -0600 Subject: [PATCH 14/16] refactored comments and test names --- e2e/playwright/tests/test.list.ts | 6 ++--- e2e/playwright/tests/todo_plugin.spec.ts | 32 ++++++++---------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/e2e/playwright/tests/test.list.ts b/e2e/playwright/tests/test.list.ts index dca2dc64..82fecacd 100644 --- a/e2e/playwright/tests/test.list.ts +++ b/e2e/playwright/tests/test.list.ts @@ -6,8 +6,8 @@ import commands from './todo_plugin.spec'; import '../support/init_test'; -// Test if plugin is setup correctly -test.describe("setup", commands.setup); +// Test if plugin shows the correct suggestions +test.describe("testing todo command", commands.todo); -// Test various plugin actions +// Test if plugin actions work correctly test.describe("testing help command", commands.help); diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index b4509d75..e836930e 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -33,12 +33,14 @@ test.beforeEach(async ({page, pw}) => { }); export default { - setup: () => { - test('checking available commands', async ({page}) => { + todo: () => { + const command = "/todo"; + + test(`${command}`, async ({page}) => { const slash = new SlashCommandSuggestions(page.locator('#suggestionList')); - // # Run command to trigger todo - await fillMessage('/todo', page); + // # Type command to show suggestions + await fillMessage(command, page); // * Assert suggestions are visible await expect(slash.container).toBeVisible(); @@ -51,39 +53,27 @@ export default { }, help: () => { - test('help', async ({pages, page, pw}) => { + const command = "/todo help"; + + test(`${command}`, async ({pages, page, pw}) => { const c = new pages.ChannelsPage(page); // # Run command to trigger help - postMessage('/todo help', page); + postMessage(command, page); // # Grab the last post const lastPost = await getLastPost(page); - // * Assert /todo add [message] command is visible + // * Assert all commands are shown in the help text output await expect(lastPost).toContainText('add [message]'); - - // * Assert /todo list command is visible await expect(lastPost).toContainText('list'); - - // * Assert /todo list [listName] command is visible await expect(lastPost).toContainText('list [listName]'); - - // * Assert /todo pop command is visible await expect(lastPost).toContainText('pop'); - - // * Assert /todo send [user] [message] command is visible await expect(lastPost).toContainText('send [user] [message]'); - - // * Assert /todo settings summary [on, off] command is visible await expect(lastPost).toContainText('settings summary [on, off]'); - - // * Assert /todo settings allow_incoming_task_requests [on, off] command is visible await expect(lastPost).toContainText( 'settings allow_incoming_task_requests [on, off]' ); - - // * Assert /todo help command is visible await expect(lastPost).toContainText('help'); }); } From 93e0490db569d4e3dd288d389351712199457cd2 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sat, 9 Dec 2023 07:43:13 -0600 Subject: [PATCH 15/16] fixed getBotDMPageURL arguments --- e2e/playwright/support/utils.ts | 2 +- e2e/playwright/tests/todo_plugin.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/playwright/support/utils.ts b/e2e/playwright/support/utils.ts index d895e529..74c2afd6 100644 --- a/e2e/playwright/support/utils.ts +++ b/e2e/playwright/support/utils.ts @@ -20,7 +20,7 @@ export const getTeamName = async (client: Client4, userId: string) => { return team; }; -export const getBotDMPageURL = async (client: Client4, userId: string, teamName: string, botUsername: string) => { +export const getBotDMPageURL = async (teamName: string, botUsername: string) => { return `${teamName}/messages/${botUsername}`; }; diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index e836930e..3ce4f607 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -28,7 +28,7 @@ test.beforeEach(async ({page, pw}) => { if (adminUser === null) { throw new Error('can not get adminUser'); } - const dmURL = await getBotDMPageURL(adminClient, adminUser.id, teamName, botUserName); + const dmURL = await getBotDMPageURL(teamName, botUserName); await page.goto(dmURL, {waitUntil: 'load'}); }); From 18e5802839e5fc0d4c8da03e26282f0f174d5cb1 Mon Sep 17 00:00:00 2001 From: Rahul Suresh Date: Sat, 9 Dec 2023 07:46:39 -0600 Subject: [PATCH 16/16] cleaned up before test functions: --- e2e/playwright/tests/todo_plugin.spec.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/e2e/playwright/tests/todo_plugin.spec.ts b/e2e/playwright/tests/todo_plugin.spec.ts index 3ce4f607..27923628 100644 --- a/e2e/playwright/tests/todo_plugin.spec.ts +++ b/e2e/playwright/tests/todo_plugin.spec.ts @@ -23,11 +23,7 @@ test.beforeAll(async ({pw}) => { } }); -test.beforeEach(async ({page, pw}) => { - const {adminClient, adminUser} = await pw.getAdminClient(); - if (adminUser === null) { - throw new Error('can not get adminUser'); - } +test.beforeEach(async ({page}) => { const dmURL = await getBotDMPageURL(teamName, botUserName); await page.goto(dmURL, {waitUntil: 'load'}); });