forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiProvider / Functional tests] Check for EuiProvider Dev Warning (e…
…lastic#189018) ## Summary Follows elastic#184608 Closes elastic/kibana-team#805 ![image](https://github.com/user-attachments/assets/eaee5b81-c1e9-4e81-9018-db57652236dc) --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
486df8c
commit dc7e3ec
Showing
17 changed files
with
274 additions
and
2 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
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
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
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
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
13 changes: 13 additions & 0 deletions
13
test/plugin_functional/plugins/eui_provider_dev_warning/kibana.jsonc
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,13 @@ | ||
{ | ||
"type": "plugin", | ||
"id": "@kbn/eui-provider-dev-warning", | ||
"owner": "@elastic/appex-sharedux", | ||
"plugin": { | ||
"id": "euiProviderDevWarning", | ||
"server": false, | ||
"browser": true, | ||
"configPath": [ | ||
"eui_provider_dev_warning" | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/plugin_functional/plugins/eui_provider_dev_warning/package.json
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,14 @@ | ||
{ | ||
"name": "@kbn/eui-provider-dev-warning", | ||
"version": "1.0.0", | ||
"main": "target/test/plugin_functional/plugins/eui_provider_dev_warning", | ||
"kibana": { | ||
"version": "kibana", | ||
"templateVersion": "1.0.0" | ||
}, | ||
"license": "SSPL-1.0 OR Elastic License 2.0", | ||
"scripts": { | ||
"kbn": "node ../../../../scripts/kbn.js", | ||
"build": "rm -rf './target' && ../../../../node_modules/.bin/tsc" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
test/plugin_functional/plugins/eui_provider_dev_warning/public/application.tsx
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,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiPageTemplate, EuiTitle, EuiText } from '@elastic/eui'; | ||
import ReactDOM from 'react-dom'; | ||
import { AppMountParameters, CoreStart } from '@kbn/core/public'; | ||
|
||
export const renderApp = (_core: CoreStart, { element }: AppMountParameters) => { | ||
ReactDOM.render( | ||
<EuiPageTemplate restrictWidth="1000px"> | ||
<EuiPageTemplate.Header> | ||
<EuiTitle size="l"> | ||
<h1>EuiProvider is missing</h1> | ||
</EuiTitle> | ||
</EuiPageTemplate.Header> | ||
<EuiPageTemplate.Section> | ||
<EuiTitle> | ||
<h2>Goal of this page</h2> | ||
</EuiTitle> | ||
<EuiText> | ||
<p> | ||
The goal of this page is to create a UI that attempts to render EUI React components | ||
without wrapping the rendering tree in EuiProvider. | ||
</p> | ||
</EuiText> | ||
</EuiPageTemplate.Section> | ||
</EuiPageTemplate>, | ||
element | ||
); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
13 changes: 13 additions & 0 deletions
13
test/plugin_functional/plugins/eui_provider_dev_warning/public/index.ts
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,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { EuiProviderDevWarningPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new EuiProviderDevWarningPlugin(); | ||
} |
35 changes: 35 additions & 0 deletions
35
test/plugin_functional/plugins/eui_provider_dev_warning/public/plugin.ts
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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { AppMountParameters, CoreSetup, Plugin } from '@kbn/core/public'; | ||
|
||
export class EuiProviderDevWarningPlugin | ||
implements Plugin<EuiProviderDevWarningPluginSetup, EuiProviderDevWarningPluginStart> | ||
{ | ||
public setup(core: CoreSetup) { | ||
core.application.register({ | ||
id: 'euiProviderDevWarning', | ||
title: 'EUI Provider Dev Warning', | ||
async mount(params: AppMountParameters) { | ||
const { renderApp } = await import('./application'); | ||
const [coreStart] = await core.getStartServices(); | ||
coreStart.chrome.docTitle.change('EuiProvider test'); | ||
return renderApp(coreStart, params); | ||
}, | ||
}); | ||
|
||
// Return methods that should be available to other plugins | ||
return {}; | ||
} | ||
|
||
public start() {} | ||
public stop() {} | ||
} | ||
|
||
export type EuiProviderDevWarningPluginSetup = ReturnType<EuiProviderDevWarningPlugin['setup']>; | ||
export type EuiProviderDevWarningPluginStart = ReturnType<EuiProviderDevWarningPlugin['start']>; |
18 changes: 18 additions & 0 deletions
18
test/plugin_functional/plugins/eui_provider_dev_warning/tsconfig.json
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 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types" | ||
}, | ||
"include": [ | ||
"index.ts", | ||
"public/**/*.ts", | ||
"public/**/*.tsx", | ||
"../../../../typings/**/*" | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [ | ||
"@kbn/core" | ||
] | ||
} |
45 changes: 45 additions & 0 deletions
45
test/plugin_functional/test_suites/shared_ux/eui_provider.ts
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,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { PluginFunctionalProviderContext } from '../../services'; | ||
|
||
export default function ({ getPageObjects, getService }: PluginFunctionalProviderContext) { | ||
const PageObjects = getPageObjects(['common', 'header']); | ||
const testSubjects = getService('testSubjects'); | ||
const browser = getService('browser'); | ||
|
||
describe('EUI Provider Dev Warning', () => { | ||
it('shows error toast to developer', async () => { | ||
const pageTitle = 'EuiProvider test - Elastic'; | ||
|
||
await PageObjects.common.navigateToApp('euiProviderDevWarning'); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
expect(await browser.getTitle()).eql(pageTitle); | ||
await testSubjects.existOrFail('core-chrome-euiDevProviderWarning-toast'); | ||
|
||
// check that the error has been detected and stored in session storage | ||
const euiProviderWarning = await browser.getSessionStorageItem('dev.euiProviderWarning'); | ||
const { | ||
message: errorMessage, | ||
stack: errorStack, | ||
pageHref: errorPageHref, | ||
pageTitle: errorPageTitle, | ||
} = JSON.parse(euiProviderWarning!); | ||
expect(errorMessage).to.not.be.empty(); | ||
expect(errorStack).to.not.be.empty(); | ||
expect(errorPageHref).to.not.be.empty(); | ||
expect(errorPageTitle).to.be(pageTitle); | ||
}); | ||
|
||
after(async () => { | ||
// clean up to ensure test suite will pass | ||
await browser.removeSessionStorageItem('dev.euiProviderWarning'); | ||
}); | ||
}); | ||
} |
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,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { PluginFunctionalProviderContext } from '../../services'; | ||
|
||
export default function ({ loadTestFile }: PluginFunctionalProviderContext) { | ||
describe('SharedUX', () => { | ||
loadTestFile(require.resolve('./eui_provider')); | ||
}); | ||
} |
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
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