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

Fix URL table for ingresses #1317

Merged
merged 4 commits into from
Nov 26, 2019
Merged

Conversation

andresmgot
Copy link
Contributor

Description of the change

The component AccessURLTable is now being mounted before the references to the ingress objects are populated. This caused the AccessURLTable to be empty. To avoid that, we are now fetching also the ingresses when there are changes in the list.

Another subtle change is that instead of relying on the implementation of fetchIngresses, which was defined in the container, I have moved the implementation to the component so it's clear what it's doing.

Applicable issues

Fixes #1307

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

shallow(
<AccessURLTable {...defaultProps} ingressRefs={[{} as ResourceRef]} getResource={mock} />,
);
expect(mock).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be .toHaveBeenCalledWith(...) to be able to justify the name of the test? (ie. to show that it fetches ingresses at mount time)

expect(mock).toHaveBeenCalled();
});

it("fetches new ingresses when received", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/when received/when new ingress refs received/ (just to be specific.

const mock = jest.fn();
shallow(<AccessURLTable services={[]} ingresses={[]} fetchIngresses={mock} />);
const wrapper = shallow(<AccessURLTable {...defaultProps} getResource={mock} />);
wrapper.setProps({ ingressRefs: [{} as ResourceRef] });
expect(mock).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here. I realise this line didn't change, but it was previously a mock of the function fetchIngresses so it was obvious. now it's a mock of the more generic getResource, so it'd be clearer to show that it is indeed getting an Ingress resource.

private fetchIngresses() {
// Fetch all related Ingress resources. We don't need to fetch Services as
// they are expected to be watched by the ServiceTable.
this.props.ingressRefs.forEach(r => this.props.getResource(r));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to worry about re-fetching ingresses we've previously fetched - I assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, it will just update the info

@andresmgot andresmgot merged commit d904fdf into vmware-tanzu:master Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ingress URL not shown in the AppView
2 participants