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

Playwright suite on CI + me/todo/autocomplete specs #666

Merged
merged 119 commits into from
May 2, 2023
Merged

Conversation

trilopin
Copy link
Contributor

@trilopin trilopin commented Apr 5, 2023

Summary

Key points:

  • Ordered execution
  • Videos recorded always
  • Screenshots are taken when there are failures (instead of always)
  • Shared auth state, login just once (through UI)
  • Rate limit bypassed (3 searches per entire suite consumed)
  • eslint added for playwright folder, extends webapp eslintrc.json and override some rules
  • tests are done against mattermost-enterprise image at master

Still 1/5 on the way tests are structured (unconnected/connected/nosetup map). A record would be nice in the future.

Ticket Link

Fixes https://mattermost.atlassian.net/browse/MM-51379
Fixes https://mattermost.atlassian.net/browse/MM-51368

@trilopin trilopin added 2: Dev Review Requires review by a core committer and removed Work In Progress Not yet ready for review labels Apr 24, 2023
@trilopin trilopin requested a review from srkgupta April 24, 2023 19:00

import type {Page} from '@playwright/test';

import {ChannelsPage} from '@e2e-support/ui/pages';
import {UserProfile} from '@mattermost/types/users';
import Client4 from '@mattermost/client/client4';

const SCREENSHOTS_DIR = path.join(__dirname, '../screenshots');
export const waitForNewMessages = async (page: Page) => {
await page.waitForTimeout(1000);
Copy link
Contributor Author

@trilopin trilopin Apr 24, 2023

Choose a reason for hiding this comment

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

the smart wait for New-messages does not work (yet) in CI for some tests.

I'll research more, but I see some value in having green e2e until then.

@@ -0,0 +1,18 @@
{
"extends": [
"../../webapp/.eslintrc.json"
Copy link
Contributor Author

@trilopin trilopin Apr 24, 2023

Choose a reason for hiding this comment

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

I tried to extend from mattermost-server/e2e-tests/.eslintrc.json but has no rules at all, and missed most of the points I wanted to cover. That's why I extended from plugin/webapp/.eslintrc.json

"plugins": ["import"],
"parser": "@typescript-eslint/parser",
"rules": {
"import/no-unresolved": "off",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this shouldn't be here but fails with custom imports mapped in tsconfig.json

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this cause other issues with linting? e.g. something that has to do with the type that was imported. This may be caught by the typescript compiler instead, though CI is not running checks with tsc in the e2e folder

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a problem only in CI? If so, I think we'll need to clone the webapp repo during linting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added tsc to CI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tsc/lint are done after cloning webapp repo in setup-environment. It happened on CI and locally

@trilopin trilopin changed the title WIP Playwright specs Playwright suite on CI + me/todo/autocomplete specs Apr 25, 2023
@trilopin
Copy link
Contributor Author

trilopin commented Apr 26, 2023

@mickmister I'd want to finish and merge this before I go through your create-issue PR. The main reason is that I've changed the structure a lot. I'd be willing to adapt your PR after merging this one if you want.

build/setup.mk Outdated
# Ensure that go is installed. Note that this is independent of whether or not a server is being
# built, since the build script itself uses go.
ifeq ($(GO),)
$(error "go is not available: see https://golang.org/doc/install")
endif

# Ensure that the build tools are compiled. Go's caching makes this quick.
$(shell cd build/manifest && $(GO) build -o ../bin/manifest)
$(shell cd build/manifest && $(GO) build -buildvcs=false $(GO_BUILD_FLAGS) -o ../bin/manifest)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mickmister, this comes from your changes, is it needed? what's the goal?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was originally to have the workflow runner be able to build the plugin in a docker container. This can be removed as that's not how we're running the tests.

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.

LGTM 🎉

@@ -78,6 +78,7 @@ jobs:
MM_SERVICESETTINGS_SITEURL: http://localhost:8065
MM_PLUGINSETTINGS_AUTOMATICPREPACKAGEDPLUGINS: false
MM_ANNOUNCEMENTSETTINGS_ADMINNOTICESENABLED: false
MM_SERVICESETTINGS_ENABLEONBOARDINGFLOW: false
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 moving this logic here could make the test fail on a local machine I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was already handled in patchConfig, removed from here

.gitignore Outdated Show resolved Hide resolved
"plugins": ["import"],
"parser": "@typescript-eslint/parser",
"rules": {
"import/no-unresolved": "off",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a problem only in CI? If so, I think we'll need to clone the webapp repo during linting

build/setup.mk Outdated
# Ensure that go is installed. Note that this is independent of whether or not a server is being
# built, since the build script itself uses go.
ifeq ($(GO),)
$(error "go is not available: see https://golang.org/doc/install")
endif

# Ensure that the build tools are compiled. Go's caching makes this quick.
$(shell cd build/manifest && $(GO) build -o ../bin/manifest)
$(shell cd build/manifest && $(GO) build -buildvcs=false $(GO_BUILD_FLAGS) -o ../bin/manifest)
Copy link
Contributor

Choose a reason for hiding this comment

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

This was originally to have the workflow runner be able to build the plugin in a docker container. This can be removed as that's not how we're running the tests.

@@ -24,5 +27,6 @@ const app = makeOAuthServer({

const port = process.env.OAUTH_SERVER_PORT || 8080;
app.listen(port, () => {
// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just get rid of this file. It's used to stand up the oauth server separate from the tests, but it's not ever used like that

Comment on lines 39 to 40
// * Assert suggestions are visible
await slash.toBeVisible();
Copy link
Contributor

Choose a reason for hiding this comment

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

This reads weird without expect being on the same line

trilopin and others added 2 commits April 28, 2023 09:39
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
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.

LGTM 🎉


export default {
connected: () => {
test.describe('/github me', () => {
Copy link
Contributor

@srkgupta srkgupta May 2, 2023

Choose a reason for hiding this comment

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

Is this test dependent on any other test to be able to complete the pre-requisite steps of connecting their github account? I am sorry, but I am not seeing any references here.

EDIT: I see the sequence of tests defined in test.list.ts file. This might just be a little confusing if we dont see this file or read the code. Should we update somewhere in Playwright README that the tests are executed in the order defined in e2e/playwright/tests/test.list.ts file (or) do you think this is not required and is a standard Playwright practice of writing E2E tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately, tests are dependent and ran serially in a specific order specified in test.list.ts

in the future, we will explore better approaches to prepare the entire env for each test, due to the complexity, the first full iteration is like this.

Comment on lines +56 to +59
await expect(todo.getDesc(GithubRHSCategory.OPEN_PR)).toHaveText('You have 1 open pull requests:');
await expect(todo.getDesc(GithubRHSCategory.ASSIGNMENTS)).toHaveText('You have 19 assignments:');
await expect(todo.getDesc(GithubRHSCategory.REVIEW_PR)).toHaveText('You have 1 pull requests awaiting your review:');
await expect(todo.getDesc(GithubRHSCategory.UNREAD)).toHaveText('You have 1 unread messages:');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have these numbers defined in a separate file, so its easy to edit in future (if these value changes due to any other situations) and ensure assertions passes, instead of requiring the test to be updated in multiple places? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💯 to that, I'll add that change in my tests for sidebar/coutners since I need to use them too.

Copy link
Contributor

@srkgupta srkgupta left a comment

Choose a reason for hiding this comment

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

Thanks @trilopin. The tests and it's dependencies looks great overall. Just left a few minor comments.

@srkgupta srkgupta self-requested a review May 2, 2023 10:00
Copy link
Contributor

@srkgupta srkgupta left a comment

Choose a reason for hiding this comment

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

Approving the changes based on previous comments and discussions. LGTM 🎉

@trilopin trilopin merged commit 9bfa67c into master May 2, 2023
@trilopin trilopin deleted the pw-specs branch May 2, 2023 10:22
trilopin added a commit that referenced this pull request May 2, 2023
* master:
  Playwright suite on CI + me/todo/autocomplete specs (#666)
@avas27JTG avas27JTG mentioned this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants