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

Enhances spo page section add with collapsibleTitle option. Closes #6461 #6471

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkm17
Copy link
Contributor

@mkm17 mkm17 commented Nov 5, 2024

Closes #6461

Let me know if there are any comments or changes needed.

In other commands, I recall there was a suggestion to make some changes in the tests, specifically to check stubPost.lastCall.args[0].data instead of directly comparing the data in this style assert.strictEqual(data, JSON.stringify (...)

@milanholemans
Copy link
Contributor

Thanks @mkm17, we'll try to review it ASAP!

@milanholemans milanholemans self-assigned this Dec 15, 2024
Copy link
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

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

Let's change a few things before we merge it.
Just like you mentioned in your PR description we should indeed check for a deep equal of the last stubbed request. In the past, we sometimes implemented things differently, but over the years you learn how to make things better. Therefore we always ask our contributors to use the latest approach when adding new code.

@@ -904,6 +904,42 @@ describe(commands.PAGE_SECTION_ADD, () => {
assert.strictEqual(data, JSON.stringify({ "CanvasContent1": "[{\"displayMode\":2,\"position\":{\"zoneIndex\":1,\"sectionIndex\":1,\"sectionFactor\":12,\"layoutIndex\":1},\"emphasis\":{},\"zoneGroupMetadata\":{\"type\":1,\"isExpanded\":false,\"showDividerLine\":false,\"iconAlignment\":\"left\"}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]" }));
});

it('adds a OneColumn section at the end to an uncustomized page with collapsible setting and section title', async () => {
sinon.stub(request, 'get').callsFake(async (opts) => {
if ((opts.url as string).includes(`/_api/sitepages/pages/GetByUrl('sitepages/home.aspx')?$select=CanvasContent1,IsPageCheckedOutToCurrentUser`)) {
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 check for the absolute URL instead of includes.


let data: string = '';
sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).includes(`/_api/sitepages/pages/GetByUrl('sitepages/home.aspx')/savepage`)) {
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 check for the absolute URL instead of includes.

sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).includes(`/_api/sitepages/pages/GetByUrl('sitepages/home.aspx')/savepage`)) {
data = JSON.stringify(opts.data);
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return {};
return;

collapsibleTitle: 'Collapsible section title'
}
});
assert.strictEqual(data, JSON.stringify({ "CanvasContent1": "[{\"displayMode\":2,\"position\":{\"zoneIndex\":1,\"sectionIndex\":1,\"sectionFactor\":12,\"layoutIndex\":1},\"emphasis\":{},\"zoneGroupMetadata\":{\"type\":1,\"isExpanded\":false,\"showDividerLine\":false,\"iconAlignment\":\"right\",\"displayName\":\"Collapsible section title\"}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]" }));
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of checking it this way, let's use a deep equal on postStub.lastCall.

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 add the new option to the example where a collapsible section is created.

@milanholemans milanholemans marked this pull request as draft December 16, 2024 22:53
@mkm17
Copy link
Contributor Author

mkm17 commented Dec 20, 2024

@milanholemans Thank you for the confirmation. I just wanted to double-check if these changes are also needed. I appreciate it, and I will try to make the changes promptly.

@mkm17 mkm17 force-pushed the issues/6461_collapsible_section_title branch from 4d2fa5b to 4a1e63c Compare December 21, 2024 22:25
@mkm17
Copy link
Contributor Author

mkm17 commented Dec 21, 2024

Hi @milanholemans, I have added the requested changes to the entire test file (not just the new code). I hope that is ok. And of course I have included a new example in the documentation.

@mkm17 mkm17 marked this pull request as ready for review December 21, 2024 22:29
@milanholemans
Copy link
Contributor

Hi @milanholemans, I have added the requested changes to the entire test file (not just the new code). I hope that is ok. And of course I have included a new example in the documentation.

Wow, thanks for the commitment. We really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants