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

Docs: Plugin E2E - Add Setup Resources article #748

Merged
merged 16 commits into from
Feb 20, 2024

Conversation

sunker
Copy link
Contributor

@sunker sunker commented Feb 15, 2024

What this PR does / why we need it:

This PR adds a new article that walks through how to set up the resources you'll need for e2e testing. See this epic for better understanding of how this article fits into the bigger picture.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@sunker sunker requested a review from a team as a code owner February 15, 2024 15:32
@sunker sunker requested review from academo and removed request for a team February 15, 2024 15:32
Copy link

github-actions bot commented Feb 15, 2024

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

✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs.

@sunker sunker added the no-changelog Don't include in changelog and version calculations label Feb 15, 2024
docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved
docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved

# Introduction

In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. This guide covers how to setup the resources that you need.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. This guide covers how to setup the resources that you need.
In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. For example, to test how a panel plugin displays data, you'll need a data source configured to query and return that data. This guide covers how to setup the resources that you need through [provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/).

docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved

You may use [provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) to configure resources such as dashboards and data sources.

> If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file. Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data.
Copy link
Contributor

Choose a reason for hiding this comment

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

These feel like separate points. Displaying them is awkward

Suggested change
> If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file. Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data.
:::note
If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file.
:::
:::danger
Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data.
:::

These read like separate points of differing levels of concern. A slightly awkward display, but generally we dont use > quote blocks


`@grafana/plugin-e2e` provides fixtures that enables you to read files that you have placed in the `provisioning` folder.

### `readProvisionedDataSource` fixture
Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-02-15 at 17 24 46

code styling always looks weird in headers/bold in general. Not sure if @jackw has a suggestion here, but a simple suggestion would be to drop "fixture"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks slightly better now that it's and h4 instead of h3.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My suggestion would be to not use it. Headings using multiple fonts always look jarring to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay - I'll make sure code styling is not used in headings. 👍

docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved
docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved
@sunker sunker force-pushed the plugin-e2e/setup-resources-docs branch from aea0030 to 3c9ad0f Compare February 19, 2024 09:19
Copy link
Collaborator

@jackw jackw left a comment

Choose a reason for hiding this comment

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

Left a question more for my own understanding than anything else. 🚀

docusaurus/docs/e2e-test-a-plugin/setup-resources.md Outdated Show resolved Hide resolved

```ts title="configEditor.spec.ts"
const datasource = readProvisionedDataSource<JsonData, SecureJsonData>({ fileName: 'datasources.yml' });
await page.getByLabel('API Key').fill(datasource.secureJsonData.apiKey);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Above we claim it's dangerous to commit secrets to public repos and to use env vars for sensitive data but here we grab an API key from a datasources.yml file. Am I wrong or is this example contradicting the advice above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as secrets are being defined with environment variables in the provisioned file it should be fine. Look at this example for the google-sheets datasource:

datasources:
  - editable: true
    enabled: true
    jsonData:
      authType: jwt
    name: Google Sheets Service Account
    secureJsonData:
      jwt: ${GOOGLE_JWT_FILE}
    type: grafana-googlesheets-datasource
    version: 1

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
@sunker sunker merged commit 0229575 into main Feb 20, 2024
12 checks passed
@sunker sunker deleted the plugin-e2e/setup-resources-docs branch February 20, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Don't include in changelog and version calculations
Projects
Development

Successfully merging this pull request may close these issues.

3 participants