Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e, playwright): added e2e test for /todo help command #238

Closed
Show file tree
Hide file tree
Changes from 4 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";
rahulsuresh-git marked this conversation as resolved.
Show resolved Hide resolved

test.describe(core.connected);
// Test if plugin is setup correctly
test.describe("setup", core.setup);

// Test various plugin actions
test.describe("actions", core.actions);
101 changes: 70 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,76 @@
// - [*] 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 }) => {
rahulsuresh-git marked this conversation as resolved.
Show resolved Hide resolved
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
rahulsuresh-git marked this conversation as resolved.
Show resolved Hide resolved
await expect(postBody).toContainText(`add [message]`);
rahulsuresh-git marked this conversation as resolved.
Show resolved Hide resolved

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