mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-15 12:47:56 +08:00
Fix unit tests (#2428)
* only create toaster if we're on the browser * drop/fix references to window * add back fe unit tests
This commit is contained in:
committed by
GitHub
parent
01013bcf04
commit
0634160c0c
@@ -1,11 +1,4 @@
|
||||
export const baseDataURL = "https://a.fake.url/api/v0.2";
|
||||
|
||||
window.CELLXGENE = {
|
||||
API: {
|
||||
prefix: baseDataURL,
|
||||
version: "v0.2/",
|
||||
},
|
||||
};
|
||||
|
||||
export { schema } from "./schema";
|
||||
export * from "./routes";
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
import { Position, Toaster, Intent } from "@blueprintjs/core";
|
||||
|
||||
/** Singleton toaster instance. Create separate instances for different options. */
|
||||
|
||||
const ToastTopCenter = Toaster.create({
|
||||
className: "recipe-toaster",
|
||||
position: Position.TOP,
|
||||
maxToasts: 4,
|
||||
});
|
||||
let ToastTopCenter = null;
|
||||
if (typeof document !== "undefined") {
|
||||
ToastTopCenter = Toaster.create({
|
||||
className: "recipe-toaster",
|
||||
position: Position.TOP,
|
||||
maxToasts: 4,
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
A "user" error - eg, bad input
|
||||
*/
|
||||
export const postUserErrorToast = (message) =>
|
||||
ToastTopCenter.show({ message, intent: Intent.WARNING });
|
||||
ToastTopCenter?.show({ message, intent: Intent.WARNING });
|
||||
|
||||
/*
|
||||
A toast the user must dismiss manually, because they need to act on its information,
|
||||
ie., 8 bulk add genes out of 40 were bad. Manually see which ones and fix.
|
||||
*/
|
||||
export const keepAroundErrorToast = (message) =>
|
||||
ToastTopCenter.show({ message, timeout: 0, intent: Intent.WARNING });
|
||||
ToastTopCenter?.show({ message, timeout: 0, intent: Intent.WARNING });
|
||||
|
||||
/*
|
||||
a hard network error
|
||||
*/
|
||||
export const postNetworkErrorToast = (message, key = undefined) =>
|
||||
ToastTopCenter.show(
|
||||
ToastTopCenter?.show(
|
||||
{
|
||||
message,
|
||||
timeout: 30000,
|
||||
@@ -38,14 +40,14 @@ export const postNetworkErrorToast = (message, key = undefined) =>
|
||||
Async message to user
|
||||
*/
|
||||
export const postAsyncSuccessToast = (message) =>
|
||||
ToastTopCenter.show({
|
||||
ToastTopCenter?.show({
|
||||
message,
|
||||
timeout: 10000,
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
|
||||
export const postAsyncFailureToast = (message) =>
|
||||
ToastTopCenter.show({
|
||||
ToastTopCenter?.show({
|
||||
message,
|
||||
timeout: 10000,
|
||||
intent: Intent.WARNING,
|
||||
|
||||
@@ -102,7 +102,7 @@ const CXG_SERVER_PORT =
|
||||
|
||||
let _API;
|
||||
|
||||
if (window.CELLXGENE && window.CELLXGENE.API) {
|
||||
if (typeof window !== "undefined" && window.CELLXGENE && window.CELLXGENE.API) {
|
||||
_API = window.CELLXGENE.API;
|
||||
} else {
|
||||
if (CXG_SERVER_PORT === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user