[CORL-159, CORL-160] Stream Config Tab (#2219)

* feat: Implement stream configuration tab

* feat: split profile & configure into separate bundles

* chore: better role logic

* fix+chore: add test cases, implement expectAndFail, refactor tests

* chore: add some comments

* chore: Update src/core/client/framework/lib/form/helpers.tsx

Co-Authored-By: cvle <vinh@wikiwi.io>

* feat: support new graphql mutations/schema

* fix: ci fixes

* fix: improvement to revision loading

* fix: updated some tests

* fix: adapt client to changes

* fix: remove obsolote isClosed in UpdateStory

* ci: increase no_output_timeout for build
This commit is contained in:
Kiwi
2019-03-18 22:07:52 +01:00
committed by GitHub
parent c738d9a355
commit 9eb5afbb2b
128 changed files with 2249 additions and 1081 deletions
+56
View File
@@ -0,0 +1,56 @@
// Jest assertions will not fail if they live inside a try-catch block due to
// https://github.com/facebook/jest/issues/3917.
// This file returns a version of `expect` that that
// fails the test immediately when an exception is thrown.
/**
* isPromise detects whether given object is a promise or not.
*/
const isPromise = <T extends any>(obj: any): obj is PromiseLike<T> =>
!!obj &&
(typeof obj === "object" || typeof obj === "function") &&
typeof obj.then === "function";
/**
* Wrap a jest matcher so if the expectation fails, it also fails the test.
* @param func the jest matcher that will be wrapped.
*/
const wrapMatcher = (func: any) => {
const wrappedMatcher: any = {};
const keys = Object.keys(func);
keys.forEach(k => {
if (typeof func[k] === "function") {
wrappedMatcher[k] = (...args: any[]) => {
try {
const result = func[k](...args);
if (isPromise(result)) {
return result.then(undefined, e => {
// Remove this function from stacktrace.
Error.captureStackTrace(e, wrappedMatcher[k]);
fail(e);
throw e;
});
}
return result;
} catch (e) {
// Remove this function from stacktrace.
Error.captureStackTrace(e, wrappedMatcher[k]);
fail(e);
throw e;
}
};
} else {
// This should be not, resolves, rejects.
wrappedMatcher[k] = wrapMatcher(func[k]);
}
});
return wrappedMatcher;
};
const expectAndFail = (...args: any[]) => {
const matcher = (global as any).expect(...args);
return wrapMatcher(matcher);
};
export default expectAndFail;
@@ -1,6 +1,13 @@
import expectAndFail from "./expectAndFail";
// Automatically unmock console.
import "jest-mock-console/dist/setupTestFramework";
// Expose a version of expect that will fail tests immediately
// when assertion fails. This works even inside of an try-catch block
// to get around: https://github.com/facebook/jest/issues/3917
(global as any).expectAndFail = expectAndFail;
// Log unhandled rejections.
// tslint:disable-next-line:no-console
process.on("unhandledRejection", err => {