-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
48 additions
and
247 deletions.
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 |
---|---|---|
|
@@ -113,7 +113,7 @@ | |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #16176 | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #13991 | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #18409 | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined | | ||
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined | | ||
|
@@ -315,7 +315,7 @@ | |
| `[email protected]` | MIT | clearlydefined | | ||
| [`[email protected]`](http://github.com/eslint/eslint-scope) | BSD-2-Clause | clearlydefined | | ||
| [`[email protected]`](http://github.com/eslint/eslint-scope) | BSD-2-Clause | #9916 | | ||
| [`[email protected]`](https://github.com/eslint/eslint-visitor-keys#readme) | Apache-2.0 | #15274 | | ||
| [`[email protected]`](https://github.com/eslint/eslint-visitor-keys#readme) | Apache-2.0 | #18264 | | ||
| [`[email protected]`](https://github.com/webpack-contrib/eslint-webpack-plugin) | MIT | clearlydefined | | ||
| [`[email protected]`](https://eslint.org) | MIT | #11437 | | ||
| [`[email protected]`](https://github.com/eslint/espree) | BSD-2-Clause | #15293 | | ||
|
@@ -435,7 +435,7 @@ | |
| [`[email protected]`](git://github.com/inspect-js/is-typed-array.git) | MIT | #4853 | | ||
| [`[email protected]`](git+https://github.com/inspect-js/is-weakmap.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/inspect-js/is-weakref.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/inspect-js/is-weakset.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/inspect-js/is-weakset.git) | MIT | #18388 | | ||
| `[email protected]` | MIT | clearlydefined | | ||
| [`[email protected]`](git://github.com/juliangruber/isarray.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/jonschlinkert/isobject) | MIT | clearlydefined | | ||
|
@@ -445,7 +445,7 @@ | |
| [`[email protected]`](git+ssh://[email protected]/istanbuljs/istanbuljs.git) | BSD-3-Clause | clearlydefined | | ||
| [`[email protected]`](git+ssh://[email protected]/istanbuljs/istanbuljs.git) | BSD-3-Clause | clearlydefined | | ||
| [`[email protected]`](git+ssh://[email protected]/istanbuljs/istanbuljs.git) | BSD-3-Clause | #1710 | | ||
| [`[email protected]`](git+https://github.com/ljharb/Iterator.prototype.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/ljharb/Iterator.prototype.git) | MIT | #18395 | | ||
| [`[email protected]`](https://github.com/jestjs/jest.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/jestjs/jest.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/jestjs/jest.git) | MIT | clearlydefined | | ||
|
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 |
---|---|---|
|
@@ -408,7 +408,7 @@ | |
| [`[email protected]`](https://github.com/tapjs/signal-exit.git) | ISC | clearlydefined | | ||
| [`[email protected]`](https://github.com/lelylan/simple-oauth2) | Apache-2.0 | clearlydefined | | ||
| [`[email protected]`](https://github.com/JoshGlazebrook/smart-buffer.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/TooTallNate/proxy-agents.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/TooTallNate/proxy-agents.git) | MIT | #18498 | | ||
| [`[email protected]`](https://github.com/JoshGlazebrook/socks.git) | MIT | #13459 | | ||
| [`[email protected]`](git+https://github.com/pinojs/sonic-boom.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/pinojs/sonic-boom.git) | MIT | clearlydefined | | ||
|
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
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
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
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
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,7 +13,6 @@ | |
/* 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 React from 'react'; | ||
|
@@ -346,7 +345,7 @@ describe('Creating steps, fetching a devfile', () => { | |
}); | ||
}); | ||
|
||
describe('unsupported git provider error', () => { | ||
describe('unsupported git provider', () => { | ||
let emptyStore: Store; | ||
const rejectReason = 'Failed to fetch devfile'; | ||
|
||
|
@@ -355,110 +354,13 @@ describe('Creating steps, fetching a devfile', () => { | |
mockRequestFactoryResolver.mockRejectedValueOnce(rejectReason); | ||
}); | ||
|
||
test('alert title', async () => { | ||
test('should continue with the default devfile', async () => { | ||
renderComponent(emptyStore, searchParams); | ||
|
||
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS); | ||
|
||
const expectAlertItem = expect.objectContaining({ | ||
title: 'Warning', | ||
actionCallbacks: [ | ||
expect.objectContaining({ | ||
title: 'Continue with default devfile', | ||
callback: expect.any(Function), | ||
}), | ||
expect.objectContaining({ | ||
title: 'Reload', | ||
callback: expect.any(Function), | ||
}), | ||
], | ||
}); | ||
await waitFor(() => expect(mockOnError).toHaveBeenCalledWith(expectAlertItem)); | ||
|
||
expect(mockOnNextStep).not.toHaveBeenCalled(); | ||
}); | ||
|
||
test('action "Continue with default devfile"', async () => { | ||
// this deferred object will help run the callback at the right time | ||
const deferred = getDefer(); | ||
|
||
const actionTitle = 'Continue with default devfile'; | ||
mockOnError.mockImplementationOnce((alertItem: AlertItem) => { | ||
const action = alertItem.actionCallbacks?.find(_action => | ||
_action.title.startsWith(actionTitle), | ||
); | ||
expect(action).toBeDefined(); | ||
|
||
if (action) { | ||
deferred.promise.then(action.callback); | ||
} else { | ||
throw new Error('Action not found'); | ||
} | ||
}); | ||
|
||
renderComponent(emptyStore, searchParams); | ||
await jest.runAllTimersAsync(); | ||
|
||
await waitFor(() => expect(mockOnError).toHaveBeenCalled()); | ||
expect(mockOnRestart).not.toHaveBeenCalled(); | ||
expect(mockOnNextStep).not.toHaveBeenCalled(); | ||
|
||
mockOnError.mockClear(); | ||
|
||
/* test the action */ | ||
await jest.runOnlyPendingTimersAsync(); | ||
|
||
// resolve deferred to trigger the callback | ||
deferred.resolve(); | ||
|
||
await waitFor(() => expect(mockOnNextStep).toHaveBeenCalled()); | ||
expect(mockOnRestart).not.toHaveBeenCalled(); | ||
expect(mockOnError).not.toHaveBeenCalled(); | ||
}); | ||
|
||
test('action "Reload"', async () => { | ||
// this deferred object will help run the callback at the right time | ||
const deferred = getDefer(); | ||
|
||
const actionTitle = 'Reload'; | ||
mockOnError.mockImplementationOnce(async (alertItem: AlertItem) => { | ||
const action = alertItem.actionCallbacks?.find(_action => | ||
_action.title.startsWith(actionTitle), | ||
); | ||
expect(action).toBeDefined(); | ||
|
||
if (action) { | ||
deferred.promise.then(action.callback); | ||
} else { | ||
throw new Error('Action not found'); | ||
} | ||
}); | ||
|
||
renderComponent(emptyStore, searchParams); | ||
await jest.runAllTimersAsync(); | ||
|
||
await waitFor(() => expect(mockOnError).toHaveBeenCalled()); | ||
expect(mockOnRestart).not.toHaveBeenCalled(); | ||
expect(mockOnNextStep).not.toHaveBeenCalled(); | ||
|
||
// first call resolves with error | ||
expect(mockRequestFactoryResolver).toHaveBeenCalledTimes(1); | ||
|
||
mockOnError.mockClear(); | ||
|
||
/* test the action */ | ||
|
||
await jest.runAllTimersAsync(); | ||
|
||
// resolve deferred to trigger the callback | ||
deferred.resolve(); | ||
|
||
await waitFor(() => expect(mockOnRestart).toHaveBeenCalled()); | ||
expect(mockOnNextStep).not.toHaveBeenCalled(); | ||
expect(mockOnError).not.toHaveBeenCalled(); | ||
|
||
// should request the factory resolver for the second time | ||
await waitFor(() => expect(mockRequestFactoryResolver).toHaveBeenCalledTimes(2)); | ||
await waitFor(() => expect(mockOnError).not.toHaveBeenCalled()); | ||
expect(mockOnNextStep).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
|
@@ -695,31 +597,6 @@ describe('Creating steps, fetching a devfile', () => { | |
const protocol = 'http://'; | ||
const factoryUrl = '[email protected]:user/repository-name.git'; | ||
const emptyStore = new MockStoreBuilder().build(); | ||
const sshPrivateRepoAllertItem = 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), | ||
}), | ||
], | ||
}); | ||
|
||
let spyWindowLocation: jest.SpyInstance; | ||
let location: Location; | ||
|
@@ -771,32 +648,32 @@ describe('Creating steps, fetching a devfile', () => { | |
expect(mockOnError).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should show warning on SSH url', async () => { | ||
it('should use default devfile on private SSH url', async () => { | ||
searchParams = new URLSearchParams({ | ||
[FACTORY_URL_ATTR]: '[email protected]:user/repository.git', | ||
}); | ||
|
||
renderComponent(emptyStore, searchParams, location); | ||
|
||
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS); | ||
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled); | ||
await waitFor(() => expect(mockOnNextStep).toHaveBeenCalled()); | ||
|
||
expect(mockOpenOAuthPage).not.toHaveBeenCalled(); | ||
expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem); | ||
expect(mockOnError).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should show warning on bitbucket-server SSH url', async () => { | ||
it('should use default devfile on bitbucket-server SSH url', async () => { | ||
searchParams = new URLSearchParams({ | ||
[FACTORY_URL_ATTR]: 'ssh://[email protected]/~user/repository.git', | ||
}); | ||
|
||
renderComponent(emptyStore, searchParams, location); | ||
|
||
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS); | ||
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled); | ||
await waitFor(() => expect(mockOnNextStep).toHaveBeenCalled); | ||
|
||
expect(mockOpenOAuthPage).not.toHaveBeenCalled(); | ||
expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem); | ||
expect(mockOnError).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
|
Oops, something went wrong.