-
Notifications
You must be signed in to change notification settings - Fork 64
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
[GH-124]: Integrating Playwright for E2E tests #228
Conversation
Hi @mickmister and @larkox, Let me know if you have any concerns. I'd be happy to address. |
This PR is |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
…suresh-git/mattermost-plugin-todo into feat/adding-playwright-e2e
…t-plugin-todo into feat/adding-playwright-e2e
There was a problem hiding this 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
# - name: ci/checkout-mattermost-monorepo | ||
# uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
# with: | ||
# path: ../mattermost | ||
# repository: mattermost/mattermost |
There was a problem hiding this comment.
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
- 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 |
There was a problem hiding this comment.
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
workflow_run: | ||
workflows: ["ci"] | ||
types: | ||
- completed |
There was a problem hiding this comment.
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.
- name: ci/tsc | ||
run: | | ||
cd e2e/playwright | ||
npm run tsc | ||
|
||
# - name: ci/lint | ||
# run: | | ||
# cd e2e/playwright | ||
# npm run lint |
There was a problem hiding this comment.
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:
- 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 |
# - name: ci/lint | ||
# run: | | ||
# cd e2e/playwright | ||
# npm run lint |
There was a problem hiding this comment.
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
#!/bin/sh | ||
cd ../../../ | ||
git clone --depth 1 https://github.com/mattermost/mattermost.git | ||
cd mattermost |
There was a problem hiding this comment.
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
type TodoPluginSettings = { | ||
encryptionkey: string; | ||
webhooksecret: string; | ||
} | ||
|
||
const todoConfig: TodoPluginSettings = { | ||
encryptionkey: 'S9YasItflsENXnrnKUhMJkdosXTsr6Tc', | ||
webhooksecret: 'w7HfrdZ+mtJKnWnsmHMh8eKzWpQH7xET', | ||
}; |
There was a problem hiding this comment.
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
// # 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); | ||
}); |
There was a problem hiding this comment.
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
"eslint-plugin-react": "~7.32.2", | ||
"eslint-plugin-react-hooks": "~4.6.0", |
There was a problem hiding this comment.
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
// 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'}); | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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! |
Thank you for the opportunity! @mickmister :) |
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