Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][Home] Rename IndexPattern to DataView #123593

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/plugins/home/public/application/components/home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('home', () => {
addBasePath(url) {
return `base_path/${url}`;
},
hasUserIndexPattern: jest.fn(async () => true),
hasUserDataView: jest.fn(async () => true),
};
});

Expand Down Expand Up @@ -187,8 +187,8 @@ describe('home', () => {
test('should show the welcome screen if enabled, and there are no index patterns defined', async () => {
defaultProps.localStorage.getItem = jest.fn(() => 'true');

const hasUserIndexPattern = jest.fn(async () => false);
const component = await renderHome({ hasUserIndexPattern });
const hasUserDataView = jest.fn(async () => false);
const component = await renderHome({ hasUserDataView });

expect(defaultProps.localStorage.getItem).toHaveBeenCalledTimes(1);

Expand All @@ -198,8 +198,8 @@ describe('home', () => {
test('stores skip welcome setting if skipped', async () => {
defaultProps.localStorage.getItem = jest.fn(() => 'true');

const hasUserIndexPattern = jest.fn(async () => false);
const component = await renderHome({ hasUserIndexPattern });
const hasUserDataView = jest.fn(async () => false);
const component = await renderHome({ hasUserDataView });

component.instance().skipWelcome();
component.update();
Expand All @@ -212,8 +212,8 @@ describe('home', () => {
test('should show the normal home page if loading fails', async () => {
defaultProps.localStorage.getItem = jest.fn(() => 'true');

const hasUserIndexPattern = jest.fn(() => Promise.reject('Doh!'));
const component = await renderHome({ hasUserIndexPattern });
const hasUserDataView = jest.fn(() => Promise.reject('Doh!'));
const component = await renderHome({ hasUserDataView });

expect(component.find(Welcome).exists()).toBe(false);
});
Expand All @@ -237,28 +237,28 @@ describe('home', () => {

describe('isNewKibanaInstance', () => {
test('should set isNewKibanaInstance to true when there are no index patterns', async () => {
const hasUserIndexPattern = jest.fn(async () => false);
const component = await renderHome({ hasUserIndexPattern });
const hasUserDataView = jest.fn(async () => false);
const component = await renderHome({ hasUserDataView });

expect(component.state().isNewKibanaInstance).toBe(true);

expect(component).toMatchSnapshot();
});

test('should set isNewKibanaInstance to false when there are index patterns', async () => {
const hasUserIndexPattern = jest.fn(async () => true);
const component = await renderHome({ hasUserIndexPattern });
const hasUserDataView = jest.fn(async () => true);
const component = await renderHome({ hasUserDataView });

expect(component.state().isNewKibanaInstance).toBe(false);

expect(component).toMatchSnapshot();
});

test('should safely handle exceptions', async () => {
const hasUserIndexPattern = jest.fn(() => {
const hasUserDataView = jest.fn(() => {
throw new Error('simulated find error');
});
const component = await renderHome({ hasUserIndexPattern });
const component = await renderHome({ hasUserDataView });

expect(component.state().isNewKibanaInstance).toBe(false);

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/home/public/application/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface HomeProps {
localStorage: Storage;
urlBasePath: string;
telemetry: TelemetryPluginStart;
hasUserIndexPattern: () => Promise<boolean>;
hasUserDataView: () => Promise<boolean>;
}

interface State {
Expand Down Expand Up @@ -89,7 +89,7 @@ export class Home extends Component<HomeProps, State> {
}
}, 10000);

const hasUserIndexPattern = await this.props.hasUserIndexPattern();
const hasUserIndexPattern = await this.props.hasUserDataView();

this.endLoading({ isNewKibanaInstance: !hasUserIndexPattern });
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function HomeApp({ directories, solutions }) {
localStorage={localStorage}
urlBasePath={getBasePath()}
telemetry={telemetry}
hasUserIndexPattern={() => indexPatternService.hasUserDataView()}
hasUserDataView={() => indexPatternService.hasUserDataView()}
/>
</Route>
<Redirect to="/" />
Expand Down