Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- --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",
Expand Down
12 changes: 8 additions & 4 deletions e2e/playwright/tests/test.list.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// 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 if plugin is setup correctly
test.describe("setup", core.setup);

// Test various plugin actions
test.describe("actions", core.actions);
122 changes: 91 additions & 31 deletions e2e/playwright/tests/todo_plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,97 @@
// - [*] 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";

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);
await page.goto(dmURL, { waitUntil: "load" });
});

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 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 }) => {
const c = new pages.ChannelsPage(page);

// # 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]`);

// * 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 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 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");
});

test("add action", async ({ pages, page, pw }) => {
const c = new pages.ChannelsPage(page);
const slash = new SlashCommandSuggestions(
page.locator("#suggestionList")
);
const todoMessage = "Don't forget to be awesome";

// # Run command to add todo
await c.postMessage(`/todo add ${todoMessage}`);

// # Grab the last post
const post = await c.getLastPost();
const postBody = post.container.locator(".post-message__text-container");

// * Assert post body has correct title
await expect(postBody).toContainText("Added Todo. Todo List:");

// * Assert added todo is visible
await expect(postBody).toContainText(todoMessage);
});
},
};