Skip to content
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

Added internalName option for spo field commands #6379

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ktskumar
Copy link
Contributor

Closes #6249

In this PR, i have added internalName option to below commands

  • spo field get
  • spo field set
  • spo field remove

@milanholemans
Copy link
Contributor

Thank you, we'll try to review it ASAP!

@MathijsVerbeeck MathijsVerbeeck self-assigned this Nov 13, 2024

it('should call the correct GET url when field internalName and list url specified', async () => {
const getStub = sinon.stub(request, 'get').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please use full URL's instead of using indexOf please? Please do this for all your tests

const getStub = sinon.stub(request, 'get').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) {
return {
"Id": "03e45e84-1992-4d42-9116-26f756012634"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's use single quotes

@@ -320,6 +320,51 @@ describe(commands.FIELD_GET, () => {
assert.strictEqual(getStub.lastCall.args[0].url, 'https://contoso.sharepoint.com/sites/portal/_api/web/lists(guid\'03e45e84-1992-4d42-9116-26f756012634\')/fields/getbyinternalnameortitle(\'Title\')');
});

it('should call the correct GET url when field internalName and list title specified (verbose)', async () => {
const getStub = sinon.stub(request, 'get').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's use full url's

@@ -117,6 +122,9 @@ class SpoFieldGetCommand extends SpoCommand {
if (args.options.id) {
fieldRestUrl = `/getbyid('${formatting.encodeQueryParameter(args.options.id)}')`;
}
else if (args.options.internalName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not do something like:

Suggested change
else if (args.options.internalName) {
else {
fieldRestUrl = `/getbyinternalnameortitle('${formatting.encodeQueryParameter(args.options.internalName || args.options.title)}')`;
}

@@ -454,6 +466,51 @@ describe(commands.FIELD_REMOVE, () => {
assert.strictEqual(getStub.lastCall.args[0].url, 'https://contoso.sharepoint.com/sites/portal/_api/web/lists(guid\'03e45e84-1992-4d42-9116-26f756012634\')/fields/getbyinternalnameortitle(\'Title\')');
});

it('calls the correct get url when field internalName and list title specified (verbose)', async () => {
const getStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's use full URLs

@@ -112,6 +112,44 @@ describe(commands.FIELD_SET, () => {
assert(loggerLogSpy.notCalled);
});

it('updates site column specified by internalName', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_vti_bin/client.svc/ProcessQuery`) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use full urls

@MathijsVerbeeck MathijsVerbeeck marked this pull request as draft November 29, 2024 15:22
@ktskumar ktskumar marked this pull request as ready for review December 21, 2024 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add internalName option for spo field commands
3 participants