-
Notifications
You must be signed in to change notification settings - Fork 362
New command: spo site alert remove. Closes #6863 #6997
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
base: main
Are you sure you want to change the base?
Conversation
Thanks @Saurabh7019! We'll try to review it ASAP. |
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.
The command is nearly perfect! When the comments below are processed, it looks good to go.
webUrl: zod.alias('u', z.string()) | ||
.refine(url => validation.isValidSharePointUrl(url) === true, url => ({ | ||
message: `'${url}' is not a valid SharePoint URL.` | ||
})), |
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.
The zod.alias
should include the refine
as well. Otherwise, the alias is not registered correctly and cannot be used.
webUrl: zod.alias('u', z.string()) | |
.refine(url => validation.isValidSharePointUrl(url) === true, url => ({ | |
message: `'${url}' is not a valid SharePoint URL.` | |
})), | |
webUrl: zod.alias('u', z.string() | |
.refine(url => validation.isValidSharePointUrl(url) === true, url => ({ | |
message: `'${url}' is not a valid SharePoint URL.` | |
}))), |
} | ||
|
||
public get description(): string { | ||
return 'Removes an alert from a SharePoint site'; |
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.
return 'Removes an alert from a SharePoint site'; | |
return 'Removes an alert from a SharePoint list'; |
|
||
# spo site alert remove | ||
|
||
Removes an alert from a SharePoint site |
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.
Removes an alert from a SharePoint site | |
Removes an alert from a SharePoint list |
await request.delete(requestOptions); | ||
} | ||
catch (err: any) { | ||
this.handleRejectedPromise(err); |
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.
this.handleRejectedPromise(err); | |
this.handleRejectedODataJsonPromise(err); |
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.
sorry for the delay :)
handleRejectedPromise
is showing cleaner error instead of raw xml.
with handleRejectedODataJsonPromise, I am getting below:
Error: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2146232832, Microsoft.SharePoint.SPException</m:code><m:message xml:lang="en-US">The alert you are trying to access does not exist or has just been deleted. </m:message></m:error>
should I keep the current one?
}); | ||
|
||
it('prompts before removing the alert', async () => { | ||
await command.action(logger, { options: commandOptionsSchema.parse({ webUrl: webUrl, id: alertId }) }); |
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.
The parsing of the options is not needed. Let's fix this for other tests as well.
await command.action(logger, { options: commandOptionsSchema.parse({ webUrl: webUrl, id: alertId }) }); | |
await command.action(logger, { options: { webUrl: webUrl, id: alertId } }); |
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.
Sure, I will fix it. I was asked to add it on another PR.
}); | ||
|
||
it('aborts removing the alert when prompt is not confirmed', async () => { | ||
const deleteStub = sinon.stub(request, 'delete').resolves({}); |
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.
const deleteStub = sinon.stub(request, 'delete').resolves({}); | |
const deleteStub = sinon.stub(request, 'delete').resolves(); |
|
||
it('correctly handles random API error', async () => { | ||
sinon.stub(request, 'delete').rejects( | ||
new Error('The alert you are trying to access does not exist or has just been deleted.') |
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.
This is not how a failing API call to SharePoint would look like. Instead, let's make it as realistic as possible with a read failing request body.
: The ID of the alert. | ||
|
||
`-f, --force` | ||
: Don't prompt for confirmation |
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.
: Don't prompt for confirmation | |
: Don't prompt for confirmation. |
Closes #6863