-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds m365 spo tenant homesite add
. Closes #6488
#6533
Closed
Closed
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
633959a
add new cmdlet to add home site
reshmee011 7d2a270
update to add additional parameters
reshmee011 f79efd4
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 a5d46e7
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 8f7a2d4
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 4a6dd5b
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 19ea2ae
Update src/m365/spo/commands/tenant/tenant-homesite-add.ts
reshmee011 0fe6459
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 de55555
Update src/m365/spo/commands/tenant/tenant-homesite-add.ts
reshmee011 69fb83b
updates based on comments
reshmee011 ba56f92
Merge branch 'pnp:main' into addhomesite
reshmee011 b63164c
updates based on Milan's comments
reshmee011 582d528
Add validation for integers and guids
reshmee011 2d67b4d
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 e35c835
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 09445cf
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 c7765e1
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 cb3a024
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 708a14a
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 74404fa
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 2937f55
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 72023e1
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 40214d4
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 3e95a3d
Update src/m365/spo/commands/tenant/tenant-homesite-add.ts
reshmee011 b3fe02d
Update src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
reshmee011 eb14f25
Update docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx
reshmee011 312962a
Merge branch 'main' into addhomesite
reshmee011 bbfe113
rename home site add to remove reference to tenant
reshmee011 6e2ae30
amend to zod
reshmee011 90fb463
updated test
reshmee011 8c3b8fc
update test
reshmee011 b2c2e95
change to zod schema
reshmee011 d1ffd0a
updates
reshmee011 5cd799f
update test script
reshmee011 9d43564
updates
reshmee011 972779f
Update src/m365/spo/commands/homesite/homesite-add.ts
reshmee011 dbaafc9
Update src/m365/spo/commands/homesite/homesite-add.ts
reshmee011 0d8321b
Update docs/docs/cmd/spo/homesite/homesite-add.mdx
reshmee011 130c439
Update docs/docs/cmd/spo/homesite/homesite-add.mdx
reshmee011 81c6411
Merge branch 'pnp:main' into addhomesite
reshmee011 5fdfc4d
update based on feedback
reshmee011 b9d86b0
update test
reshmee011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import Global from '/docs/cmd/_global.mdx'; | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# spo tenant homesite add | ||
|
||
Add a Home Site. | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Usage | ||
|
||
```sh | ||
m365 spo tenant homesite add [options] | ||
``` | ||
|
||
## Options | ||
|
||
```md definition-list | ||
`-u, --url <url>` | ||
: URL of the site to set as the home site. | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`--isInDraftMode [isInDraftMode]` | ||
: Specifies whether the home site is in draft mode. Accepts `true` or `false`. | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`--vivaConnectionsDefaultStart [vivaConnectionsDefaultStart]` | ||
: Specifies whether the home site is the default start for Viva Connections. Accepts `true` or `false`. | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`--audiences [audiences]` | ||
: Comma-separated list of audience GUIDs. | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`--order [order]` | ||
: Order of the home site. Must be an integer. | ||
``` | ||
|
||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Examples | ||
|
||
Add a Home Site | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```sh | ||
m365 spo tenant homesite add --url "https://contoso.sharepoint.com/sites/testcomms" | ||
``` | ||
|
||
Add a Home Site with optional parameters | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```sh | ||
m365 spo tenant homesite add --url "https://contoso.sharepoint.com/sites/testcomms" --isInDraftMode true --vivaConnectionsDefaultStart false --audiences "af8c0bc8-7b1b-44b4-b087-ffcc8df70d16,754ff15c-76b1-44cb-88c7-0065a4d3cfb7" --order 2 | ||
``` | ||
## Response | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<Tabs> | ||
<TabItem value="JSON"> | ||
|
||
```json | ||
{ | ||
"Audiences": [], | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"IsInDraftMode": true, | ||
"IsVivaBackendSite": false, | ||
"SiteId": "ca49054c-85f3-41eb-a290-46ffda8f219c", | ||
"TargetedLicenseType": 0, | ||
"Title": "testcommsite", | ||
"Url": "https://contoso.sharepoint.com/sites/testcomms", | ||
"VivaConnectionsDefaultStart": false, | ||
"WebId": "256c4f0f-e372-47b4-a891-b4888e829e20" | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Text"> | ||
|
||
```text | ||
Audiences : [] | ||
IsInDraftMode : true | ||
IsVivaBackendSite : false | ||
SiteId : ca49054c-85f3-41eb-a290-46ffda8f219c | ||
TargetedLicenseType : 0 | ||
Title : testcommsite | ||
Url : https://contoso.sharepoint.com/sites/testcomms | ||
VivaConnectionsDefaultStart: false | ||
WebId : 256c4f0f-e372-47b4-a891-b4888e829e20 | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="CSV"> | ||
|
||
```csv | ||
IsInDraftMode,IsVivaBackendSite,SiteId,TargetedLicenseType,Title,Url,VivaConnectionsDefaultStart,WebId | ||
1,0,ca49054c-85f3-41eb-a290-46ffda8f219c,0,testcommsite,https://contoso.sharepoint.com/sites/testcomms,0,256c4f0f-e372-47b4-a891-b4888e829e20 | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Markdown"> | ||
|
||
```md | ||
# spo tenant homesite add --url "https://contoso.sharepoint.com/sites/testcomms" | ||
|
||
Date: 12/23/2024 | ||
|
||
## testcommsite (https://contoso.sharepoint.com/sites/testcomms) | ||
|
||
Property | Value | ||
---------|------- | ||
IsInDraftMode | true | ||
IsVivaBackendSite | false | ||
SiteId | ca49054c-85f3-41eb-a290-46ffda8f219c | ||
TargetedLicenseType | 0 | ||
Title | testcommsite | ||
Url | https://contoso.sharepoint.com/sites/testcomms | ||
VivaConnectionsDefaultStart | false | ||
WebId | 256c4f0f-e372-47b4-a891-b4888e829e20 | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
## More information | ||
|
||
- SharePoint home sites [Viva Connections set up](https://learn.microsoft.com/en-us/viva/connections/set-up-admin-center) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import assert from 'assert'; | ||
import sinon from 'sinon'; | ||
import auth from '../../../../Auth.js'; | ||
import { cli } from '../../../../cli/cli.js'; | ||
import { Logger } from '../../../../cli/Logger.js'; | ||
import { CommandError } from '../../../../Command.js'; | ||
import { CommandInfo } from '../../../../cli/CommandInfo.js'; | ||
import request from '../../../../request.js'; | ||
import { telemetry } from '../../../../telemetry.js'; | ||
import { pid } from '../../../../utils/pid.js'; | ||
import { session } from '../../../../utils/session.js'; | ||
import { sinonUtil } from '../../../../utils/sinonUtil.js'; | ||
import commands from '../../commands.js'; | ||
import command from './tenant-homesite-add.js'; | ||
|
||
describe(commands.TENANT_HOMESITE_ADD, () => { | ||
let log: string[]; | ||
let logger: Logger; | ||
let loggerLogSpy: sinon.SinonSpy; | ||
let commandInfo: CommandInfo; | ||
const homeSite = "https://contoso.sharepoint.com/sites/testcomms"; | ||
const homeSites = { | ||
"Audiences": [], | ||
"IsInDraftMode": true, | ||
"IsVivaBackendSite": false, | ||
"SiteId": "ca49054c-85f3-41eb-a290-46ffda8f219c", | ||
"TargetedLicenseType": 0, | ||
"Title": "testcommsite", | ||
"Url": homeSite, | ||
"VivaConnectionsDefaultStart": false, | ||
"WebId": "256c4f0f-e372-47b4-a891-b4888e829e20" | ||
}; | ||
|
||
const homeSiteConfig = { | ||
"Audiences": [ | ||
{ | ||
"Email": "[email protected]", | ||
"Id": "af8c0bc8-7b1b-44b4-b087-ffcc8df70d16", | ||
"Title": "SharingTest Members" | ||
} | ||
], | ||
"IsInDraftMode": true, | ||
"IsVivaBackendSite": false, | ||
"SiteId": "ca49054c-85f3-41eb-a290-46ffda8f219c", | ||
"TargetedLicenseType": 0, | ||
"Title": "testcommsite", | ||
"Url": "https://contoso.sharepoint.com/sites/testcomms", | ||
"VivaConnectionsDefaultStart": false, | ||
"WebId": "256c4f0f-e372-47b4-a891-b4888e829e20" | ||
}; | ||
|
||
before(() => { | ||
sinon.stub(auth, 'restoreAuth').resolves(); | ||
sinon.stub(telemetry, 'trackEvent').returns(); | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sinon.stub(pid, 'getProcessName').returns(''); | ||
sinon.stub(session, 'getId').returns(''); | ||
auth.connection.active = true; | ||
auth.connection.spoUrl = 'https://contoso.sharepoint.com'; | ||
}); | ||
|
||
beforeEach(() => { | ||
log = []; | ||
logger = { | ||
log: async (msg: string) => { | ||
log.push(msg); | ||
}, | ||
logRaw: async (msg: string) => { | ||
log.push(msg); | ||
}, | ||
logToStderr: async (msg: string) => { | ||
log.push(msg); | ||
} | ||
}; | ||
loggerLogSpy = sinon.spy(logger, 'log'); | ||
commandInfo = cli.getCommandInfo(command); | ||
}); | ||
|
||
afterEach(() => { | ||
sinonUtil.restore([ | ||
request.post | ||
]); | ||
}); | ||
|
||
after(() => { | ||
sinon.restore(); | ||
auth.connection.active = false; | ||
auth.connection.spoUrl = undefined; | ||
}); | ||
|
||
it('has correct name', () => { | ||
assert.strictEqual(command.name, commands.TENANT_HOMESITE_ADD); | ||
}); | ||
|
||
it('has a description', () => { | ||
assert.notStrictEqual(command.description, null); | ||
}); | ||
|
||
it('adds available home sites', async () => { | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sinon.stub(request, 'post').callsFake(async (opts) => { | ||
if (opts.url === `https://contoso-admin.sharepoint.com/_api/SPHSite/AddHomeSite`) { | ||
return homeSites; | ||
} | ||
|
||
throw opts.url; | ||
}); | ||
|
||
await command.action(logger, { options: { url: homeSite, verbose: true } }); | ||
assert(loggerLogSpy.calledWith(homeSites)); | ||
}); | ||
|
||
it('adds a home site with the specified URL, isInDraftMode, vivaConnectionsDefaultStart, and audiences', async () => { | ||
sinon.stub(request, 'post').callsFake(async (opts) => { | ||
if (opts.url === `https://contoso-admin.sharepoint.com/_api/SPHSite/AddHomeSite`) { | ||
return homeSiteConfig; | ||
} | ||
|
||
throw 'Invalid request'; | ||
}); | ||
|
||
await command.action(logger, { | ||
options: { | ||
url: homeSite, | ||
isInDraftMode: 'true', | ||
vivaConnectionsDefaultStart: 'false', | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
audiences: 'af8c0bc8-7b1b-44b4-b087-ffcc8df70d16,754ff15c-76b1-44cb-88c7-0065a4d3cfb7', | ||
order: 2 | ||
} | ||
}); | ||
assert(loggerLogSpy.calledWith(homeSiteConfig)); | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
it('correctly handles invalid GUID in audiences', async () => { | ||
const result = await command.validate({ | ||
options: { | ||
url: homeSite, | ||
audiences: "invalidGuid,af8c0bc8-7b1b-44b4-b087-ffcc8df70d16" | ||
} | ||
}, commandInfo); | ||
assert.strictEqual(result, `invalidGuid is not a valid GUID`); | ||
}); | ||
|
||
it('correctly handles non-integer order', async () => { | ||
const result = await command.validate({ | ||
options: { | ||
url: homeSite, | ||
order: 'invalid-order' | ||
} | ||
}, commandInfo); | ||
assert.strictEqual(result, 'Order must be an integer'); | ||
}); | ||
|
||
it('fails validation if the url is not a valid SharePoint url', async () => { | ||
const actual = await command.validate({ | ||
options: { | ||
url: "test" | ||
} | ||
}, commandInfo); | ||
assert.notStrictEqual(actual, true); | ||
}); | ||
|
||
it('passes validation', async () => { | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const actual = await command.validate({ | ||
options: { | ||
url: homeSite | ||
} | ||
}, commandInfo); | ||
assert.strictEqual(actual, true); | ||
}); | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('correctly handles OData error when adding a home site', async () => { | ||
sinon.stub(request, 'post').rejects({ error: { 'odata.error': { message: { value: 'An error has occurred' } } } }); | ||
|
||
await assert.rejects(command.action(logger, { options: {} } as any), new CommandError('An error has occurred')); | ||
reshmee011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename everything from
spo tenant homesite add
tospo homesite add
.