From 3fcb47f5ec310a37bad317f90b6ae36a4a681aa8 Mon Sep 17 00:00:00 2001 From: Dave Bouwman Date: Fri, 15 Sep 2023 14:56:06 -0600 Subject: [PATCH] refactor: rename functions to match finalized terminology --- package-lock.json | 46 +++----- packages/common/e2e/associations.e2e.ts | 29 +---- packages/common/src/groups/HubGroups.ts | 3 +- .../src/groups/_internal/computeProps.ts | 2 +- .../common/src/initiatives/HubInitiatives.ts | 109 +++++++++--------- packages/common/src/projects/fetch.ts | 6 +- packages/common/src/search/hubSearch.ts | 13 +-- packages/common/src/search/utils.ts | 2 +- packages/common/src/users/HubUsers.ts | 3 +- .../test/initiatives/HubInitiatives.test.ts | 109 +++++++++--------- packages/common/test/projects/fetch.test.ts | 10 +- packages/common/test/search/hubSearch.test.ts | 10 +- packages/common/test/search/utils.test.ts | 8 +- 13 files changed, 159 insertions(+), 191 deletions(-) diff --git a/package-lock.json b/package-lock.json index d2770c71756..d3b8397c1e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22659,10 +22659,9 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", - "dev": true, + "extraneous": true, "inBundle": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._baseuniq": { "version": "4.6.0", @@ -22677,24 +22676,21 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", - "dev": true, + "extraneous": true, "inBundle": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", - "dev": true, + "extraneous": true, "inBundle": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT", - "peer": true, "dependencies": { "lodash._getnative": "^3.0.0" } @@ -22708,10 +22704,9 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", - "dev": true, + "extraneous": true, "inBundle": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash._root": { "version": "3.0.1", @@ -22729,10 +22724,9 @@ }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", - "dev": true, + "extraneous": true, "inBundle": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/cz-lerna-changelog/node_modules/npm/node_modules/lodash.union": { "version": "4.6.0", @@ -83407,8 +83401,7 @@ "lodash._baseindexof": { "version": "3.1.0", "bundled": true, - "dev": true, - "peer": true + "extraneous": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -83423,20 +83416,17 @@ "lodash._bindcallback": { "version": "3.0.1", "bundled": true, - "dev": true, - "peer": true + "extraneous": true }, "lodash._cacheindexof": { "version": "3.0.2", "bundled": true, - "dev": true, - "peer": true + "extraneous": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, - "dev": true, - "peer": true, + "extraneous": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -83450,8 +83440,7 @@ "lodash._getnative": { "version": "3.9.1", "bundled": true, - "dev": true, - "peer": true + "extraneous": true }, "lodash._root": { "version": "3.0.1", @@ -83468,8 +83457,7 @@ "lodash.restparam": { "version": "3.6.1", "bundled": true, - "dev": true, - "peer": true + "extraneous": true }, "lodash.union": { "version": "4.6.0", diff --git a/packages/common/e2e/associations.e2e.ts b/packages/common/e2e/associations.e2e.ts index dc9f41b753c..c68728426c4 100644 --- a/packages/common/e2e/associations.e2e.ts +++ b/packages/common/e2e/associations.e2e.ts @@ -1,9 +1,8 @@ import { IHubInitiative, - fetchConnectedProjects, - fetchAssociatedProjects, + fetchAcceptedProjects, fetchHubEntity, - fetchUnConnectedProjects, + fetchPendingProjects, } from "../src"; import Artifactory from "./helpers/Artifactory"; import config from "./helpers/config"; @@ -98,7 +97,7 @@ fdescribe("associations development harness:", () => { }); }); describe("flex the functions:", () => { - it("search for associated projects", async () => { + it("search for accepted projects", async () => { const ctxMgr = await factory.getContextManager(orgName, "admin"); const context = ctxMgr.context; const entity = (await fetchHubEntity( @@ -107,30 +106,14 @@ fdescribe("associations development harness:", () => { context )) as IHubInitiative; // debugger; - const projects = await fetchAssociatedProjects( + const projects = await fetchAcceptedProjects( entity, context.hubRequestOptions ); expect(projects.length).toBe(6); }); - it("search for un-related projects", async () => { - const ctxMgr = await factory.getContextManager(orgName, "admin"); - const context = ctxMgr.context; - const entity = (await fetchHubEntity( - "initiative", - TEST_ITEMS.initiative, - context - )) as IHubInitiative; - // debugger; - const projects = await fetchUnConnectedProjects( - entity, - context.hubRequestOptions - ); - // need to update this so we fetch all pages - expect(projects.length).toBe(10); - }); - it("search for related projects", async () => { + it("search for pending projects", async () => { const ctxMgr = await factory.getContextManager(orgName, "admin"); const context = ctxMgr.context; const entity = (await fetchHubEntity( @@ -138,7 +121,7 @@ fdescribe("associations development harness:", () => { TEST_ITEMS.initiative, context )) as IHubInitiative; - const projects = await fetchConnectedProjects( + const projects = await fetchPendingProjects( entity, context.hubRequestOptions ); diff --git a/packages/common/src/groups/HubGroups.ts b/packages/common/src/groups/HubGroups.ts index fc0c909bef9..621e840313d 100644 --- a/packages/common/src/groups/HubGroups.ts +++ b/packages/common/src/groups/HubGroups.ts @@ -1,7 +1,7 @@ import { IGroup } from "@esri/arcgis-rest-types"; import { fetchGroupEnrichments } from "./_internal/enrichments"; import { getProp, setProp } from "../objects"; -import { getGroupThumbnailUrl, IHubSearchResult } from "../search"; +import { getGroupThumbnailUrl } from "../search/utils"; import { parseInclude } from "../search/_internal/parseInclude"; import { IHubRequestOptions } from "../types"; import { getGroupHomeUrl } from "../urls"; @@ -20,6 +20,7 @@ import { DEFAULT_GROUP } from "./defaults"; import { convertHubGroupToGroup } from "./_internal/convertHubGroupToGroup"; import { convertGroupToHubGroup } from "./_internal/convertGroupToHubGroup"; import { getRelativeWorkspaceUrl } from "../core/getRelativeWorkspaceUrl"; +import { IHubSearchResult } from "../search/types/IHubSearchResult"; /** * Enrich a generic search result diff --git a/packages/common/src/groups/_internal/computeProps.ts b/packages/common/src/groups/_internal/computeProps.ts index edeb7b0497a..783f01e1584 100644 --- a/packages/common/src/groups/_internal/computeProps.ts +++ b/packages/common/src/groups/_internal/computeProps.ts @@ -4,7 +4,7 @@ import { UserSession } from "@esri/arcgis-rest-auth"; import { IHubGroup } from "../../core/types/IHubGroup"; import { IGroup } from "@esri/arcgis-rest-types"; import { isDiscussable } from "../../discussions"; -import { getGroupThumbnailUrl } from "../../search"; +import { getGroupThumbnailUrl } from "../../search/utils"; /** * Given a model and a group, set various computed properties that can't be directly mapped diff --git a/packages/common/src/initiatives/HubInitiatives.ts b/packages/common/src/initiatives/HubInitiatives.ts index a7062923526..53665e0eb39 100644 --- a/packages/common/src/initiatives/HubInitiatives.ts +++ b/packages/common/src/initiatives/HubInitiatives.ts @@ -282,21 +282,20 @@ export async function enrichInitiativeSearchResult( } /** - * Fetch the Projects that are "Associated" with an Initiative. - * This is a subset of the "Connected" projects, limited - * are included in the Initiative's Catalog. - * This is how we can get the "Approved" Projects + * Fetch the Projects that are "Accepted" with an Initiative. + * This is a subset of the "Associated" projects, limited + * to those included in the Initiative's Catalog. * @param initiative * @param requestOptions * @param query: Optional `IQuery` to further filter the results * @returns */ -export async function fetchAssociatedProjects( +export async function fetchAcceptedProjects( initiative: IHubInitiative, requestOptions: IHubRequestOptions, query?: IQuery ): Promise { - let projectQuery = getAssociatedProjectsQuery(initiative); + let projectQuery = getAcceptedProjectsQuery(initiative); // combineQueries will purge undefined/null entries projectQuery = combineQueries([projectQuery, query]); @@ -304,40 +303,20 @@ export async function fetchAssociatedProjects( } /** - * Fetch the Projects that are "Connected" to the Initiative but are not - * "Associated", meaning they are not in the Initiative's Catalog. - * This is how we can get the list of Projects awaiting Approval + * Fetch the Projects that are "Associated" to the Initiative but are not + * "Accepted", meaning they have the keyword but are not included in the Initiative's Catalog. + * This is how we can get the list of Projects awaiting Acceptance * @param initiative * @param requestOptions * @param query * @returns */ -export async function fetchConnectedProjects( +export async function fetchPendingProjects( initiative: IHubInitiative, requestOptions: IHubRequestOptions, query?: IQuery ): Promise { - let projectQuery = getConnectedProjectsQuery(initiative); - // combineQueries will purge undefined/null entries - projectQuery = combineQueries([projectQuery, query]); - - return queryAsEntityInfo(projectQuery, requestOptions); -} - -/** - * Fetch Projects which are not "Connected" and are not in the - * Initiative's Catalog. - * @param initiative - * @param requestOptions - * @param query - * @returns - */ -export async function fetchUnConnectedProjects( - initiative: IHubInitiative, - requestOptions: IHubRequestOptions, - query?: IQuery -): Promise { - let projectQuery = getUnConnectedProjectsQuery(initiative); + let projectQuery = getPendingProjectsQuery(initiative); // combineQueries will purge undefined/null entries projectQuery = combineQueries([projectQuery, query]); @@ -374,7 +353,7 @@ async function queryAsEntityInfo( * @param initiative * @returns */ -export function getAssociatedProjectsQuery(initiative: IHubInitiative): IQuery { +export function getAcceptedProjectsQuery(initiative: IHubInitiative): IQuery { // get query that returns Hub Projects with the initiative keyword let query = getTypeWithKeywordQuery( "Hub Project", @@ -397,7 +376,7 @@ export function getAssociatedProjectsQuery(initiative: IHubInitiative): IQuery { * @param initiative * @returns */ -export function getConnectedProjectsQuery(initiative: IHubInitiative): IQuery { +export function getPendingProjectsQuery(initiative: IHubInitiative): IQuery { // get query that returns Hub Projects with the initiative keyword let query = getTypeWithKeywordQuery( "Hub Project", @@ -412,25 +391,47 @@ export function getConnectedProjectsQuery(initiative: IHubInitiative): IQuery { return query; } -/** - * Un-connected projects are those without Initiative id in the typekeywords - * and is NOT included in the Initiative's catalog. - * This can be used to locate "Other" Projects - * @param initiative - * @returns - */ -export function getUnConnectedProjectsQuery( - initiative: IHubInitiative -): IQuery { - // get query that returns Hub Projects with the initiative keyword - let query = getTypeWithoutKeywordQuery( - "Hub Project", - `initiative|${initiative.id}` - ); - // The the item scope from the catalog... - const qry = getProp(initiative, "catalog.scopes.item"); +// ALTHOUGH WE DON"T CURRENTLY HAVE A UX THAT NEEDS THIS +// THERE IS SOME DISCUSSION ABOUT IT BEING USEFUL SO I'M LEAVING +// THE CODE HERE, COMMENTED. SAME FOR TESTS +// /** +// * Fetch Projects which are not "Connected" and are not in the +// * Initiative's Catalog. +// * @param initiative +// * @param requestOptions +// * @param query +// * @returns +// */ +// export async function fetchUnConnectedProjects( +// initiative: IHubInitiative, +// requestOptions: IHubRequestOptions, +// query?: IQuery +// ): Promise { +// let projectQuery = getUnConnectedProjectsQuery(initiative); +// // combineQueries will purge undefined/null entries +// projectQuery = combineQueries([projectQuery, query]); - // negate the scope, combine that with the base query - query = combineQueries([query, negateGroupPredicates(qry)]); - return query; -} +// return queryAsEntityInfo(projectQuery, requestOptions); +// } +// /** +// * Un-connected projects are those without Initiative id in the typekeywords +// * and is NOT included in the Initiative's catalog. +// * This can be used to locate "Other" Projects +// * @param initiative +// * @returns +// */ +// export function getUnConnectedProjectsQuery( +// initiative: IHubInitiative +// ): IQuery { +// // get query that returns Hub Projects with the initiative keyword +// let query = getTypeWithoutKeywordQuery( +// "Hub Project", +// `initiative|${initiative.id}` +// ); +// // The the item scope from the catalog... +// const qry = getProp(initiative, "catalog.scopes.item"); + +// // negate the scope, combine that with the base query +// query = combineQueries([query, negateGroupPredicates(qry)]); +// return query; +// } diff --git a/packages/common/src/projects/fetch.ts b/packages/common/src/projects/fetch.ts index 91025657b74..ef640a69cf0 100644 --- a/packages/common/src/projects/fetch.ts +++ b/packages/common/src/projects/fetch.ts @@ -148,14 +148,14 @@ export async function enrichProjectSearchResult( * chosen to connect to. If project has not defined any associations * to any Initiatives, will return `null`. * Currently, we have not implemented a means to get the list of initiatives that have - * "Approved" the Project via inclusion in it's catalog. + * "Accepted" the Project via inclusion in it's catalog. * * If needed, this could be done by getting all the groups the project is shared into - * then cross-walking that into the catalogs of all the Connected Initiatives + * then cross-walking that into the catalogs of all the Associated Initiatives * @param project * @returns */ -export function getConnectedInitiativesQuery(project: IHubProject): IQuery { +export function getAssociatedInitiativesQuery(project: IHubProject): IQuery { // get the list of ids from the keywords const ids = listAssociations(project, "initiative").map((a) => a.id); if (ids.length) { diff --git a/packages/common/src/search/hubSearch.ts b/packages/common/src/search/hubSearch.ts index 8cf6d8fc9c0..4a93be80b72 100644 --- a/packages/common/src/search/hubSearch.ts +++ b/packages/common/src/search/hubSearch.ts @@ -8,14 +8,13 @@ import { IQuery, } from "./types"; import { getApi } from "./_internal/commonHelpers/getApi"; -import { - hubSearchItems, - portalSearchItems, - portalSearchGroups, - portalSearchUsers, - hubSearchChannels, -} from "./_internal"; + import { portalSearchGroupMembers } from "./_internal/portalSearchGroupMembers"; +import { portalSearchItems } from "./_internal/portalSearchItems"; +import { portalSearchGroups } from "./_internal/portalSearchGroups"; +import { portalSearchUsers } from "./_internal/portalSearchUsers"; +import { hubSearchItems } from "./_internal/hubSearchItems"; +import { hubSearchChannels } from "./_internal/hubSearchChannels"; /** * Main entrypoint for searching via Hub diff --git a/packages/common/src/search/utils.ts b/packages/common/src/search/utils.ts index bd43d806801..25888f2555b 100644 --- a/packages/common/src/search/utils.ts +++ b/packages/common/src/search/utils.ts @@ -30,7 +30,7 @@ import { LegacySearchCategory, } from "./_internal/commonHelpers/isLegacySearchCategory"; import { toCollectionKey } from "./_internal/commonHelpers/toCollectionKey"; -import { expandQuery } from "./_internal"; +import { expandQuery } from "./_internal/portalSearchItems"; /** * Well known APIs diff --git a/packages/common/src/users/HubUsers.ts b/packages/common/src/users/HubUsers.ts index d941da796ef..f9d06669b67 100644 --- a/packages/common/src/users/HubUsers.ts +++ b/packages/common/src/users/HubUsers.ts @@ -1,13 +1,14 @@ import { IUser } from "@esri/arcgis-rest-types"; import { fetchUserEnrichments } from "./_internal/enrichments"; import { getProp } from "../objects"; -import { getUserThumbnailUrl, IHubSearchResult } from "../search"; +import { getUserThumbnailUrl } from "../search/utils"; import { parseInclude } from "../search/_internal/parseInclude"; import { IHubRequestOptions } from "../types"; import { getUserHomeUrl } from "../urls"; import { unique } from "../util"; import { mapBy } from "../utils"; import { AccessLevel } from "../core"; +import { IHubSearchResult } from "../search/types/IHubSearchResult"; /** * Enrich a User object diff --git a/packages/common/test/initiatives/HubInitiatives.test.ts b/packages/common/test/initiatives/HubInitiatives.test.ts index f379d23b0d0..a55ba9c54ea 100644 --- a/packages/common/test/initiatives/HubInitiatives.test.ts +++ b/packages/common/test/initiatives/HubInitiatives.test.ts @@ -12,12 +12,10 @@ import { fetchInitiative, deleteInitiative, updateInitiative, - getAssociatedProjectsQuery, - getConnectedProjectsQuery, - getUnConnectedProjectsQuery, - fetchAssociatedProjects, - fetchConnectedProjects, - fetchUnConnectedProjects, + getPendingProjectsQuery, + getAcceptedProjectsQuery, + fetchAcceptedProjects, + fetchPendingProjects, } from "../../src/initiatives/HubInitiatives"; import { IHubInitiative } from "../../src/core/types/IHubInitiative"; import { cloneObject } from "../../src/util"; @@ -431,7 +429,7 @@ describe("HubInitiatives:", () => { } as unknown as IHubInitiative; }); it("getAssociatedProjectsQuery", () => { - const chk = getAssociatedProjectsQuery(fixture); + const chk = getAcceptedProjectsQuery(fixture); expect(chk.targetEntity).toBe("item"); // ensure we have type and keyword in predicate expect(verifyPredicate(chk, { type: "Hub Project" })).toBeTruthy(); @@ -441,7 +439,7 @@ describe("HubInitiatives:", () => { expect(getPredicateValue(chk, { group: null })).toEqual(["00c", "aa1"]); }); it("getConnectedProjectsQuery", () => { - const chk = getConnectedProjectsQuery(fixture); + const chk = getPendingProjectsQuery(fixture); expect(chk.targetEntity).toBe("item"); // ensure we have type and keyword in predicate expect(verifyPredicate(chk, { type: "Hub Project" })).toBeTruthy(); @@ -454,27 +452,27 @@ describe("HubInitiatives:", () => { not: ["00c", "aa1"], }); }); - it("getUnConnectedProjectsQuery", () => { - const chk = getUnConnectedProjectsQuery(fixture); - expect(chk.targetEntity).toBe("item"); - // ensure we have type and keyword in predicate - expect(verifyPredicate(chk, { type: "Hub Project" })).toBeTruthy(); + // it("getUnConnectedProjectsQuery", () => { + // const chk = getUnConnectedProjectsQuery(fixture); + // expect(chk.targetEntity).toBe("item"); + // // ensure we have type and keyword in predicate + // expect(verifyPredicate(chk, { type: "Hub Project" })).toBeTruthy(); - expect(getPredicateValue(chk, { typekeywords: null })).toEqual( - { - not: ["initiative|00f"], - }, - "should have negated keyword" - ); - expect(getPredicateValue(chk, { group: null })).toEqual({ - any: [], - all: [], - not: ["00c", "aa1"], - }); - }); + // expect(getPredicateValue(chk, { typekeywords: null })).toEqual( + // { + // not: ["initiative|00f"], + // }, + // "should have negated keyword" + // ); + // expect(getPredicateValue(chk, { group: null })).toEqual({ + // any: [], + // all: [], + // not: ["00c", "aa1"], + // }); + // }); }); - describe("fetchAssociated:", () => { + describe("fetchAccepted:", () => { let searchSpy: jasmine.Spy; let fixture: IHubInitiative; beforeEach(() => { @@ -517,7 +515,7 @@ describe("HubInitiatives:", () => { } as unknown as IHubInitiative; }); it("fetches associated projects", async () => { - const chk = await fetchAssociatedProjects(fixture, MOCK_AUTH); + const chk = await fetchAcceptedProjects(fixture, MOCK_AUTH); expect(searchSpy).toHaveBeenCalled(); // get the query const qry = searchSpy.calls.argsFor(0)[0]; @@ -531,27 +529,8 @@ describe("HubInitiatives:", () => { type: "Hub Project", }); }); - it("fetches connected projects", async () => { - const chk = await fetchConnectedProjects(fixture, MOCK_AUTH); - expect(searchSpy).toHaveBeenCalled(); - // get the query - const qry = searchSpy.calls.argsFor(0)[0]; - // this should have the negated groups in the predicate - expect(getPredicateValue(qry, { group: null })).toEqual({ - any: [], - all: [], - not: ["00c", "aa1"], - }); - expect(chk.length).toBe(1); - // verify conversion - expect(chk[0]).toEqual({ - id: "3ef", - name: "fake result", - type: "Hub Project", - }); - }); - it("fetches unconnected projects", async () => { - const chk = await fetchUnConnectedProjects(fixture, MOCK_AUTH); + it("fetches pending projects", async () => { + const chk = await fetchPendingProjects(fixture, MOCK_AUTH); expect(searchSpy).toHaveBeenCalled(); // get the query const qry = searchSpy.calls.argsFor(0)[0]; @@ -561,12 +540,6 @@ describe("HubInitiatives:", () => { all: [], not: ["00c", "aa1"], }); - expect(getPredicateValue(qry, { typekeywords: null })).toEqual( - { - not: ["initiative|00f"], - }, - "should have negated keyword" - ); expect(chk.length).toBe(1); // verify conversion expect(chk[0]).toEqual({ @@ -575,6 +548,34 @@ describe("HubInitiatives:", () => { type: "Hub Project", }); }); + // ALTHOUGH WE DON"T CURRENTLY HAVE A UX THAT NEEDS THIS + // THERE IS SOME DISCUSSION ABOUT IT BEING USEFUL SO I'M LEAVING + // THE CODE HERE, COMMENTED. + // it("fetches unconnected projects", async () => { + // const chk = await fetchUnConnectedProjects(fixture, MOCK_AUTH); + // expect(searchSpy).toHaveBeenCalled(); + // // get the query + // const qry = searchSpy.calls.argsFor(0)[0]; + // // this should have the negated groups in the predicate + // expect(getPredicateValue(qry, { group: null })).toEqual({ + // any: [], + // all: [], + // not: ["00c", "aa1"], + // }); + // expect(getPredicateValue(qry, { typekeywords: null })).toEqual( + // { + // not: ["initiative|00f"], + // }, + // "should have negated keyword" + // ); + // expect(chk.length).toBe(1); + // // verify conversion + // expect(chk[0]).toEqual({ + // id: "3ef", + // name: "fake result", + // type: "Hub Project", + // }); + // }); }); }); diff --git a/packages/common/test/projects/fetch.test.ts b/packages/common/test/projects/fetch.test.ts index fa7725cb2a5..0423210db8d 100644 --- a/packages/common/test/projects/fetch.test.ts +++ b/packages/common/test/projects/fetch.test.ts @@ -5,7 +5,7 @@ import { cloneObject, enrichProjectSearchResult, fetchProject, - getConnectedInitiativesQuery, + getAssociatedInitiativesQuery, } from "../../src"; import { GUID, PROJECT_DATA, PROJECT_ITEM, PROJECT_LOCATION } from "./fixtures"; import { MOCK_AUTH } from "../mocks/mock-auth"; @@ -182,12 +182,12 @@ describe("project fetch module:", () => { }); }); - describe("getConnectedInitiativesQuery:", () => { - it("returns query if project is connected", () => { + describe("getAssociatedInitiativesQuery:", () => { + it("returns query if project is associated", () => { const p: IHubProject = { typeKeywords: ["initiative|00c", "initiative|00d"], } as unknown as IHubProject; - const chk = getConnectedInitiativesQuery(p); + const chk = getAssociatedInitiativesQuery(p); expect(chk.targetEntity).toEqual("item"); expect(chk.filters[0].predicates[0].type).toBe("Hub Initiative"); expect(chk.filters[0].predicates[0].id).toEqual(["00c", "00d"]); @@ -197,7 +197,7 @@ describe("project fetch module:", () => { const p: IHubProject = { typeKeywords: [], } as unknown as IHubProject; - const chk = getConnectedInitiativesQuery(p); + const chk = getAssociatedInitiativesQuery(p); expect(chk).toBeNull(); }); }); diff --git a/packages/common/test/search/hubSearch.test.ts b/packages/common/test/search/hubSearch.test.ts index c84d36b350c..8fcf6c7d308 100644 --- a/packages/common/test/search/hubSearch.test.ts +++ b/packages/common/test/search/hubSearch.test.ts @@ -1,8 +1,6 @@ import { IHubSearchOptions, IQuery } from "../../src"; import { hubSearch } from "../../src/search/hubSearch"; -import * as SearchFunctionModule from "../../src/search/_internal"; - describe("hubSearch Module:", () => { describe("hubSearch:", () => { describe("guards:", () => { @@ -95,7 +93,7 @@ describe("hubSearch Module:", () => { // we are only interested in verifying that the fn was called with specific args // so all the responses are fake portalSearchItemsSpy = spyOn( - SearchFunctionModule, + require("../../src/search/_internal/portalSearchItems"), "portalSearchItems" ).and.callFake(() => { return Promise.resolve({ @@ -105,7 +103,7 @@ describe("hubSearch Module:", () => { }); }); portalSearchGroupsSpy = spyOn( - SearchFunctionModule, + require("../../src/search/_internal/portalSearchGroups"), "portalSearchGroups" ).and.callFake(() => { return Promise.resolve({ @@ -115,7 +113,7 @@ describe("hubSearch Module:", () => { }); }); hubSearchItemsSpy = spyOn( - SearchFunctionModule, + require("../../src/search/_internal/hubSearchItems"), "hubSearchItems" ).and.callFake(() => { return Promise.resolve({ @@ -125,7 +123,7 @@ describe("hubSearch Module:", () => { }); }); hubSearchChannelsSpy = spyOn( - SearchFunctionModule, + require("../../src/search/_internal/hubSearchChannels"), "hubSearchChannels" ).and.callFake(() => { return Promise.resolve({ diff --git a/packages/common/test/search/utils.test.ts b/packages/common/test/search/utils.test.ts index efefb21b5fd..e47494b76a1 100644 --- a/packages/common/test/search/utils.test.ts +++ b/packages/common/test/search/utils.test.ts @@ -1,10 +1,5 @@ import { IGroup, ISearchOptions, IUser } from "@esri/arcgis-rest-portal"; -import { - IHubSite, - IQuery, - ISearchResponse, - getGroupPredicate, -} from "../../src"; +import { IHubSite, IQuery, ISearchResponse } from "../../src"; import { IHubSearchResult, IRelativeDate } from "../../src/search"; import { expandApis, @@ -15,6 +10,7 @@ import { getNextFunction, migrateToCollectionKey, getResultSiteRelativeLink, + getGroupPredicate, } from "../../src/search/utils"; import { MOCK_AUTH } from "../mocks/mock-auth"; import { mockUserSession } from "../test-helpers/fake-user-session";