|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + * |
| 8 | + * Any modifications Copyright OpenSearch Contributors. See |
| 9 | + * GitHub history for details. |
| 10 | + */ |
| 11 | + |
| 12 | +import url from 'url'; |
| 13 | +import expect from '@osd/expect'; |
| 14 | + |
| 15 | +const getPathWithHash = (absoluteUrl: string) => { |
| 16 | + const parsed = url.parse(absoluteUrl); |
| 17 | + return `${parsed.path}${parsed.hash ?? ''}`; |
| 18 | +}; |
| 19 | + |
| 20 | +export default function ({ getService, getPageObjects }) { |
| 21 | + const testSubjects = getService('testSubjects'); |
| 22 | + const PageObjects = getPageObjects(['common', 'dashboard']); |
| 23 | + const browser = getService('browser'); |
| 24 | + const listingTable = getService('listingTable'); |
| 25 | + const find = getService('find'); |
| 26 | + |
| 27 | + describe('dashboard listing plugin', function describeIndexTests() { |
| 28 | + const dashboardName = 'Dashboard Test'; |
| 29 | + |
| 30 | + before(async () => { |
| 31 | + await PageObjects.dashboard.initTests(); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should be able to navigate to create a dashboard', async () => { |
| 35 | + await testSubjects.click('createMenuDropdown'); |
| 36 | + await testSubjects.click('contextMenuItem-dashboard'); |
| 37 | + await PageObjects.dashboard.saveDashboard(dashboardName); |
| 38 | + |
| 39 | + await PageObjects.dashboard.gotoDashboardLandingPage(); |
| 40 | + await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 1); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should be able to navigate to view dashboard', async () => { |
| 44 | + await listingTable.clickItemLink('dashboard', dashboardName); |
| 45 | + await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); |
| 46 | + await PageObjects.dashboard.getIsInViewMode(); |
| 47 | + await PageObjects.dashboard.gotoDashboardLandingPage(); |
| 48 | + }); |
| 49 | + |
| 50 | + it('should be able to navigate to edit dashboard', async () => { |
| 51 | + await listingTable.searchForItemWithName(dashboardName); |
| 52 | + const editBttn = await find.allByCssSelector('.euiToolTipAnchor'); |
| 53 | + await editBttn.click(); |
| 54 | + await PageObjects.dashboard.clickCancelOutOfEditMode(); |
| 55 | + await PageObjects.dashboard.gotoDashboardLandingPage(); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should be able to navigate to create a test dashboard', async () => { |
| 59 | + await testSubjects.click('createMenuDropdown'); |
| 60 | + await testSubjects.click('contextMenuItem-dashboard_listing_test_plugin'); |
| 61 | + expect(getPathWithHash(await browser.getCurrentUrl())).to.eql( |
| 62 | + '/app/dashboard_listing_test_plugin#/create' |
| 63 | + ); |
| 64 | + }); |
| 65 | + }); |
| 66 | +} |
0 commit comments