-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the Devfile is not reachable warning for SSH urls (#1259)
If the devfile resolve request fails with the devfile not found error, check if the url is an SSH url. If so, interrupt the workspace start with a new warning that describes the problem of the devfile resolve via a private repository SSH url.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
|
||
import { FACTORY_LINK_ATTR } from '@eclipse-che/common'; | ||
import { AlertVariant } from '@patternfly/react-core'; | ||
import { cleanup, screen, waitFor } from '@testing-library/react'; | ||
import userEvent, { UserEvent } from '@testing-library/user-event'; | ||
import { createMemoryHistory, MemoryHistory } from 'history'; | ||
|
@@ -709,6 +710,7 @@ describe('Creating steps, fetching a devfile', () => { | |
[FACTORY_URL_ATTR]: factoryUrl, | ||
}); | ||
|
||
mockIsOAuthResponse.mockReturnValue(false); | ||
mockRequestFactoryResolver.mockRejectedValue('Could not reach devfile'); | ||
|
||
spyWindowLocation = createWindowLocationSpy(host, protocol); | ||
|
@@ -751,6 +753,46 @@ describe('Creating steps, fetching a devfile', () => { | |
expect(mockOpenOAuthPage).not.toHaveBeenCalled(); | ||
expect(mockOnError).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should show warning on SSH url', async () => { | ||
const expectAlertItem = expect.objectContaining({ | ||
title: 'Warning', | ||
variant: AlertVariant.warning, | ||
children: ( | ||
<ExpandableWarning | ||
textBefore="Devfile resolve from a privatre repositry via an SSH url is not supported." | ||
errorMessage="Could not reach devfile" | ||
textAfter="Apply a Personal Access Token to fetch the devfile.yaml content." | ||
/> | ||
), | ||
actionCallbacks: [ | ||
expect.objectContaining({ | ||
title: 'Continue with default devfile', | ||
callback: expect.any(Function), | ||
}), | ||
expect.objectContaining({ | ||
title: 'Reload', | ||
callback: expect.any(Function), | ||
}), | ||
expect.objectContaining({ | ||
title: 'Open Documentation page', | ||
callback: expect.any(Function), | ||
}), | ||
], | ||
}); | ||
searchParams = new URLSearchParams({ | ||
[FACTORY_URL_ATTR]: '[email protected]:user/repository.git', | ||
}); | ||
const emptyStore = new FakeStoreBuilder().build(); | ||
renderComponent(emptyStore, searchParams, history); | ||
|
||
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS); | ||
|
||
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled); | ||
|
||
expect(mockOpenOAuthPage).not.toHaveBeenCalled(); | ||
expect(mockOnError).toHaveBeenCalledWith(expectAlertItem); | ||
}); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters