Skip to content

Commit

Permalink
feat(hub-sites): initiatives are no longer created during site creati…
Browse files Browse the repository at this point in the history
…on (#1564)

BREAKING CHANGE: removes logic to automatically create an initiative during the site creation process
  • Loading branch information
juliannemarik authored Jun 27, 2024
1 parent b02db7f commit 1f54908
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
31 changes: 0 additions & 31 deletions packages/sites/src/create-site-model-from-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,6 @@ export function createSiteModelFromTemplate(
settings.solution.defaultHostname = `${uniqueSubdomain}-${portal.urlKey}.${base}`;
settings.solution.url = `https://${uniqueSubdomain}-${portal.urlKey}.${base}`;
}

// create the initiative
let handleInitiative = Promise.resolve(null);

if (product !== "portal") {
handleInitiative = _createSiteInitiative(
template,
settings,
transforms,
hubRequestOptions
);
}
return handleInitiative;
})
.then((maybeInitiative) => {
// if we got an initiative back...
let teamUpdatePromise = Promise.resolve(null);
if (maybeInitiative) {
// add to settings hash so it's available to the site
// typically all that's used is initiative.item.id
settings.initiative = maybeInitiative;
// directly set the parentInitiativeId vs relying on adlib
template.item.properties.parentInitiativeId = maybeInitiative.item.id;
// check if we created a followers team because we need to add the initiativeId into a tag
teamUpdatePromise = _updateTeamTags(
maybeInitiative,
state.teams,
hubRequestOptions
);
}
return teamUpdatePromise;
})
.then((_) => {
const siteModel = interpolateSite(template, settings, transforms);
Expand Down
29 changes: 2 additions & 27 deletions packages/sites/test/create-site-model-from-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ describe("createSiteModelFromTemplate", () => {
let getProductSpy: jasmine.Spy;
let createTeamsSpy: jasmine.Spy;
let ensureDomainSpy: jasmine.Spy;
let createInitiativeSpy: jasmine.Spy;
let updateTeamTagsSpy: jasmine.Spy;
beforeEach(() => {
getProductSpy = spyOn(commonModule, "getHubProduct").and.returnValue(
"premium"
Expand All @@ -148,16 +146,6 @@ describe("createSiteModelFromTemplate", () => {
commonModule,
"ensureUniqueDomainName"
).and.returnValue(Promise.resolve(uniqueDomain));

createInitiativeSpy = spyOn(
createSiteModule,
"_createSiteInitiative"
).and.returnValue(Promise.resolve(initiativeResponse));

updateTeamTagsSpy = spyOn(
updateTagsModule,
"_updateTeamTags"
).and.returnValue(Promise.resolve());
});

it("creates the site on premium", async () => {
Expand Down Expand Up @@ -189,10 +177,7 @@ describe("createSiteModelFromTemplate", () => {
);
expect(createdSite.data.values.subdomain).toBe(`unique-domain`);

expectAllCalled(
[createTeamsSpy, ensureDomainSpy, createInitiativeSpy, updateTeamTagsSpy],
expect
);
expectAllCalled([createTeamsSpy, ensureDomainSpy], expect);

expect(createdSite.item.properties.contentGroupId).toBe(
teams.props.contentGroupId
Expand Down Expand Up @@ -234,10 +219,7 @@ describe("createSiteModelFromTemplate", () => {
);
expect(createdSite.data.values.subdomain).toBe(`unique-domain`);

expectAllCalled(
[createTeamsSpy, ensureDomainSpy, createInitiativeSpy, updateTeamTagsSpy],
expect
);
expectAllCalled([createTeamsSpy, ensureDomainSpy], expect);

expect(createdSite.item.properties.contentGroupId).toBe(
teams.props.contentGroupId
Expand Down Expand Up @@ -281,13 +263,6 @@ describe("createSiteModelFromTemplate", () => {
expect(createdSite.data.values.subdomain).toBe(`unique-domain`);

expectAllCalled([createTeamsSpy, ensureDomainSpy], expect);
// create initiative stuff shouldnt be called on portal
expectAll(
[createInitiativeSpy, updateTeamTagsSpy],
"toHaveBeenCalled",
false,
expect
);

expect(createdSite.item.properties.contentGroupId).toBe(
teams.props.contentGroupId
Expand Down

0 comments on commit 1f54908

Please sign in to comment.