-
Notifications
You must be signed in to change notification settings - Fork 0
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 Initial Setup #3
Open
panoramix360
wants to merge
44
commits into
main
Choose a base branch
from
feature/playwright-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
a726963
feat: first playwright config
panoramix360 ebf53dc
feat: adding utils files
panoramix360 e433aa0
feat: change the export way
panoramix360 dc16baa
adds config to the RunContainer function
panoramix360 08db487
feat: configuring the node-fetch package
panoramix360 fb1149a
feat: externalizing PluginConfig
panoramix360 90336a0
feat: adding external plugin configuration
panoramix360 eefcd4c
feat: adding an example-test-folder
panoramix360 63bba59
chore: removes the console log
panoramix360 d91e7f7
feat: moving the constructor to the top and changing the name of the …
panoramix360 730844d
feat: enhancing the readfile for loop
panoramix360 814cdef
feat: configuring eslint and formatting
panoramix360 12c2372
chore: removes unecessary imports
panoramix360 4905419
feat: removing the `no-process-env` and `no-undefined` to not complai…
panoramix360 a1afbb6
feat: creating the concept of the MattermostPlugin
panoramix360 9f05ee9
fix: eslint problem on the promises of the plugins to install
panoramix360 c4d5ab0
refactor to make it simpler to use an external plugin
panoramix360 c29ee4d
chore: fix babel old version
panoramix360 8fea238
chore: setting the nvm version
panoramix360 d3814c9
chore: actions on save
panoramix360 1ad4c91
chore: removing eslint n
panoramix360 49fa826
chore: fixing babel es lint parser
panoramix360 0a94b3f
newline in the end of file
panoramix360 e4a5a52
chore: renaming
panoramix360 833594b
chore: rename pluginid
panoramix360 d89e03a
feat: changing how the client types the configs for the plugin
panoramix360 f47d8d6
feat: adding demo plugin as a constant
panoramix360 7dc7fb2
chore: changing the default node version and the settings
panoramix360 359360a
feat: increasing the timeout and creating a dialog test
panoramix360 97aedfe
feat: adding the env
panoramix360 a5ba3aa
feat: adding a force boolean on the install commands
panoramix360 743d259
feat: testing github actions
panoramix360 4fb61e2
feat: change workflow action
panoramix360 5c66bb1
ci: moving the playwright workflow
panoramix360 ace8f8f
ci: test another command
panoramix360 19c8eb3
ci: adding a working dir
panoramix360 1867c0d
ci: playwright report path
panoramix360 462be25
chore: public var
panoramix360 e4e4aea
feat: changing node version to equal to nvmrc
panoramix360 f073874
chore: renaming folder
panoramix360 b5a874b
feat: adding the dist files
panoramix360 2369d27
feat: updates package json
panoramix360 40010ef
fix: issue when it's a local binary, the path was not being filled
panoramix360 a214fe3
feat: update MattermostContainer to set user ID after login and clean…
panoramix360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
panoramix360 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Install root dependencies | ||
run: npm ci | ||
- name: Install tests dependencies | ||
run: npm ci | ||
working-directory: example_plugin_tests/ | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
working-directory: example_plugin_tests/ | ||
- name: Run Playwright tests | ||
run: npm run test | ||
panoramix360 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
working-directory: example_plugin_tests/ | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: example_plugin_tests/playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.eslintcache | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"eslint.validate": ["javascript"], | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "example_plugin_tests", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "playwright test", | ||
"ui": "playwright test --ui" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"mattermost-plugin-e2e-test-utils": "file:..", | ||
"@playwright/test": "^1.42.1", | ||
"@types/node": "^20.11.24" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {defineConfig, devices} from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
|
||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
|
||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: Boolean(process.env.CI), | ||
|
||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
|
||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
|
||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
|
||
/* More timeout since raising containers are costly */ | ||
timeout: 50000, | ||
panoramix360 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
|
||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: {...devices['Desktop Chrome']}, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: {...devices['Desktop Firefox']}, | ||
}, | ||
|
||
{ | ||
name: 'webkit', | ||
use: {...devices['Desktop Safari']}, | ||
}, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import {test, expect} from '@playwright/test'; | ||
import { | ||
MattermostContainer, | ||
MattermostPlugin, | ||
login, | ||
logout, | ||
} from 'mattermost-plugin-e2e-test-utils'; | ||
|
||
type DemoPluginConfig = { | ||
clientId: string | ||
} | ||
|
||
const DEMO_PLUGIN_EXTERNAL_URL = 'https://github.com/mattermost/mattermost-plugin-demo/releases/download/v0.10.1/com.mattermost.demo-plugin-0.10.1.tar.gz'; | ||
|
||
let mattermost: MattermostContainer; | ||
let demoPluginInstance: MattermostPlugin<DemoPluginConfig>; | ||
|
||
test.beforeAll(async () => { | ||
demoPluginInstance = new MattermostPlugin<DemoPluginConfig>({ | ||
pluginId: 'com.mattermost.demo-plugin', | ||
pluginConfig: { | ||
clientId: 'client-id', | ||
}, | ||
}). | ||
withExternalURL(DEMO_PLUGIN_EXTERNAL_URL); | ||
|
||
mattermost = await new MattermostContainer(). | ||
withPlugin(demoPluginInstance). | ||
withEnv('MM_FILESETTINGS_ENABLEPUBLICLINK', 'true'). | ||
startWithUserSetup(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await mattermost.stop(); | ||
}); | ||
|
||
test.describe('example test', () => { | ||
test('check if the town square and plublic channel are created', async ({page}) => { | ||
const url = mattermost.url(); | ||
await login(page, url, 'regularuser', 'regularuser'); | ||
await expect(page.getByLabel('town square public channel')).toBeVisible(); | ||
await logout(page); | ||
}); | ||
|
||
test('open dialog and cancels it', async ({page}) => { | ||
const url = mattermost.url(); | ||
await login(page, url, 'regularuser', 'regularuser'); | ||
|
||
await page.getByTestId('post_textbox').fill('/dialog'); | ||
await page.getByTestId('SendMessageButton').click(); | ||
|
||
await expect(page.getByText('Test Title')).toBeVisible(); | ||
await expect(page.getByTestId('realnamelabel')).toBeVisible(); | ||
await expect(page.getByTestId('someemaillabel')).toBeVisible(); | ||
await expect(page.getByTestId('somepasswordlabel')).toBeVisible(); | ||
|
||
await page.getByRole('button', {name: 'Cancel'}).click(); | ||
|
||
await expect(page.getByText('Test Title')).not.toBeVisible(); | ||
|
||
await logout(page); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if it makes sense to have this workflow be in a centralized GH action for other plugin projects to use. The one thing is that the way we set up our shared actions, the caller cannot pass any arbitrary environment variables. I think that works fine since pretty much all configuration is done in the actual test now due to using
testcontainers
🎉 🎉Made a ticket for creating a centralized action/workflow to run playwright tests #6
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.
That makes sense! let's work on that in the new ticket!
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.
Keeping this conversation unresolved to surface the discussion