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

[GH-124]: Integrating Playwright for E2E tests #228

Conversation

rahulsuresh-git
Copy link
Contributor

@rahulsuresh-git rahulsuresh-git commented Nov 1, 2023

Summary

This PR introduces E2E testing for the Todo plugin using Playwright. It largely borrows from the implementation in the GitHub plugin https://github.com/mattermost/mattermost-plugin-github/blob/master/.github/workflows/playwright.yml. There are changes made to support the latest monorepo changes.

The tests themselves assert that the correct slash command suggestions are shown when you type /todo into the post text box.

Original PR
#231

Ticket Link

Fixes #124

@mickmister mickmister self-requested a review November 6, 2023 03:51
@rahulsuresh-git rahulsuresh-git marked this pull request as ready for review November 9, 2023 19:53
@rahulsuresh-git
Copy link
Contributor Author

rahulsuresh-git commented Nov 9, 2023

Hi @mickmister and @larkox,
I've verified that the changes work by running a simple test that triggers the slash container popup when someone types /todo.

Here are the results:
image

Let me know if you have any concerns. I'd be happy to address.

@rahulsuresh-git
Copy link
Contributor Author

This PR is ready for review.

@codecov-commenter
Copy link

codecov-commenter commented Nov 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8b25f12) 6.42% compared to head (e6af7c0) 6.42%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master    #228   +/-   ##
======================================
  Coverage    6.42%   6.42%           
======================================
  Files          11      11           
  Lines        1712    1712           
======================================
  Hits          110     110           
  Misses       1594    1594           
  Partials        8       8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rahulsuresh-git rahulsuresh-git mentioned this pull request Nov 14, 2023
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Nov 16, 2023
Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this awesome contribution @rahulsuresh-git!!

LGTM 👍 Just some non-blocking suggestions and comments

Comment on lines +132 to +136
# - name: ci/checkout-mattermost-monorepo
# uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
# with:
# path: ../mattermost
# repository: mattermost/mattermost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this block

Comment on lines +108 to +113
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: ".nvmrc"
# cache: "npm"
# cache-dependency-path: webapp/package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an issue to address dependency caching #233

Comment on lines -3 to -6
workflow_run:
workflows: ["ci"]
types:
- completed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers that one of the main reasons this was written this way before was so PRs coming from forks could use the OAuth token secrets for e2e testing. We're going to try to avoid the need to use real tokens going forward, by having a test harness around external services, that the e2e test can act as and make assertions.

Comment on lines +168 to +176
- name: ci/tsc
run: |
cd e2e/playwright
npm run tsc

# - name: ci/lint
# run: |
# cd e2e/playwright
# npm run lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all of the other steps are descriptive:

Suggested change
- name: ci/tsc
run: |
cd e2e/playwright
npm run tsc
# - name: ci/lint
# run: |
# cd e2e/playwright
# npm run lint
- name: ci/tsc-plugin-playwright
run: |
cd e2e/playwright
npm run tsc
# - name: ci/lint-plugin-playwright
# run: |
# cd e2e/playwright
# npm run lint

Comment on lines +173 to +176
# - name: ci/lint
# run: |
# cd e2e/playwright
# npm run lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a ticket to address this in a separate PR #232

We were receiving linting errors in the e2e code:

The task here is to fix the linting errors here:
https://github.com/rahulsuresh-git/mattermost-plugin-todo/actions/runs/6897786793/job/18766591926

/home/runner/work/mattermost-plugin-todo/mattermost-plugin-todo/e2e/playwright/playwright.config.ts
  4:1  error  Parsing error: The keyword 'import' is reserved

Comment on lines +1 to +4
#!/bin/sh
cd ../../../
git clone --depth 1 https://github.com/mattermost/mattermost.git
cd mattermost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers that this script is only to help set up the development environment, and is not used for CI. See this directory's README for more info

Comment on lines +69 to +77
type TodoPluginSettings = {
encryptionkey: string;
webhooksecret: string;
}

const todoConfig: TodoPluginSettings = {
encryptionkey: 'S9YasItflsENXnrnKUhMJkdosXTsr6Tc',
webhooksecret: 'w7HfrdZ+mtJKnWnsmHMh8eKzWpQH7xET',
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The todo plugin does not have these settings. For the purpose of the test, we are not using plugin settings, so we can leave the settings blank for now, or comment it out so we know how to add them for later

Comment on lines +60 to +67
// # Clear bot DM channel
test.beforeEach(async ({pw}) => {
const {adminClient, adminUser} = await pw.getAdminClient();
if (adminUser === null) {
throw new Error('can not get adminUser');
}
await cleanUpBotDMs(adminClient, adminUser.id, botUsername);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this requires that tests must be run in serial. This allows every test to have a clean slate on the bot DM channel, with the same user logged in for each test

Comment on lines +22 to +23
"eslint-plugin-react": "~7.32.2",
"eslint-plugin-react-hooks": "~4.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove these too eslint plugins since we're not doing anything with React in this e2e test package

Comment on lines +6 to +9
// TODO: migrate this helpers to webapp's ChannelsPost after monorepo migration
export const getBotTagFromPost = (post: ChannelsPost) => {
return post.container.locator('.post__header').locator('.BotTag', {hasText: 'BOT'});
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just remove the todo comment. We will address this already when we extract the common code

Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left my review at #236 (review). I think we can merge this PR and address the remaining concerns as part of #236.

@mickmister mickmister merged commit 65296b8 into mattermost-community:master Nov 17, 2023
5 checks passed
@mickmister
Copy link
Contributor

Awesome work on this @rahulsuresh-git!! It's incredible the effort you put into this and the result has already had a big impact on our team's direction on testing the plugin projects.

We had a past effort to introduce e2e tests to our plugin projects, though it was generally de-prioritized and left as a work-in-progress. Your efforts here to take that on and ensure a working framework has sparked momentum in our team to achieve better test confidence on each of the projects. Great work creating a solid foundation to build on top of 🚀 Thanks @rahulsuresh-git!

@rahulsuresh-git
Copy link
Contributor Author

Thank you for the opportunity! @mickmister :)

@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate E2E testing
5 participants