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

WIP: Playwright with shared repo, compared with master #236

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c24bd0f
setup playwright using docs
rahulsuresh-git Nov 1, 2023
a3871d2
fixed setup commands in setup-environment script
rahulsuresh-git Nov 1, 2023
389c10f
added readme
rahulsuresh-git Nov 1, 2023
e52d248
added config for playwright
rahulsuresh-git Nov 1, 2023
c0d4dc3
Merge branch 'master' of https://github.com/rahulsuresh-git/mattermos…
rahulsuresh-git Nov 9, 2023
ef99bdd
integrated playwright utils and added test to check available commands
rahulsuresh-git Nov 9, 2023
cce3e55
removed changes from user.ts
rahulsuresh-git Nov 9, 2023
ab195be
fixed TodoBot URL
rahulsuresh-git Nov 9, 2023
15ea6cb
removed a comment
rahulsuresh-git Nov 9, 2023
54c3133
improvements to message input function
rahulsuresh-git Nov 10, 2023
007367f
fixed issue with cleanUpBotDMs
rahulsuresh-git Nov 10, 2023
23c6e32
added github workflow for playwright
rahulsuresh-git Nov 11, 2023
6646dd0
updated workflow with workflow_dispatch
rahulsuresh-git Nov 15, 2023
8d22541
updated node version in .nvmrc
rahulsuresh-git Nov 15, 2023
8bc4127
updated package-lock.json
rahulsuresh-git Nov 16, 2023
98e0dc2
updated package-lock.json for node 16.13.1
rahulsuresh-git Nov 16, 2023
3a94bd3
updated package-lock.json for node 16.13.1
rahulsuresh-git Nov 16, 2023
63284a8
Merge branch 'feat/adding-playwright-e2e' of https://github.com/rahul…
rahulsuresh-git Nov 16, 2023
721a285
added python to workflow
rahulsuresh-git Nov 16, 2023
4be1742
removed python from workflow and removed package-lock.json cache
rahulsuresh-git Nov 16, 2023
0e9c707
attempts to fix workflow failure
rahulsuresh-git Nov 16, 2023
858d67e
attempts to fix workflow failure
rahulsuresh-git Nov 16, 2023
67351b4
attempts to fix workflow failure
rahulsuresh-git Nov 16, 2023
f48fdb2
reverted workflow changes
rahulsuresh-git Nov 16, 2023
745a291
reverted workflow changes
rahulsuresh-git Nov 16, 2023
3ac3aec
disabled caching in workflow
rahulsuresh-git Nov 16, 2023
a798f8d
Merge branch 'master' of https://github.com/rahulsuresh-git/mattermos…
rahulsuresh-git Nov 16, 2023
ab0fcd9
updated playwright workflow and node version to 16.20.2
rahulsuresh-git Nov 16, 2023
ae3e6d2
updated to node 18.17 and updated setup-environment
rahulsuresh-git Nov 16, 2023
f848c87
updated workflow with new steps
rahulsuresh-git Nov 16, 2023
cf843ad
changed checkout method for mattermost-monorepo
rahulsuresh-git Nov 16, 2023
1a37d61
fixed tsc errors
rahulsuresh-git Nov 16, 2023
8a698e3
commented out playwright ci/lint in workflow
rahulsuresh-git Nov 16, 2023
dd496af
updated workflow to run on pull_request
rahulsuresh-git Nov 17, 2023
e3fb677
remove extract only what's necessary
mickmister Nov 17, 2023
284e154
add submodule
mickmister Nov 17, 2023
e2460ce
update commit on submodule
mickmister Nov 17, 2023
a5094ae
change actions workflow to use submodule
mickmister Nov 17, 2023
c2239ad
update path to .auth-user.json
mickmister Nov 17, 2023
3c24235
regenerate package-lock.json
mickmister Nov 17, 2023
17bbf7e
update test utils commit
mickmister Nov 22, 2023
7c41fa3
Merge branch 'master' into playwright-with-shared-repo
mickmister Nov 22, 2023
8562797
update webapp deps
mickmister Nov 22, 2023
d0e4119
fix e2e test
mickmister Nov 22, 2023
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
21 changes: 8 additions & 13 deletions .github/workflows/playwright.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there something we can generalize from this file and move into https://github.com/mattermost/actions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I want to "get it right" first though. I don't think we should merge two PRs from two different repos before moving this to the actions repo

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: 'true'

- name: ci/setup-go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
Expand Down Expand Up @@ -129,12 +131,6 @@ jobs:
PLUGIN_E2E_MOCK_OAUTH_SERVER_URL: http://172.17.0.1:8080
E2E_TESTING: true

# - name: ci/checkout-mattermost-monorepo
# uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
# with:
# path: ../mattermost
# repository: mattermost/mattermost

- name: ci/checkout-mattermost-monorepo
run: |
git clone https://github.com/mattermost/mattermost.git ../mattermost
Expand Down Expand Up @@ -162,13 +158,12 @@ jobs:

- name: ci/install-plugin-playwright-deps
run: |
cd e2e/playwright
npm ci
cd e2e/playwright/mattermost-plugin-e2e-test-utils
npm i

- name: ci/tsc
run: |
cd e2e/playwright
npm run tsc
cd e2e/playwright/mattermost-plugin-e2e-test-utils

# - name: ci/lint
# run: |
Expand All @@ -177,20 +172,20 @@ jobs:

- name: ci/run-playwright-tests
run: |
cd e2e/playwright
cd e2e/playwright/mattermost-plugin-e2e-test-utils
npm run test-ci
env:
PW_BASE_URL: ${{ env.MM_SERVICESETTINGS_SITEURL }}

- name: ci/move-artifacts
if: success() || failure()
run: |
cd e2e/playwright
cd e2e/playwright/mattermost-plugin-e2e-test-utils
mkdir results
mv playwright-report results

- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results
path: e2e/playwright/results
path: e2e/playwright/mattermost-plugin-e2e-test-utils/results
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "e2e/playwright/mattermost-plugin-e2e-test-utils"]
path = e2e/playwright/mattermost-plugin-e2e-test-utils
url = https://github.com/mattermosttest/mattermost-plugin-e2e-test-utils.git
Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love seeing a submodule getting used here. It adds a lot of complexity. Are there simpler approaches that you considered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hanzei Yes the other two options I've considered is referencing through npm, and just duplicating the code. I definitely don't want to go down the route of duplicating the code. Publishing to npm or referencing as a git-based node dependency is probably what we will end up doing.

The submodule approach was the quickest way that required no hassling with npm. Even if I didn't end up running into an issue with npm, I didn't want that to get in the way when trying this out. A git-based npm dependency wouldn't be much different as far as "use this commit", but I agree the submodule is not as turnkey as referencing a git-based dependency

Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the repo be under the Mattermost org? mattermosttest is only used for GitHub API testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hanzei Yes this was just the easiest way for me to have it somewhere other than my personal account. Since it is specifically related to Mattermost, and I was directly referencing it in a Mattermost project as a dependency, I sided to put it there for now. It's mainly a proof of concept to test out sharing code, and figuring out exactly which code should be shared etc.

10 changes: 5 additions & 5 deletions e2e/playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
node_modules/
node_modules
.eslintcache
.auth-user.json
.env
/blob-report/
/playwright/.cache/
.env
test-results
screenshots
playwright-report
test-results
.auth-user.json
.eslintcache
1 change: 1 addition & 0 deletions e2e/playwright/mattermost-plugin-e2e-test-utils
4 changes: 3 additions & 1 deletion e2e/playwright/tests/integrations.setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import path from 'node:path';

import {test as setup} from '@e2e-support/test_fixture';

const authFile = __dirname + '/../.auth-user.json';
const authFile = path.join(__dirname, '../mattermost-plugin-e2e-test-utils/.auth-user.json');

setup('authenticate', async ({page, pages, pw}) => {
const {adminClient, adminUser} = await pw.getAdminClient();
Expand Down
2 changes: 1 addition & 1 deletion e2e/playwright/tests/test.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import {test} from '@playwright/test';
import core from './todo_plugin.spec';

import '../support/init_test';
import '../mattermost-plugin-e2e-test-utils/support/init_test';

test.describe(core.connected);
8 changes: 3 additions & 5 deletions e2e/playwright/tests/todo_plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
// ***************************************************************

import {expect, test} from '@e2e-support/test_fixture';
import SlashCommandSuggestions from 'support/components/slash_commands';
import {fillMessage, getTodoBotDMPageURL} from 'support/utils';
import SlashCommandSuggestions from '../mattermost-plugin-e2e-test-utils/support/components/slash_commands';
import {fillMessage, getBotDMPageURL} from '../mattermost-plugin-e2e-test-utils/support/utils';

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);
const dmURL = await getBotDMPageURL(adminClient, '', adminUser.id, 'todo');
await page.goto(dmURL, {waitUntil: 'load'});

const c = new pages.ChannelsPage(page);
Expand All @@ -39,4 +38,3 @@ export default {
});
},
};

35 changes: 21 additions & 14 deletions e2e/playwright/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@
"noEmit": true,
"baseUrl": ".",
"paths": {
"@mattermost/client/*": [
"../../../mattermost/webapp/platform/client/lib/*"
],
"@mattermost/types/*": [
"../../../mattermost/webapp/platform/types/lib/*"
],
// "@mattermost/client/*": [
// "../../../mattermost/webapp/platform/client/lib/*"
// ],
// "@mattermost/types/*": [
// "../../../mattermost/webapp/platform/types/lib/*"
// ],
"@e2e-support/*": [
"../../../mattermost/e2e-tests/playwright/support/*"
],
"@e2e-test.config": [
"../../../mattermost/e2e-tests/playwright/test.config.ts"
],
"@e2e-test.playwright-config": [
"../../../mattermost/e2e-tests/playwright/playwright.config.ts"
],
// "@e2e-test.config": [
// "../../../mattermost/e2e-tests/playwright/test.config.ts"
// ],
// "@e2e-test.playwright-config": [
// "../../../mattermost/e2e-tests/playwright/playwright.config.ts"
// ],
"@playwright/test": [
"../../../mattermost/e2e-tests/playwright/node_modules/@playwright/test"
],
"@e2e-types": ["../../../mattermost/e2e-tests/playwright/types.ts"]
// "@e2e-types": [
// "../../../mattermost/e2e-tests/playwright/types.ts"
// ],
// "@mattermost-plugin-e2e-test-utils": [
// "./mattermost-plugin-e2e-test-utils"
// ]
}
},
"include": ["./**/*"]
"include": [
"./**/*",
]
}
Loading
Loading