-
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
WIP: Playwright with shared repo, compared with master #236
base: master
Are you sure you want to change the base?
Changes from 40 commits
c24bd0f
a3871d2
389c10f
e52d248
c0d4dc3
ef99bdd
cce3e55
ab195be
15ea6cb
54c3133
007367f
23c6e32
6646dd0
8d22541
8bc4127
98e0dc2
3a94bd3
63284a8
721a285
4be1742
0e9c707
858d67e
67351b4
f48fdb2
745a291
3ac3aec
a798f8d
ab0fcd9
ae3e6d2
f848c87
cf843ad
1a37d61
8a698e3
dd496af
e3fb677
284e154
e2460ce
a5094ae
c2239ad
3c24235
17bbf7e
7c41fa3
8562797
d0e4119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,198 @@ | ||
name: Playwright Tests | ||
on: | ||
workflow_run: | ||
workflows: ["ci"] | ||
types: | ||
- completed | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
TERM: xterm | ||
GO_VERSION: 1.19.6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of CI uses go1.21. (mattermost/actions#13) Should the same version be used here? |
||
NODE_VERSION: 16.20.2 | ||
|
||
jobs: | ||
playwright-run: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:11.13 | ||
env: | ||
POSTGRES_USER: mmuser | ||
POSTGRES_PASSWORD: mostest | ||
POSTGRES_DB: mattermost_test | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
minio: | ||
image: minio/minio:RELEASE.2019-10-11T00-38-09Z | ||
env: | ||
MINIO_ACCESS_KEY: minioaccesskey | ||
MINIO_SECRET_KEY: miniosecretkey | ||
MINIO_SSE_MASTER_KEY: "my-minio-key:6368616e676520746869732070617373776f726420746f206120736563726574" | ||
inbucket: | ||
image: mattermost/inbucket:release-1.2.0 | ||
ports: | ||
- 10080:10080 | ||
- 10110:10110 | ||
- 10025:10025 | ||
elasticsearch: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do minio and elasticsearch to be used during testing? If not, maybe these can be removed? |
||
image: mattermost/mattermost-elasticsearch-docker:7.0.0 | ||
env: | ||
http.host: "0.0.0.0" | ||
http.port: 9200 | ||
http.cors.enabled: "true" | ||
http.cors.allow-origin: "http://localhost:1358,http://127.0.0.1:1358" | ||
http.cors.allow-headers: "X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization" | ||
http.cors.allow-credentials: "true" | ||
transport.host: "127.0.0.1" | ||
ES_JAVA_OPTS: "-Xms512m -Xmx512m" | ||
ports: | ||
- 9200:9200 | ||
mattermost-server: | ||
image: mattermost/mattermost-enterprise-edition:master | ||
env: | ||
DB_HOST: postgres | ||
DB_PORT_NUMBER: 5432 | ||
MM_DBNAME: mattermost_test | ||
MM_USERNAME: mmuser | ||
MM_PASSWORD: mostest | ||
CI_INBUCKET_HOST: inbucket | ||
CI_INBUCKET_PORT: 10080 | ||
CI_MINIO_HOST: minio | ||
IS_CI: true | ||
MM_CLUSTERSETTINGS_READONLYCONFIG: false | ||
MM_EMAILSETTINGS_SMTPSERVER: inbucket | ||
MM_EMAILSETTINGS_SMTPPORT: 10025 | ||
MM_ELASTICSEARCHSETTINGS_CONNECTIONURL: http://elasticsearch:9200 | ||
MM_EXPERIMENTALSETTINGS_USENEWSAMLLIBRARY: true | ||
MM_SQLSETTINGS_DATASOURCE: "postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable&connect_timeout=10" | ||
MM_SQLSETTINGS_DRIVERNAME: postgres | ||
MM_PLUGINSETTINGS_ENABLEUPLOADS: true | ||
MM_SERVICESETTINGS_SITEURL: http://localhost:8065 | ||
MM_PLUGINSETTINGS_AUTOMATICPREPACKAGEDPLUGINS: false | ||
MM_ANNOUNCEMENTSETTINGS_ADMINNOTICESENABLED: false | ||
MM_FEATUREFLAGS_AppsEnabled: true | ||
|
||
ports: | ||
- 8065:8065 | ||
- 4000:4000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does port 4000 needs to be exposed? |
||
env: | ||
TYPE: NONE | ||
PULL_REQUEST: "" | ||
HEADLESS: true | ||
DASHBOARD_ENABLE: false | ||
FULL_REPORT: false | ||
MM_SERVICESETTINGS_SITEURL: http://localhost:8065 | ||
MM_ADMIN_EMAIL: [email protected] | ||
MM_ADMIN_USERNAME: sysadmin | ||
MM_ADMIN_PASSWORD: Sys@dmin-sample1 | ||
TEST_DATABASE_URL: postgres://mmuser:mostest@localhost:5432/mattermost_test | ||
MM_SERVICESETTINGS_ENABLEDEVELOPER: true | ||
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 | ||
with: | ||
go-version: "${{ env.GO_VERSION }}" | ||
cache: true | ||
|
||
- 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 commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed any longer? Having a cache would be nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NVM, I just saw #233. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that we were having issues with this block, where the |
||
|
||
- name: ci/create-admin-user | ||
run: | | ||
STATUSCODE=$(curl -X POST -H "Content-Type: application/json" -d '{"email": "'${MM_ADMIN_EMAIL}'", "username": "'${MM_ADMIN_USERNAME}'", "password": "'${MM_ADMIN_PASSWORD}'"}' ${MM_SERVICESETTINGS_SITEURL}/api/v4/users -w "%{http_code}" -o /dev/stderr) | ||
if test $STATUSCODE -ne 201; then exit 1; fi | ||
|
||
- name: ci/install-go-dependencies | ||
run: go mod tidy | ||
|
||
- name: ci/install-plugin-webapp-deps | ||
run: cd webapp && npm ci | ||
|
||
- name: ci/build-and-install-plugin | ||
run: make deploy | ||
env: | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove? |
||
|
||
- name: ci/checkout-mattermost-monorepo | ||
run: | | ||
git clone https://github.com/mattermost/mattermost.git ../mattermost | ||
|
||
- name: ci/setup-node-for-mattermost-monorepo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe drop monorepo in name? Same in other instances. |
||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | ||
with: | ||
node-version-file: "../mattermost/.nvmrc" | ||
|
||
- name: ci/install-mattermost-monorepo-webapp-deps | ||
run: | | ||
cd ../mattermost/webapp | ||
npm i | ||
|
||
- name: ci/install-mattermost-monorepo-playwright-deps | ||
run: | | ||
cd ../mattermost/e2e-tests/playwright | ||
npm i | ||
npx playwright install --with-deps | ||
|
||
- name: ci/setup-node-for-mattermost-plugin | ||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | ||
with: | ||
node-version-file: ".nvmrc" | ||
|
||
- name: ci/install-plugin-playwright-deps | ||
run: | | ||
cd e2e/playwright/mattermost-plugin-e2e-test-utils | ||
npm i | ||
|
||
- name: ci/tsc | ||
run: | | ||
cd e2e/playwright/mattermost-plugin-e2e-test-utils | ||
npm run tsc | ||
|
||
# - name: ci/lint | ||
# run: | | ||
# cd e2e/playwright | ||
# npm run lint | ||
|
||
- name: ci/run-playwright-tests | ||
run: | | ||
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/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/mattermost-plugin-e2e-test-utils/results |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the repo be under the Mattermost org? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.13.1 | ||
16.20.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
playwright-report | ||
test-results | ||
node_modules | ||
.auth-user.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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 = path.join(__dirname, '../mattermost-plugin-e2e-test-utils/.auth-user.json'); | ||
|
||
setup('authenticate', async ({page, pages, pw}) => { | ||
const {adminClient, adminUser} = await pw.getAdminClient(); | ||
if (adminUser === null) { | ||
throw new Error('authenticate: can not get adminUser'); | ||
} | ||
const config = await adminClient.getConfig(); | ||
const login = new pages.LoginPage(page, config); | ||
await login.goto(); | ||
await login.login(adminUser); | ||
await page.context().storageState({path: authFile}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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 '../mattermost-plugin-e2e-test-utils/support/init_test'; | ||
|
||
test.describe(core.connected); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
// *************************************************************** | ||
// - [#] indicates a test step (e.g. # Go to a page) | ||
// - [*] indicates an assertion (e.g. * Check the title) | ||
// *************************************************************** | ||
|
||
import {expect, test} from '@e2e-support/test_fixture'; | ||
import SlashCommandSuggestions from '../mattermost-plugin-e2e-test-utils/support/components/slash_commands'; | ||
import {fillMessage, getTodoBotDMPageURL} 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); | ||
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'); | ||
}); | ||
}); | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"skipLibCheck": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
// "@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" | ||
// ], | ||
"@playwright/test": [ | ||
"../../../mattermost/e2e-tests/playwright/node_modules/@playwright/test" | ||
], | ||
// "@e2e-types": [ | ||
// "../../../mattermost/e2e-tests/playwright/types.ts" | ||
// ], | ||
// "@mattermost-plugin-e2e-test-utils": [ | ||
// "./mattermost-plugin-e2e-test-utils" | ||
// ] | ||
} | ||
}, | ||
"include": [ | ||
"./**/*", | ||
] | ||
} |
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.
Is there something we can generalize from this file and move into https://github.com/mattermost/actions?
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.
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