Refresh Caches only in Portal (#129)

This commit is contained in:
Steve Faulkner 2020-08-05 15:54:17 -05:00 committed by GitHub
parent f132a8546c
commit 78e70cc7cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 7 deletions

View File

@ -39,9 +39,9 @@ module.exports = {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 19.5,
branches: 20,
functions: 24,
lines: 29.5,
lines: 30,
statements: 29.0
}
},

View File

@ -20,7 +20,7 @@ import { ContainerRequest } from "@azure/cosmos/dist-esm/client/Container/Contai
import { CosmosClient } from "./CosmosClient";
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
import { LocalStorageUtility, StorageKey } from "../Shared/StorageUtility";
import { sendCachedDataMessage, canSendMessage } from "./MessageHandler";
import { sendCachedDataMessage } from "./MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { OfferUtils } from "../Utils/OfferUtils";
import { RequestOptions } from "@azure/cosmos/dist-esm";
@ -612,7 +612,7 @@ export function createDatabase(
}
export function refreshCachedOffers(): Q.Promise<void> {
if (canSendMessage()) {
if (config.platform === Platform.Portal) {
return sendCachedDataMessage(MessageTypes.RefreshOffers, []);
} else {
return Q();
@ -620,7 +620,7 @@ export function refreshCachedOffers(): Q.Promise<void> {
}
export function refreshCachedResources(options?: any): Q.Promise<void> {
if (canSendMessage()) {
if (config.platform === Platform.Portal) {
return sendCachedDataMessage(MessageTypes.RefreshResources, []);
} else {
return Q();

View File

@ -2,7 +2,6 @@ import { MessageTypes } from "../Contracts/ExplorerContracts";
import Q from "q";
import * as _ from "underscore";
import * as Constants from "./Constants";
import { config, Platform } from "../Config";
export interface CachedDataPromise<T> {
deferred: Q.Deferred<T>;
@ -60,7 +59,7 @@ export function sendMessage(data: any): void {
}
export function canSendMessage(): boolean {
return config.platform === Platform.Portal && window.parent !== window;
return window.parent !== window;
}
// TODO: This is exported just for testing. It should not be.

View File

@ -1,11 +1,14 @@
jest.mock("../../Utils/arm/request");
jest.mock("../MessageHandler");
import { deleteCollection } from "./deleteCollection";
import { armRequest } from "../../Utils/arm/request";
import { AuthType } from "../../AuthType";
import { sendCachedDataMessage } from "../MessageHandler";
describe("deleteCollection", () => {
it("should call ARM if logged in with AAD", async () => {
window.authType = AuthType.AAD;
(sendCachedDataMessage as jest.Mock).mockResolvedValue(undefined);
await deleteCollection("database", "collection");
expect(armRequest).toHaveBeenCalled();
});

View File

@ -1,11 +1,14 @@
jest.mock("../../Utils/arm/request");
jest.mock("../MessageHandler");
import { deleteDatabase } from "./deleteDatabase";
import { armRequest } from "../../Utils/arm/request";
import { AuthType } from "../../AuthType";
import { sendCachedDataMessage } from "../MessageHandler";
describe("deleteDatabase", () => {
it("should call ARM if logged in with AAD", async () => {
window.authType = AuthType.AAD;
(sendCachedDataMessage as jest.Mock).mockResolvedValue(undefined);
await deleteDatabase("database");
expect(armRequest).toHaveBeenCalled();
});