-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fetch_api_infra' into namespace-ui
Signed-off-by: yelias <[email protected]>
- Loading branch information
Showing
32 changed files
with
1,953 additions
and
235 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { NamespacesList } from '~/app/types'; | ||
|
||
export const mockNamespaces: NamespacesList = [ | ||
{ name: 'default' }, | ||
{ name: 'kubeflow' }, | ||
{ name: 'custom-namespace' }, | ||
]; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ResponseBody } from '~/app/types'; | ||
|
||
export const mockBFFResponse = <T>(data: T): ResponseBody<T> => ({ | ||
data, | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
workspaces/frontend/src/__tests__/cypress/cypress/tests/mocked/application.cy.ts
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
declare namespace jest { | ||
interface Expect { | ||
isIdentityEqual: <T>(expected: T) => T; | ||
} | ||
|
||
interface Matchers<R, T> { | ||
hookToBe: (expected: unknown) => R; | ||
hookToStrictEqual: (expected: unknown) => R; | ||
hookToHaveUpdateCount: (expected: number) => R; | ||
hookToBeStable: < | ||
V extends T extends Pick< | ||
import('~/__tests__/unit/testUtils/hooks').RenderHookResultExt< | ||
infer Result, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
any | ||
>, | ||
'result' | ||
> | ||
? import('~/__tests__/unit/testUtils/hooks').BooleanValues<Result> | ||
: never, | ||
>( | ||
expected?: V, | ||
) => R; | ||
} | ||
|
||
interface Expect { | ||
isIdentityEqual: (expected: unknown) => AsymmetricMatcher; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { TextEncoder } from 'util'; | ||
import { JestAssertionError } from 'expect'; | ||
import 'core-js/actual/array/to-sorted'; | ||
import { | ||
BooleanValues, | ||
RenderHookResultExt, | ||
createComparativeValue, | ||
} from '~/__tests__/unit/testUtils/hooks'; | ||
|
||
global.TextEncoder = TextEncoder; | ||
|
||
const tryExpect = (expectFn: () => void) => { | ||
try { | ||
expectFn(); | ||
} catch (e) { | ||
const { matcherResult } = e as JestAssertionError; | ||
if (matcherResult) { | ||
return { ...matcherResult, message: () => matcherResult.message }; | ||
} | ||
throw e; | ||
} | ||
return { | ||
pass: true, | ||
message: () => '', | ||
}; | ||
}; | ||
|
||
expect.extend({ | ||
// custom asymmetric matchers | ||
|
||
/** | ||
* Checks that a value is what you expect. | ||
* It uses Object.is to check strict equality. | ||
* | ||
* Usage: | ||
* expect.isIdentifyEqual(...) | ||
*/ | ||
isIdentityEqual: (actual, expected) => ({ | ||
pass: Object.is(actual, expected), | ||
message: () => `expected ${actual} to be identity equal to ${expected}`, | ||
}), | ||
|
||
// hook related custom matchers | ||
hookToBe: (actual: RenderHookResultExt<unknown, unknown>, expected) => | ||
tryExpect(() => expect(actual.result.current).toBe(expected)), | ||
|
||
hookToStrictEqual: (actual: RenderHookResultExt<unknown, unknown>, expected) => | ||
tryExpect(() => expect(actual.result.current).toStrictEqual(expected)), | ||
|
||
hookToHaveUpdateCount: (actual: RenderHookResultExt<unknown, unknown>, expected: number) => | ||
tryExpect(() => expect(actual.getUpdateCount()).toBe(expected)), | ||
|
||
hookToBeStable: <R>(actual: RenderHookResultExt<R, unknown>, expected?: BooleanValues<R>) => { | ||
if (actual.getUpdateCount() <= 1) { | ||
throw new Error('Cannot assert stability as the hook has not run at least 2 times.'); | ||
} | ||
if (typeof expected === 'undefined') { | ||
return tryExpect(() => expect(actual.result.current).toBe(actual.getPreviousResult())); | ||
} | ||
return tryExpect(() => | ||
expect(actual.result.current).toStrictEqual( | ||
createComparativeValue(actual.getPreviousResult(), expected), | ||
), | ||
); | ||
}, | ||
}); |
Oops, something went wrong.