Commit 1b5e7cee by Dominik Prokop Committed by Ryan McKinley

grafana/toolkit: Remove hack to expose plugin/e2e exports & types (#19467)

parent 00e7c7c4
...@@ -100,6 +100,5 @@ ...@@ -100,6 +100,5 @@
}, },
"_moduleAliases": { "_moduleAliases": {
"puppeteer": "node_modules/puppeteer-core" "puppeteer": "node_modules/puppeteer-core"
}, }
"types": "src/index.ts"
} }
...@@ -3,7 +3,6 @@ import * as fs from 'fs'; ...@@ -3,7 +3,6 @@ import * as fs from 'fs';
import chalk from 'chalk'; import chalk from 'chalk';
import { useSpinner } from '../utils/useSpinner'; import { useSpinner } from '../utils/useSpinner';
import { Task, TaskRunner } from './task'; import { Task, TaskRunner } from './task';
import escapeRegExp from 'lodash/escapeRegExp';
const path = require('path'); const path = require('path');
...@@ -120,21 +119,6 @@ const toolkitBuildTaskRunner: TaskRunner<ToolkitBuildOptions> = async () => { ...@@ -120,21 +119,6 @@ const toolkitBuildTaskRunner: TaskRunner<ToolkitBuildOptions> = async () => {
fs.mkdirSync('./dist/sass'); fs.mkdirSync('./dist/sass');
await copyFiles(); await copyFiles();
await copySassFiles(); await copySassFiles();
// RYAN HACK HACK HACK
// when Dominik is back from vacation, we can find a better way
// This moves the index to the root so plugin e2e tests can import them
console.warn('hacking an index.js file for toolkit. Help!');
const index = `${distDir}/src/index.js`;
fs.readFile(index, 'utf8', (err, data) => {
const pattern = 'require("./';
const js = data.replace(new RegExp(escapeRegExp(pattern), 'g'), 'require("./src/');
fs.writeFile(`${distDir}/index.js`, js, err => {
if (err) {
throw new Error('Error writing index: ' + err);
}
});
});
}; };
export const toolkitBuildTask = new Task<ToolkitBuildOptions>('@grafana/toolkit build', toolkitBuildTaskRunner); export const toolkitBuildTask = new Task<ToolkitBuildOptions>('@grafana/toolkit build', toolkitBuildTaskRunner);
export * from './e2e';
// Namespace for Plugins
import * as plugins from './plugins';
export { plugins };
import { Browser, Page } from 'puppeteer-core'; import { Browser, Page } from 'puppeteer-core';
import { e2eScenario, takeScreenShot, plugins, pages } from '@grafana/toolkit'; import { e2eScenario, takeScreenShot, pages } from '@grafana/toolkit/src/e2e';
import { getEndToEndSettings } from '@grafana/toolkit/src/plugins';
// **************************************************************** // ****************************************************************
// NOTE, This file is copied to plugins at runtime, it is not run locally // NOTE, This file is copied to plugins at runtime, it is not run locally
...@@ -11,7 +12,7 @@ const sleep = (milliseconds: number) => { ...@@ -11,7 +12,7 @@ const sleep = (milliseconds: number) => {
}; };
e2eScenario('Common Plugin Test', 'should pass', async (browser: Browser, page: Page) => { e2eScenario('Common Plugin Test', 'should pass', async (browser: Browser, page: Page) => {
const settings = plugins.getEndToEndSettings(); const settings = getEndToEndSettings();
const pluginPage = pages.getPluginPage(settings.plugin.id); const pluginPage = pages.getPluginPage(settings.plugin.id);
await pluginPage.init(page); await pluginPage.init(page);
await pluginPage.navigateTo(); await pluginPage.navigateTo();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"rootDirs": ["."], "rootDirs": ["."],
"outDir": "dist/src", "outDir": "dist/src",
"declaration": true, "declaration": true,
"declarationDir": "dist", "declarationDir": "dist/src",
"typeRoots": ["./node_modules/@types"], "typeRoots": ["./node_modules/@types"],
"esModuleInterop": true, "esModuleInterop": true,
"lib": ["es2015", "es2017.string", "dom"] "lib": ["es2015", "es2017.string", "dom"]
......
import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit'; import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit/src/e2e';
export interface CreateDashboardPage { export interface CreateDashboardPage {
addQuery: ClickablePageObjectType; addQuery: ClickablePageObjectType;
......
import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit'; import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit/src/e2e';
export interface DashboardsPage { export interface DashboardsPage {
dashboard: ClickablePageObjectType; dashboard: ClickablePageObjectType;
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
InputPageObjectType, InputPageObjectType,
InputPageObject, InputPageObject,
PageObject, PageObject,
} from '@grafana/toolkit'; } from '@grafana/toolkit/src/e2e';
export interface SaveDashboardModal { export interface SaveDashboardModal {
name: InputPageObjectType; name: InputPageObjectType;
......
import { TestPage, ClickablePageObject, Selector, ClickablePageObjectType } from '@grafana/toolkit'; import { TestPage, ClickablePageObject, Selector, ClickablePageObjectType } from '@grafana/toolkit/src/e2e';
export interface AddDataSourcePage { export interface AddDataSourcePage {
testDataDB: ClickablePageObjectType; testDataDB: ClickablePageObjectType;
......
import { TestPage } from '@grafana/toolkit'; import { TestPage } from '@grafana/toolkit/src/e2e';
export interface DataSourcesPage {} export interface DataSourcesPage {}
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
ClickablePageObject, ClickablePageObject,
PageObject, PageObject,
Selector, Selector,
} from '@grafana/toolkit'; } from '@grafana/toolkit/src/e2e';
export interface EditDataSourcePage { export interface EditDataSourcePage {
saveAndTest: ClickablePageObjectType; saveAndTest: ClickablePageObjectType;
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
Selector, Selector,
ClickablePageObjectType, ClickablePageObjectType,
ClickablePageObject, ClickablePageObject,
} from '@grafana/toolkit'; } from '@grafana/toolkit/src/e2e';
export interface EditPanelPage { export interface EditPanelPage {
queriesTab: ClickablePageObjectType; queriesTab: ClickablePageObjectType;
......
import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit'; import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit/src/e2e';
export interface Panel { export interface Panel {
panelTitle: ClickablePageObjectType; panelTitle: ClickablePageObjectType;
......
import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit'; import { TestPage, ClickablePageObjectType, ClickablePageObject, Selector } from '@grafana/toolkit/src/e2e';
export interface SharePanelModal { export interface SharePanelModal {
directLinkRenderedImage: ClickablePageObjectType; directLinkRenderedImage: ClickablePageObjectType;
......
import { Browser, Page, Target } from 'puppeteer-core'; import { Browser, Page, Target } from 'puppeteer-core';
import { e2eScenario, constants, takeScreenShot, compareScreenShots } from '@grafana/toolkit'; import { e2eScenario, constants, takeScreenShot, compareScreenShots } from '@grafana/toolkit/src/e2e';
import { addDataSourcePage } from 'e2e-test/pages/datasources/addDataSourcePage'; import { addDataSourcePage } from 'e2e-test/pages/datasources/addDataSourcePage';
import { editDataSourcePage } from 'e2e-test/pages/datasources/editDataSourcePage'; import { editDataSourcePage } from 'e2e-test/pages/datasources/editDataSourcePage';
import { dataSourcesPage } from 'e2e-test/pages/datasources/dataSources'; import { dataSourcesPage } from 'e2e-test/pages/datasources/dataSources';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment