|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +import expect from '@kbn/expect'; |
| 9 | +import type { FtrProviderContext } from '../../../ftr_provider_context'; |
| 10 | + |
| 11 | +export default function sharingFromSpace({ getPageObjects, getService }: FtrProviderContext) { |
| 12 | + const kibanaServer = getService('kibanaServer'); |
| 13 | + const spacesService = getService('spaces'); |
| 14 | + const browser = getService('browser'); |
| 15 | + const testSubjects = getService('testSubjects'); |
| 16 | + const { dashboard, common, share, security, spaceSelector } = getPageObjects([ |
| 17 | + 'dashboard', |
| 18 | + 'common', |
| 19 | + 'share', |
| 20 | + 'security', |
| 21 | + 'spaceSelector', |
| 22 | + ]); |
| 23 | + |
| 24 | + const spaceId = 'another-space'; |
| 25 | + |
| 26 | + describe('Dashboard Custom Space share', () => { |
| 27 | + before(async () => { |
| 28 | + await kibanaServer.savedObjects.cleanStandardList(); |
| 29 | + |
| 30 | + await spacesService.create({ |
| 31 | + id: spaceId, |
| 32 | + name: 'Another Space', |
| 33 | + disabledFeatures: [], |
| 34 | + }); |
| 35 | + |
| 36 | + await kibanaServer.importExport.load( |
| 37 | + 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana', |
| 38 | + { |
| 39 | + space: spaceId, |
| 40 | + } |
| 41 | + ); |
| 42 | + |
| 43 | + await kibanaServer.uiSettings.replace({ |
| 44 | + defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', |
| 45 | + }); |
| 46 | + |
| 47 | + await security.forceLogout(); |
| 48 | + |
| 49 | + await security.login(undefined, undefined, { |
| 50 | + expectSpaceSelector: true, |
| 51 | + }); |
| 52 | + |
| 53 | + await spaceSelector.clickSpaceCard(spaceId); |
| 54 | + |
| 55 | + await common.navigateToApp('dashboard', { basePath: `/s/${spaceId}` }); |
| 56 | + await dashboard.preserveCrossAppState(); |
| 57 | + await dashboard.loadSavedDashboard('few panels'); |
| 58 | + await dashboard.switchToEditMode(); |
| 59 | + await dashboard.waitForRenderComplete(); |
| 60 | + }); |
| 61 | + |
| 62 | + after(async () => { |
| 63 | + await security.forceLogout(); |
| 64 | + |
| 65 | + await kibanaServer.importExport.unload( |
| 66 | + 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana', |
| 67 | + { |
| 68 | + space: spaceId, |
| 69 | + } |
| 70 | + ); |
| 71 | + await spacesService.delete(spaceId); |
| 72 | + await kibanaServer.savedObjects.cleanStandardList(); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should copy the dashboard url', async () => { |
| 76 | + await share.clickShareTopNavButton(); |
| 77 | + // This is required because the default position causes clicking on permalinks, to display a tooltip that blocks the click |
| 78 | + await browser |
| 79 | + .getActions() |
| 80 | + .move({ |
| 81 | + origin: (await testSubjects.find('sharePanel-Permalinks'))._webElement, |
| 82 | + x: -20, |
| 83 | + y: 0, |
| 84 | + }) |
| 85 | + .perform(); |
| 86 | + await share.checkShortenUrl(); |
| 87 | + const shareUrl = await share.getSharedUrl(); |
| 88 | + expect(shareUrl).to.contain(`/s/${spaceId}/`); |
| 89 | + }); |
| 90 | + }); |
| 91 | +} |
0 commit comments