kibana/x-pack/plugins/canvas/server/feature.test.ts
Tim Sullivan 5a6eda2b22
[Reporting] Kibana Application Privileges for Reporting (#94966)
* Implement Reporting features as subfeatures of applications

* add setting to the docker list

* update doc images

* finish docs

* Apply suggestions from code review

Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>

* Apply suggestions from code review

Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>

* Apply suggestions from code review

Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>

* typo fix

* "PDF / PNG Reports" => "Reporting"

* Update x-pack/plugins/reporting/server/config/index.ts

Co-authored-by: Larry Gregory <lgregorydev@gmail.com>

* Update x-pack/test/functional/apps/security/secure_roles_perm.js

Co-authored-by: Larry Gregory <lgregorydev@gmail.com>

* update ids of report privileges

* combine dashboard privileges into 1 group

* update jest snapshot

* fix tests

* fix tests

* updates from feedback

* add note

* update screenshot

* fix grammer

* fix bad link breaks in doc

* update doc heading

* Apply suggestions documentation feedback

Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>

* simplify

* use const assertions

* Apply text change suggestion from code review

Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>

* more test for oss_features and reporting subFeatures

* reduce loc diff

* fix snapshot

* fix flakiness in licensing plugin public functional tests

Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>
Co-authored-by: Larry Gregory <lgregorydev@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>
2021-04-20 20:44:24 -07:00

194 lines
4.6 KiB
TypeScript

/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { ReportingStart } from '../../reporting/server/types';
import { getCanvasFeature } from './feature';
let mockReportingPlugin: ReportingStart;
beforeEach(() => {
mockReportingPlugin = {
usesUiCapabilities: () => false,
};
});
it('Provides a feature declaration ', () => {
expect(getCanvasFeature({ reporting: mockReportingPlugin })).toMatchInlineSnapshot(`
Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"category": Object {
"euiIconType": "logoKibana",
"id": "kibana",
"label": "Analytics",
"order": 1000,
},
"id": "canvas",
"management": Object {},
"name": "Canvas",
"order": 300,
"privileges": Object {
"all": Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"savedObject": Object {
"all": Array [
"canvas-workpad",
"canvas-element",
],
"read": Array [
"index-pattern",
],
},
"ui": Array [
"save",
"show",
],
},
"read": Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"savedObject": Object {
"all": Array [],
"read": Array [
"index-pattern",
"canvas-workpad",
"canvas-element",
],
},
"ui": Array [
"show",
],
},
},
"subFeatures": Array [],
}
`);
});
it(`Calls on Reporting whether to include Generate PDF as a sub-feature`, () => {
mockReportingPlugin = {
usesUiCapabilities: () => true,
};
expect(getCanvasFeature({ reporting: mockReportingPlugin })).toMatchInlineSnapshot(`
Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"category": Object {
"euiIconType": "logoKibana",
"id": "kibana",
"label": "Analytics",
"order": 1000,
},
"id": "canvas",
"management": Object {
"insightsAndAlerting": Array [
"reporting",
],
},
"name": "Canvas",
"order": 300,
"privileges": Object {
"all": Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"savedObject": Object {
"all": Array [
"canvas-workpad",
"canvas-element",
],
"read": Array [
"index-pattern",
],
},
"ui": Array [
"save",
"show",
],
},
"read": Object {
"app": Array [
"canvas",
"kibana",
],
"catalogue": Array [
"canvas",
],
"savedObject": Object {
"all": Array [],
"read": Array [
"index-pattern",
"canvas-workpad",
"canvas-element",
],
},
"ui": Array [
"show",
],
},
},
"subFeatures": Array [
Object {
"name": "Reporting",
"privilegeGroups": Array [
Object {
"groupType": "independent",
"privileges": Array [
Object {
"api": Array [
"generateReport",
],
"id": "generate_report",
"includeIn": "all",
"management": Object {
"insightsAndAlerting": Array [
"reporting",
],
},
"minimumLicense": "platinum",
"name": "Generate PDF reports",
"savedObject": Object {
"all": Array [],
"read": Array [],
},
"ui": Array [
"generatePdf",
],
},
],
},
],
},
],
}
`);
});