-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[EuiProvider / Functional tests] Check for EuiProvider Dev Warning #189018
Merged
tsullivan
merged 17 commits into
elastic:main
from
tsullivan:eui-provider/fn-tests-detection
Aug 26, 2024
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0b743c9
Functional test navigate method check for EuiProvider non-compliance
tsullivan fa415c4
restrict to navigateToApp
tsullivan 11f0430
plugin functional app and functional test
tsullivan 2e2862d
Functional test measure to detect EUI Provider dev warning
tsullivan 9436a6d
[CI] Auto-commit changed files from 'node scripts/lint_packages --fix'
kibanamachine 888672f
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine 1a5868f
comment to state the intention of the post-test hook
tsullivan 3d43cc0
add lifecycle.afterTestSuite
tsullivan df68d12
move error check to remote.ts
tsullivan c9d5087
use try/catch around reading session storage
tsullivan e27b1cf
ensure hook will catch error
tsullivan 540d733
Revert "ensure hook will catch error"
tsullivan a5ec727
Add documentation note
tsullivan 8d675a6
use a single key for error message using serialized json
tsullivan 16a7d89
move test cleanup to "after"
tsullivan 2beceab
Merge branch 'main' into eui-provider/fn-tests-detection
tsullivan 917b068
Merge branch 'main' into eui-provider/fn-tests-detection
tsullivan 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
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
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" | ||
] | ||
} |
37 changes: 37 additions & 0 deletions
37
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,37 @@ | ||
/* | ||
* 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 () => { | ||
await PageObjects.common.navigateToApp('euiProviderDevWarning'); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
expect(await browser.getTitle()).eql('EuiProvider test - Elastic'); | ||
await testSubjects.existOrFail('core-chrome-euiDevProviderWarning-toast'); | ||
|
||
expect( | ||
await browser.getSessionStorageItem('dev.euiProviderWarning.message') | ||
).to.not.be.empty(); | ||
|
||
// clean up to ensure test suite will pass | ||
await Promise.all([ | ||
browser.removeSessionStorageItem('dev.euiProviderWarning.message'), | ||
browser.removeSessionStorageItem('dev.euiProviderWarning.stack'), | ||
browser.removeSessionStorageItem('dev.euiProviderWarning.pageHref'), | ||
browser.removeSessionStorageItem('dev.euiProviderWarning.pageTitle'), | ||
]); | ||
}); | ||
}); | ||
} |
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
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.
tiny nit: I'd put all of this under a single key as a serialized json since they are part of the same state
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.
Good point. I have pushed 8d675a6