Skip to content

Create Plugin: Extend the playwright config file - #1495

Closed
oshirohugo wants to merge 17 commits into
mainfrom
extend-playwright-config-file
Closed

Create Plugin: Extend the playwright config file#1495
oshirohugo wants to merge 17 commits into
mainfrom
extend-playwright-config-file

Conversation

@oshirohugo

@oshirohugo oshirohugo commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This PR move the existing playwright config to ./config, this will make updating the default playwright config easier.

Which issue(s) this PR fixes:

Closes #1366

Special notes for your reviewer:

The way the docs are written right now is still applicable to the new playwright config that extends the one from ./config therefore they were not modified.

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/create-plugin@5.27.0-canary.1495.17868716647.0
npm install @grafana/plugin-meta-extractor@0.10.0-canary.1495.17868716647.0
# or 
yarn add @grafana/create-plugin@5.27.0-canary.1495.17868716647.0
yarn add @grafana/plugin-meta-extractor@0.10.0-canary.1495.17868716647.0

@oshirohugo oshirohugo added enhancement New feature or request create-plugin related to the create-plugin tool minor labels Jan 28, 2025
@oshirohugo oshirohugo self-assigned this Jan 28, 2025
@oshirohugo
oshirohugo requested review from a team and s4kh January 28, 2025 16:03
@github-actions

github-actions Bot commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new minor release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@oshirohugo
oshirohugo requested review from jackw and sunker January 28, 2025 16:04

@sunker sunker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a bit sceptical to this. This will make it a little harder to overview and edit the Playwright config for plugin developers. And to my knowledge, Playwright don't offer any abstraction to merge configs (the way for example Webpack does with [https://www.npmjs.com/package/webpack-merge]).

Now that we're soon to release the new create-plugin update cmd that allows us to safely manipulate files outside the .config dir, is this really necessary? cc @jackw who initially raised this issue.

@mckn

mckn commented Jan 29, 2025

Copy link
Copy Markdown
Collaborator

I'm a bit sceptical to this. This will make it a little harder to overview and edit the Playwright config for plugin developers. And to my knowledge, Playwright don't offer any abstraction to merge configs (the way for example Webpack does with [https://www.npmjs.com/package/webpack-merge]).

Now that we're soon to release the new create-plugin update cmd that allows us to safely manipulate files outside the .config dir, is this really necessary? cc @jackw who initially raised this issue.

Merging the configs isn't a problem since playwright expects the default object exposed from that file to be the config. So you can use what ever merge util you want to merge multiple configs.

But I agree with your thoughts regarding the migrations. However, it might not be easy to migrate a file that is changed by the user. So moving the base to .config folder might be a good idea regardless. WDYT?

@jackw

jackw commented Jan 30, 2025

Copy link
Copy Markdown
Collaborator

I'm a bit sceptical to this. This will make it a little harder to overview and edit the Playwright config for plugin developers. And to my knowledge, Playwright don't offer any abstraction to merge configs (the way for example Webpack does with [https://www.npmjs.com/package/webpack-merge]).

As others have also pointed out we can rely on spreading these configs but I believe Playwright does have some concept of merging configs via defineConfig which can take multiple configs. e.g. defineConfig(defaultConfig, {});.

However, the playwright team decided that the projects property should override which would result in needing to do:

export default defineConfig(defaultConfig, {
  projects: [
    ...defaultConfig.projects!,
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'], storageState: 'playwright/.auth/admin.json' },
      dependencies: ['auth'],
    },
  ],
});

Whilst it was originally designed for webpack, webpack-merge isn't webpack specific. You can use it for any config including playwrights:

import { merge } from 'webpack-merge';
import defaultConfig from './.config/playwright.config';

const config = merge(defaultConfig, {
  projects: [
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'], storageState: 'playwright/.auth/admin.json' },
      dependencies: ['auth'],
    },
  ],
});

export default defineConfig(config);

Now that we're soon to release the new create-plugin update cmd that allows us to safely manipulate files outside the .config dir, is this really necessary?

Within create-plugin, we have the concept of "put default configs in .config directory and extend in files in root of project" and I opened the issue to align our playwright config with this concept. I also agree with @mckn that even with migrations it's much easier to update a file in the .config directory as we consider them ours and document in the files and in our docs website that touching them is a bad idea.

@@ -0,0 +1,53 @@
import type { PluginOptions } from '@grafana/plugin-e2e';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import type { PluginOptions } from '@grafana/plugin-e2e';
/*
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
*
* In order to extend the configuration follow the steps in
* https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-playwright-config
*/
import type { PluginOptions } from '@grafana/plugin-e2e';

If we decide to do this I think we should update the docs site in this PR too with instructions.

},
],

} as PlaywrightTestConfig<PluginOptions>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure this is necessary. I think you can export the defineConfig<PluginOptions>({}) in this file then use defineConfig again in the root.

@oshirohugo
oshirohugo requested review from jackw and sunker February 3, 2025 12:44
@oshirohugo

Copy link
Copy Markdown
Contributor Author

@jackw @mckn could you please check this one again?

@leventebalogh leventebalogh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Even though I understand @sunker's points, I am also leaning towards having all "basic" configuration files under the .config/ folder (mostly for the reason that was already brought up before, so it's easier for us to decide programatically what was added by the user and what's the default config we provided).

The changes look good to me, but maybe better to also wait for @jackw 👍

@jackw jackw added the release label May 5, 2025

@jackw jackw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM ! 🚀

See my previous comment about overrides to project property with multiple defineConfig calls. Might be useful to surface this in a docs update?

@oshirohugo
oshirohugo requested review from a team, andresmgot and wbrowne May 12, 2025 15:56
@oshirohugo

Copy link
Copy Markdown
Contributor Author

@jackw I've update the docs to reflect the new config extensions and I also added a section to our docs trying to cover the issues you mentioned, please take a look if they are ok :D

@oshirohugo

Copy link
Copy Markdown
Contributor Author

@jackw is this PR still relevant? If yes, I'll create another PR in a fresher branch.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Dec 19, 2025
@github-actions

github-actions Bot commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it has not had activity in the last 2 weeks. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Jan 2, 2026
@github-project-automation github-project-automation Bot moved this from 🔬 In review to 🚀 Shipped in Grafana Catalog Team Jan 2, 2026
@github-actions
github-actions Bot deleted the extend-playwright-config-file branch March 19, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-plugin related to the create-plugin tool enhancement New feature or request stale

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feat: Extend the playwright config file

5 participants