Skip to content

Commit

Permalink
make install status available to be read by test util
Browse files Browse the repository at this point in the history
  • Loading branch information
eokoneyo committed Mar 12, 2024
1 parent 142df27 commit 31519cb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
30 changes: 22 additions & 8 deletions packages/home/sample_data_card/src/footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React from 'react';
import React, { useCallback } from 'react';
import { SampleDataSet, InstalledStatus } from '@kbn/home-sample-data-types';
import { INSTALLED_STATUS, UNINSTALLED_STATUS } from '../constants';

Expand All @@ -28,13 +28,27 @@ export interface Props {
* Displays the appropriate Footer component based on the status of the Sample Data Set.
*/
export const Footer = ({ sampleDataSet, onAction }: Props) => {
if (sampleDataSet.status === INSTALLED_STATUS) {
return <RemoveFooter onRemove={(id) => onAction(id, UNINSTALLED_STATUS)} {...sampleDataSet} />;
}
const renderContent = useCallback(() => {
if (sampleDataSet.status === INSTALLED_STATUS) {
return (
<RemoveFooter onRemove={(id) => onAction(id, UNINSTALLED_STATUS)} {...sampleDataSet} />
);
}

if (sampleDataSet.status === UNINSTALLED_STATUS) {
return <InstallFooter onInstall={(id) => onAction(id, INSTALLED_STATUS)} {...sampleDataSet} />;
}
if (sampleDataSet.status === UNINSTALLED_STATUS) {
return (
<InstallFooter onInstall={(id) => onAction(id, INSTALLED_STATUS)} {...sampleDataSet} />
);
}

return <DisabledFooter {...sampleDataSet} />;
return <DisabledFooter {...sampleDataSet} />;
}, [onAction, sampleDataSet]);

return (
// the data-status attribute is added to solve issues with failing test,
// see https://github.com/elastic/kibana/issues/112103
<div data-status={sampleDataSet.status} style={{ display: 'contents' }}>
{renderContent()}
</div>
);
};
8 changes: 5 additions & 3 deletions test/functional/page_objects/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ export class HomePageObject extends FtrService {

async isSampleDataSetInstalled(id: string) {
const sampleDataCard = await this.testSubjects.find(`sampleDataSetCard${id}`);
const deleteButton = await sampleDataCard.findAllByTestSubject(`removeSampleDataSet${id}`);
this.log.debug(`Sample data installed: ${deleteButton.length > 0}`);
return deleteButton.length > 0;
const installStatus = await (
await sampleDataCard.findByCssSelector('[data-status]')
).getAttribute('data-status');

return installStatus === 'installed';
}

async isWelcomeInterstitialDisplayed() {
Expand Down
3 changes: 1 addition & 2 deletions x-pack/test/functional_execution_context/tests/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { assertLogContains, isExecutionContextLog, readLogFile } from '../test_u
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'home', 'timePicker']);

// FLAKY: https://github.com/elastic/kibana/issues/112103
describe.skip('Browser apps', () => {
describe('Browser apps', () => {
let logs: Ecs[];
const retry = getService('retry');

Expand Down

0 comments on commit 31519cb

Please sign in to comment.