Skip to content

Commit

Permalink
Accept api changes, fix functional tests by confirming on app leave w…
Browse files Browse the repository at this point in the history
…arning
  • Loading branch information
ThomThomson committed Dec 17, 2020
1 parent 0e97eee commit 85f2d43
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Constructs a new instance of the `EmbeddableStateTransfer` class
<b>Signature:</b>

```typescript
constructor(navigateToApp: ApplicationStart['navigateToApp'], appList?: ReadonlyMap<string, PublicAppInfo> | undefined, customStorage?: Storage);
constructor(navigateToApp: ApplicationStart['navigateToApp'], currentAppId$: ApplicationStart['currentAppId$'], appList?: ReadonlyMap<string, PublicAppInfo> | undefined, customStorage?: Storage);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| navigateToApp | <code>ApplicationStart['navigateToApp']</code> | |
| currentAppId$ | <code>ApplicationStart['currentAppId$']</code> | |
| appList | <code>ReadonlyMap&lt;string, PublicAppInfo&gt; &#124; undefined</code> | |
| customStorage | <code>Storage</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-embeddable-public](./kibana-plugin-plugins-embeddable-public.md) &gt; [EmbeddableStateTransfer](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.md) &gt; [isTransferInProgress](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.istransferinprogress.md)

## EmbeddableStateTransfer.isTransferInProgress property

<b>Signature:</b>

```typescript
isTransferInProgress: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ export declare class EmbeddableStateTransfer

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(navigateToApp, appList, customStorage)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer._constructor_.md) | | Constructs a new instance of the <code>EmbeddableStateTransfer</code> class |
| [(constructor)(navigateToApp, currentAppId$, appList, customStorage)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer._constructor_.md) | | Constructs a new instance of the <code>EmbeddableStateTransfer</code> class |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [getAppNameFromId](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getappnamefromid.md) | | <code>(appId: string) =&gt; string &#124; undefined</code> | Fetches an internationalized app title when given an appId. |
| [isTransferInProgress](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.istransferinprogress.md) | | <code>boolean</code> | |

## Methods

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/embeddable/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,14 @@ export interface EmbeddableStartDependencies {
export class EmbeddableStateTransfer {
// Warning: (ae-forgotten-export) The symbol "ApplicationStart" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PublicAppInfo" needs to be exported by the entry point index.d.ts
constructor(navigateToApp: ApplicationStart['navigateToApp'], appList?: ReadonlyMap<string, PublicAppInfo> | undefined, customStorage?: Storage);
constructor(navigateToApp: ApplicationStart['navigateToApp'], currentAppId$: ApplicationStart['currentAppId$'], appList?: ReadonlyMap<string, PublicAppInfo> | undefined, customStorage?: Storage);
// (undocumented)
clearEditorState(): void;
getAppNameFromId: (appId: string) => string | undefined;
getIncomingEditorState(removeAfterFetch?: boolean): EmbeddableEditorState | undefined;
getIncomingEmbeddablePackage(removeAfterFetch?: boolean): EmbeddablePackageState | undefined;
// (undocumented)
isTransferInProgress: boolean;
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ApplicationStart"
navigateToEditor(appId: string, options?: {
path?: string;
Expand Down
6 changes: 3 additions & 3 deletions test/common/services/security/test_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ export async function createTestUserService(
});

if (browser && testSubjects && shouldRefreshBrowser) {
// accept alert if it pops up
const alert = await browser.getAlert();
await alert?.accept();
if (await testSubjects.exists('kibanaChrome', { allowHidden: true })) {
await browser.refresh();
// accept alert if it pops up
const alert = await browser.getAlert();
await alert?.accept();
await testSubjects.find('kibanaChrome', config.get('timeouts.find') * 10);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }) {
});

it('saves the saved visualization url to the app link', async () => {
await PageObjects.header.clickVisualize();
await PageObjects.header.clickVisualize(true);
const currentUrl = await browser.getCurrentUrl();
expect(currentUrl).to.contain(VisualizeConstants.EDIT_PATH);
});
Expand Down
6 changes: 6 additions & 0 deletions test/functional/apps/dashboard/dashboard_time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default function ({ getService, getPageObjects }) {
after(async () => {
await kibanaServer.uiSettings.replace({});
await browser.refresh();
const alert = await browser.getAlert();
await alert?.accept();
});

it('Visualization updated when time picker changes', async () => {
Expand Down Expand Up @@ -86,6 +88,8 @@ export default function ({ getService, getPageObjects }) {
`)`;
log.debug('go to url' + `${kibanaBaseUrl}#${urlQuery}`);
await browser.get(`${kibanaBaseUrl}#${urlQuery}`, true);
const alert = await browser.getAlert();
await alert?.accept();
await PageObjects.header.waitUntilLoadingHasFinished();
const time = await PageObjects.timePicker.getTimeConfig();
const refresh = await PageObjects.timePicker.getRefreshConfig();
Expand All @@ -97,6 +101,8 @@ export default function ({ getService, getPageObjects }) {
it('Timepicker respects dateFormat from UI settings', async () => {
await kibanaServer.uiSettings.replace({ dateFormat: 'YYYY-MM-DD HH:mm:ss.SSS' });
await browser.refresh();
const alert = await browser.getAlert();
await alert?.accept();
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations([PIE_CHART_VIS_NAME]);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/panel_context_menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const searchName = 'my search';

before(async () => {
await PageObjects.header.clickDiscover();
await PageObjects.header.clickDiscover(true);
await PageObjects.discover.clickNewSearchButton();
await dashboardVisualizations.createSavedSearch({ name: searchName, fields: ['bytes'] });
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
2 changes: 2 additions & 0 deletions test/functional/apps/dashboard/panel_replacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('replaced panel persisted correctly when dashboard is hard refreshed', async () => {
const currentUrl = await browser.getCurrentUrl();
await browser.get(currentUrl, true);
const alert = await browser.getAlert();
await alert?.accept();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
const panelTitles = await PageObjects.dashboard.getPanelTitles();
Expand Down
17 changes: 15 additions & 2 deletions test/functional/page_objects/header_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export function HeaderPageProvider({ getService, getPageObjects }: FtrProviderCo
const defaultFindTimeout = config.get('timeouts.find');

class HeaderPage {
public async clickDiscover() {
public async clickDiscover(ignoreAppLeaveWarning = false) {
await appsMenu.clickLink('Discover', { category: 'kibana' });
await this.onAppLeaveWarning(ignoreAppLeaveWarning);
await PageObjects.common.waitForTopNavToBeVisible();
await this.awaitGlobalLoadingIndicatorHidden();
}

public async clickVisualize() {
public async clickVisualize(ignoreAppLeaveWarning = false) {
await appsMenu.clickLink('Visualize', { category: 'kibana' });
await this.onAppLeaveWarning(ignoreAppLeaveWarning);
await this.awaitGlobalLoadingIndicatorHidden();
await retry.waitFor('first breadcrumb to be "Visualize"', async () => {
const firstBreadcrumb = await globalNav.getFirstBreadcrumb();
Expand Down Expand Up @@ -95,6 +97,17 @@ export function HeaderPageProvider({ getService, getPageObjects }: FtrProviderCo
log.debug('awaitKibanaChrome');
await testSubjects.find('kibanaChrome', defaultFindTimeout * 10);
}

public async onAppLeaveWarning(ignoreWarning = false) {
await retry.try(async () => {
const warning = await testSubjects.exists('confirmModalTitleText');
if (warning) {
await testSubjects.click(
ignoreWarning ? 'confirmModalConfirmButton' : 'confirmModalCancelButton'
);
}
});
}
}

return new HeaderPage();
Expand Down
3 changes: 1 addition & 2 deletions test/functional/services/dashboard/visualizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export function DashboardVisualizationProvider({ getService, getPageObjects }: F
fields?: string[];
}) {
log.debug(`createSavedSearch(${name})`);
await PageObjects.header.clickDiscover();

await PageObjects.header.clickDiscover(true);
await PageObjects.timePicker.setHistoricalDataRange();

if (query) {
Expand Down

0 comments on commit 85f2d43

Please sign in to comment.