Skip to content

Commit

Permalink
[feature][Canvas] Share Workpads in other Websites (elastic#46278)
Browse files Browse the repository at this point in the history
* [Canvas] Embedding Workpads in other Websites (elastic#42545)

* Testing for Workpad Snapshots

* Rename Snapshots to Shareables; update documentation. (elastic#46513)

* [canvas][shareables] Add Localization + Tweaks (elastic#46632)

* Add localization + tweak naming

* Fix duplicate key

* Update storyshots

* [shareables] Unsupported Renderer Warning (elastic#46862)

* [shareables] Unsupported Renderer Warning

* Update snapshots; add test

* Addressing Feedback

* [canvas][shareables] Simplify and complete testing (elastic#47328)

* Simplify

* Updates

* Finishing up

* A few tweaks

* Fix eslint errors; how would those happen??

* Fix CI build of runtime; assorted visual tweaks

* Update x-pack/legacy/plugins/canvas/shareable_runtime/test/index.ts

Co-Authored-By: Spencer <[email protected]>

* Addressing feedback

* Remove null-loader from root package

* re-add null-loader until mitigation is found

* [perf] Fix unsupported renderers performance issue (elastic#47769)

* [perf] Fix perf issue with unsupported renderers

* Fixing snapshots

* Addressing review feedback (elastic#47775)

* Addressing feedback

* Addressing feedback (elastic#47883)

* Branding Changes (elastic#47913)

* Branding Changes

* Update snapshots
  • Loading branch information
clintandrewhall committed Oct 11, 2019
1 parent 6f7814b commit 05ed9c1
Show file tree
Hide file tree
Showing 121 changed files with 46,883 additions and 188 deletions.
2 changes: 2 additions & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ files:
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
ignore:
- 'x-pack/legacy/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/lens/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/maps/**/*.s+(a|c)ss'
rules:
Expand Down
8 changes: 8 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@
'@types/zen-observable',
],
},
{
groupSlug: 'archiver',
groupName: 'archiver related packages',
packageNames: [
'archiver',
'@types/archiver',
],
},
{
groupSlug: 'base64-js',
groupName: 'base64-js related packages',
Expand Down
14 changes: 9 additions & 5 deletions src/dev/build/build_distributables.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function buildDistributables(options) {
const config = await getConfig({
isRelease,
versionQualifier,
targetAllPlatforms
targetAllPlatforms,
});

const run = createRunner({
Expand Down Expand Up @@ -143,16 +143,20 @@ export async function buildDistributables(options) {
* package platform-specific builds into archives
* or os-specific packages in the target directory
*/
if (createArchives) { // control w/ --skip-archives
if (createArchives) {
// control w/ --skip-archives
await run(CreateArchivesTask);
}
if (createDebPackage) { // control w/ --deb or --skip-os-packages
if (createDebPackage) {
// control w/ --deb or --skip-os-packages
await run(CreateDebPackageTask);
}
if (createRpmPackage) { // control w/ --rpm or --skip-os-packages
if (createRpmPackage) {
// control w/ --rpm or --skip-os-packages
await run(CreateRpmPackageTask);
}
if (createDockerPackage) { // control w/ --docker or --skip-os-packages
if (createDockerPackage) {
// control w/ --docker or --skip-os-packages
await run(CreateDockerPackageTask);
}

Expand Down
114 changes: 58 additions & 56 deletions src/dev/build/tasks/clean_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,36 @@ export const CleanTask = {
description: 'Cleaning artifacts from previous builds',

async run(config, log) {
await deleteAll([
config.resolveFromRepo('build'),
config.resolveFromRepo('target'),
config.resolveFromRepo('.node_binaries'),
], log);
await deleteAll(
[
config.resolveFromRepo('build'),
config.resolveFromRepo('target'),
config.resolveFromRepo('.node_binaries'),
],
log
);
},
};

export const CleanPackagesTask = {
description:
'Cleaning source for packages that are now installed in node_modules',
description: 'Cleaning source for packages that are now installed in node_modules',

async run(config, log, build) {
await deleteAll([
build.resolvePath('packages'),
build.resolvePath('yarn.lock'),
], log);
await deleteAll([build.resolvePath('packages'), build.resolvePath('yarn.lock')], log);
},
};


export const CleanTypescriptTask = {
description:
'Cleaning typescript source files that have been transpiled to JS',
description: 'Cleaning typescript source files that have been transpiled to JS',

async run(config, log, build) {
log.info('Deleted %d files', await scanDelete({
directory: build.resolvePath(),
regularExpressions: [
/\.(ts|tsx|d\.ts)$/,
/tsconfig.*\.json$/
]
}));
log.info(
'Deleted %d files',
await scanDelete({
directory: build.resolvePath(),
regularExpressions: [/\.(ts|tsx|d\.ts)$/, /tsconfig.*\.json$/],
})
);
},
};

Expand All @@ -70,9 +67,7 @@ export const CleanExtraFilesFromModulesTask = {

async run(config, log, build) {
const makeRegexps = patterns =>
patterns.map(pattern =>
minimatch.makeRe(pattern, { nocase: true })
);
patterns.map(pattern => minimatch.makeRe(pattern, { nocase: true }));

const regularExpressions = makeRegexps([
// tests
Expand Down Expand Up @@ -169,19 +164,23 @@ export const CleanExtraFilesFromModulesTask = {
'**/docker-compose.yml',
]);

log.info('Deleted %d files', await scanDelete({
directory: build.resolvePath('node_modules'),
regularExpressions,
excludePaths: [
build.resolvePath('node_modules/@elastic/ctags-langserver/vendor')
]
}));
log.info(
'Deleted %d files',
await scanDelete({
directory: build.resolvePath('node_modules'),
regularExpressions,
excludePaths: [build.resolvePath('node_modules/@elastic/ctags-langserver/vendor')],
})
);

if (!build.isOss()) {
log.info('Deleted %d files', await scanDelete({
directory: build.resolvePath('x-pack/node_modules'),
regularExpressions
}));
log.info(
'Deleted %d files',
await scanDelete({
directory: build.resolvePath('x-pack/node_modules'),
regularExpressions,
})
);
}
},
};
Expand All @@ -192,14 +191,15 @@ export const CleanExtraBinScriptsTask = {
async run(config, log, build) {
for (const platform of config.getNodePlatforms()) {
if (platform.isWindows()) {
await deleteAll([
build.resolvePathForPlatform(platform, 'bin', '*'),
`!${build.resolvePathForPlatform(platform, 'bin', '*.bat')}`,
], log);
await deleteAll(
[
build.resolvePathForPlatform(platform, 'bin', '*'),
`!${build.resolvePathForPlatform(platform, 'bin', '*.bat')}`,
],
log
);
} else {
await deleteAll([
build.resolvePathForPlatform(platform, 'bin', '*.bat'),
], log);
await deleteAll([build.resolvePathForPlatform(platform, 'bin', '*.bat')], log);
}
}
},
Expand Down Expand Up @@ -251,22 +251,18 @@ export const CleanEmptyFoldersTask = {
// Delete every single empty folder from
// the distributable except the plugins
// and data folder.
await deleteEmptyFolders(
log,
build.resolvePath('.'),
[
build.resolvePath('plugins'),
build.resolvePath('data')
]
);
await deleteEmptyFolders(log, build.resolvePath('.'), [
build.resolvePath('plugins'),
build.resolvePath('data'),
]);
},
};

export const CleanCtagBuildTask = {
description: 'Cleaning extra platform-specific files from @elastic/node-ctag build dir',

async run(config, log, build) {
const getPlatformId = (platform) => {
const getPlatformId = platform => {
if (platform.isWindows()) {
return 'win32';
} else if (platform.isLinux()) {
Expand All @@ -283,11 +279,17 @@ export const CleanCtagBuildTask = {
}

const ctagsBuildDir = build.resolvePathForPlatform(platform, RELATIVE_CTAGS_BUILD_DIR);
await deleteAll([
resolve(ctagsBuildDir, '*'),
`!${resolve(ctagsBuildDir, `ctags-node-v${process.versions.modules}-${getPlatformId(platform)}-x64`)}`
], log);
await deleteAll(
[
resolve(ctagsBuildDir, '*'),
`!${resolve(
ctagsBuildDir,
`ctags-node-v${process.versions.modules}-${getPlatformId(platform)}-x64`
)}`,
],
log
);
})
);
}
},
};
36 changes: 36 additions & 0 deletions src/dev/jest/mocks/css_module_mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* This proxy allows for CSS Modules to be interpreted properly by
* Jest. Given a CSS Module class `thisClass`, we'd expect it to
* be obfuscated at runtime. With this mock, `thisClass` will be
* returned. This allows for consistent enzyme and snapshot tests.
*/
module.exports = new Proxy(
{},
{
get: function getter(target, key) {
if (key === '__esModule') {
return false;
}
return key;
},
}
);
4 changes: 3 additions & 1 deletion x-pack/.kibana-plugin-helpers.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"!legacy/plugins/**/*.test.{js,ts}",
"!legacy/plugins/**/__snapshots__",
"!legacy/plugins/**/__snapshots__/*",
"!legacy/plugins/**/__mocks__/*"
"!legacy/plugins/**/__mocks__/*",
"!legacy/plugins/canvas/shareable_runtime/test",
"!legacy/plugins/canvas/shareable_runtime/test/**/*"
],
"skipInstallDependencies": true
}
5 changes: 2 additions & 3 deletions x-pack/dev-tools/jest/create_jest_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export function createJestConfig({ kibanaDirectory, xPackKibanaDirectory }) {
'^plugins/([^/.]*)(.*)': `${kibanaDirectory}/src/legacy/core_plugins/$1/public$2`,
'^plugins/xpack_main/(.*);': `${xPackKibanaDirectory}/legacy/plugins/xpack_main/public/$1`,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': fileMockPath,
'\\.module.(css|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/css_module_mock.js`,
'\\.(css|less|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`,
'^test_utils/enzyme_helpers': `${xPackKibanaDirectory}/test_utils/enzyme_helpers.tsx`,
'^test_utils/find_test_subject': `${xPackKibanaDirectory}/test_utils/find_test_subject.ts`,
},
coverageDirectory: '<rootDir>/../target/kibana-coverage/jest',
coverageReporters: [
'html',
],
coverageReporters: ['html'],
setupFiles: [
`${kibanaDirectory}/src/dev/jest/setup/babel_polyfill.js`,
`<rootDir>/dev-tools/jest/setup/polyfills.js`,
Expand Down
18 changes: 18 additions & 0 deletions x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-story
import styleSheetSerializer from 'jest-styled-components/src/styleSheetSerializer';
import { addSerializer } from 'jest-specific-snapshot';

// Several of the renderers, used by the runtime, use jQuery.
import jquery from 'jquery';
global.$ = jquery;
global.jQuery = jquery;

// Set our default timezone to UTC for tests so we can generate predictable snapshots
moment.tz.setDefault('UTC');

Expand Down Expand Up @@ -53,6 +58,19 @@ jest.mock(
}
);

// Disabling this test due to https://github.com/elastic/eui/issues/2242
jest.mock(
'../public/components/workpad_header/workpad_export/flyout/__examples__/share_website_flyout.examples',
() => {
return 'Disabled Panel';
}
);

// This element uses a `ref` and cannot be rendered by Jest snapshots.
import { RenderedElement } from '../shareable_runtime/components/rendered_element';
jest.mock('../shareable_runtime/components/rendered_element');
RenderedElement.mockImplementation(() => 'RenderedElement');

addSerializer(styleSheetSerializer);

// Initialize Storyshots and build the Jest Snapshots
Expand Down
Loading

0 comments on commit 05ed9c1

Please sign in to comment.