From 20f4ba99c779003f338306c6b9a1f4a022ca70ae Mon Sep 17 00:00:00 2001 From: Qxisylolo Date: Fri, 1 Nov 2024 16:48:02 +0800 Subject: [PATCH] add new test Signed-off-by: Qxisylolo --- config/opensearch_dashboards.yml | 34 ++++++++++++------- package.json | 2 +- .../saved_objects_table.test.tsx.snap | 16 ++++++--- .../saved_objects_table.test.tsx | 17 ++++++++-- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/config/opensearch_dashboards.yml b/config/opensearch_dashboards.yml index 69a57caac33e..e6d73ad27be1 100644 --- a/config/opensearch_dashboards.yml +++ b/config/opensearch_dashboards.yml @@ -23,8 +23,25 @@ #server.name: "your-hostname" # The URLs of the OpenSearch instances to use for all your queries. -#opensearch.hosts: ["http://localhost:9200"] - +savedObjects.permission.enabled: true +server.host: '0.0.0.0' +opensearch.hosts: ['https://localhost:9200'] +opensearch.ssl.verificationMode: none +opensearch.username: 'admin' +opensearch.password: 'myStrongPassword123!' +opensearch.requestHeadersWhitelist: [authorization, securitytenant] +# opensearch_security.multitenancy.enabled: false +# opensearch_security.multitenancy.tenants.preferred: ['Private', 'Global'] +# opensearch_security.readonly_mode.roles: ['kibana_read_only'] +# opensearch_security.cookie.secure: false +workspace.enabled: true +opensearch.ignoreVersionMismatch: true +opensearchDashboards.dashboardAdmin.users: ['admin'] +data_source.enabled: true +uiSettings: + overrides: + 'home:useNewHomePage': true +# assistant.chat.enabled: true # OpenSearch Dashboards uses an index in OpenSearch to store saved searches, visualizations and # dashboards. OpenSearch Dashboards creates a new index if the index doesn't already exist. #opensearchDashboards.index: ".opensearch_dashboards" @@ -325,7 +342,7 @@ # "none": The data source is readonly for all users. # "dashboard_admin": The data source can only be managed by dashboard admin. # "all": The data source can be managed by all users. Default to "all". -# data_source_management.manageableBy: "all" +# data_source.manageableBy: "all" # Set the backend roles in groups, whoever has the backend roles defined in this config will be regard as dataSourceAdmin. # DataSource Admin will have the access to all the data source saved objects inside OpenSearch Dashboards by api. @@ -363,15 +380,8 @@ # This publishes the Application Usage and UI Metrics into the saved object, which can be accessed by /api/stats?extended=true&legacy=true&exclude_usage=false # usageCollection.uiMetric.enabled: false -# Set the value to true to enable enhancements for the data plugin -# data.enhancements.enabled: false - -# Set the value to true to enable dynamic config service to obtain configs from a config store. By default, it's disabled -# dynamic_config_service.enabled: false - # Set the backend roles in groups or users, whoever has the backend roles or exactly match the user ids defined in this config will be regard as dashboard admin. # Dashboard admin will have the access to all the workspaces(workspace.enabled: true) and objects inside OpenSearch Dashboards. -# The default config is [], and no one will be dashboard admin. -# If the user config is set to wildcard ["*"], anyone will be dashboard admin. # opensearchDashboards.dashboardAdmin.groups: ["dashboard_admin"] -# opensearchDashboards.dashboardAdmin.users: ["dashboard_admin"] +# opensearchDashboards.dashboardAdmin.users: ['dashboard_admin'] +# opensearchDashboards.dashboardAdmin.users: ['a'] set user is not admin diff --git a/package.json b/package.json index b7dcbb23569e..3f504d5cc3e6 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dashboarding" ], "private": true, - "version": "3.0.0", + "version": "2.15.0", "branch": "main", "types": "./opensearch_dashboards.d.ts", "tsdocMetadata": "./build/tsdoc-metadata.json", diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap index 53e1cd2431f1..6bb452ca3986 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SavedObjectsTable delete should show a confirm modal 1`] = ` +exports[`SavedObjectsTable delete should show a confirm modal with correct icons and tooltips 1`] = ` `; -exports[`SavedObjectsTable delete should show a confirm modal 2`] = ` +exports[`SavedObjectsTable delete should show a confirm modal with correct icons and tooltips 2`] = ` `; -exports[`SavedObjectsTable delete should show a confirm modal 3`] = ` +exports[`SavedObjectsTable delete should show a confirm modal with correct icons and tooltips 3`] = ` `; -exports[`SavedObjectsTable delete should show a confirm modal 4`] = `null`; +exports[`SavedObjectsTable delete should show a confirm modal with correct icons and tooltips 4`] = `null`; exports[`SavedObjectsTable delete should show error toast when failing to delete saved objects 1`] = ` { }); describe('delete', () => { - it('should show a confirm modal', async () => { + it('should show a confirm modal with correct icons and tooltips', async () => { const component = shallowRender(); const mockSelectedSavedObjects = [ - { id: '1', type: 'index-pattern' }, - { id: '3', type: 'dashboard' }, + { id: '1', type: 'config', meta: { icon: 'configApp' } }, + { id: '3', type: 'dashboard', meta: { icon: 'dashboardApp' } }, ] as SavedObjectWithMetadata[]; // Ensure all promises resolve @@ -590,6 +590,17 @@ describe('SavedObjectsTable', () => { expect(component.find('EuiModalHeader')).toMatchSnapshot(); expect(component.find('EuiModalFooter')).toMatchSnapshot(); expect(component.find('Delete assets')).toMatchSnapshot(); + + const table = component.find('EuiInMemoryTable'); + const columns = table.prop('columns'); + + const typeField = columns.find((col) => col.field === 'type'); + mockSelectedSavedObjects.forEach((savedObject) => { + const renderedContent = typeField.render(savedObject.type, savedObject); + expect(renderedContent.props.content).toBe(savedObject.type); + const iconElement = renderedContent.props.children; + expect(iconElement.props.type).toBe(savedObject.meta.icon || 'apps'); + }); }); it('should delete selected objects', async () => {