Skip to content

Issue 3 - #4

Open
MichalFrends1 wants to merge 5 commits into
mainfrom
Issue-3
Open

Issue 3#4
MichalFrends1 wants to merge 5 commits into
mainfrom
Issue-3

Conversation

@MichalFrends1

@MichalFrends1 MichalFrends1 commented Jul 1, 2024

Copy link
Copy Markdown
Contributor

Issue 3

One of the tests is not passing because an account with admin permissions on Confluence is required.

Summary by CodeRabbit

  • New Features
    • Introduced new methods for managing Confluence pages and spaces, including creation, updating, retrieval, and deletion.
    • Added support for handling different content types like JSON, XML, and HTML in responses.
    • Added a new ConfluenceMethod enum to specify various Confluence operations.
  • Bug Fixes
    • Corrected the method naming for custom requests to improve clarity.
  • Tests
    • Added comprehensive tests for new Confluence operations to ensure functionality.
  • Documentation
    • Updated version and changelog to reflect new features and changes.

@coderabbitai

coderabbitai Bot commented Jul 1, 2024

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jefim has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 25 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 3ff2b1b and db8bec5.

Walkthrough

Version 1.0.1 of Frends.Confluence.Request introduces new methods for managing Confluence pages and spaces, renames the existing Request method to CustomRequest, and updates the project and supporting test files to ensure compatibility with the latest methods and project types.

Changes

File Path Change Summary
Frends.Confluence.Request/CHANGELOG.md Updated changelog to reflect the addition of new methods and the renaming of the Request method to CustomRequest.
Frends.Confluence.Request/.../Tests.cs Added new test methods for creating, updating, retrieving, and deleting pages and spaces in Confluence.
Frends.Confluence.Request/.../TestsBase.cs Introduced System.Linq, added PageId property, and adjusted the CreatePage method and JSON body structure.
Frends.Confluence.Request/.../Frends.Confluence.Request.sln Updated project type GUIDs and added a new GlobalSection with SolutionGuid.
Frends.Confluence.Request/.../Input.cs Introduced ConfluenceMethod enum and new properties to the Input class for supporting various Confluence operations.
Frends.Confluence.Request/.../Frends.Confluence.Request.csproj Updated version number from 1.0.0 to 1.0.1.
Frends.Confluence.Request/Request.cs Added several new methods for Confluence operations and renamed Request to CustomRequest.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frends.Confluence.Request
    participant ConfluenceAPI

    User ->> Frends.Confluence.Request: Call CustomRequest
    Frends.Confluence.Request ->> ConfluenceAPI: Make Custom API Call
    ConfluenceAPI -->> Frends.Confluence.Request: Return Response
    Frends.Confluence.Request -->> User: Return Result
Loading
sequenceDiagram
    participant User
    participant Frends.Confluence.Request
    participant ConfluenceAPI

    User ->> Frends.Confluence.Request: Call CreatePage / UpdatePage / GetPageById / DeletePage / GetPageByTitle
    Frends.Confluence.Request ->> ConfluenceAPI: Perform Page Operation
    ConfluenceAPI -->> Frends.Confluence.Request: Return Page Operation Result
    Frends.Confluence.Request -->> User: Return Result
Loading
sequenceDiagram
    participant User
    participant Frends.Confluence.Request
    participant ConfluenceAPI

    User ->> Frends.Confluence.Request: Call CreateSpace / DeleteSpace / GetSpaceByName
    Frends.Confluence.Request ->> ConfluenceAPI: Perform Space Operation
    ConfluenceAPI -->> Frends.Confluence.Request: Return Space Operation Result
    Frends.Confluence.Request -->> User: Return Result
Loading

Poem

In Confluence's land, we quest anew,
With pages and spaces, there's much to do.
Requests renamed, custom in flight,
GUIDs and tests now shining bright.
With each method, a step forward we take,
Building a world, for improvement’s sake.
Version 1.0.1, let's celebrate! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 12

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62a3543 and 04a4671.

Files selected for processing (7)
  • Frends.Confluence.Request/CHANGELOG.md (1 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request.Tests/Tests.cs (2 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request.Tests/TestsBase.cs (4 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request.sln (2 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request/Definitions/Input.cs (4 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request/Frends.Confluence.Request.csproj (1 hunks)
  • Frends.Confluence.Request/Frends.Confluence.Request/Request.cs (4 hunks)
Files skipped from review due to trivial changes (1)
  • Frends.Confluence.Request/Frends.Confluence.Request/Frends.Confluence.Request.csproj
Additional context used
LanguageTool
Frends.Confluence.Request/CHANGELOG.md

[uncategorized] ~11-~11: The preposition “to” seems more likely in this position than the preposition “for”.
Context: ... Changed - Changed Request method name for CustomRequest. ## [1.0.0] - 2024-05-21...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_FOR_TO)

GitHub Check: build / Build on windows-latest
Frends.Confluence.Request/Frends.Confluence.Request/Request.cs

[warning] 258-258:
XML comment has badly formed XML -- 'End tag was not expected at this location.'


[warning] 30-30:
XML comment has a param tag for 'token', but there is no parameter by that name


[warning] 32-32:
Parameter 'cancellationToken' has no matching param tag in the XML comment for 'Confluence.Request(Input, CancellationToken)' (but other parameters do)


[warning] 258-258:
XML comment has badly formed XML -- 'End tag was not expected at this location.'


[warning] 30-30:
XML comment has a param tag for 'token', but there is no parameter by that name


[warning] 32-32:
Parameter 'cancellationToken' has no matching param tag in the XML comment for 'Confluence.Request(Input, CancellationToken)' (but other parameters do)

Additional comments not posted (36)
Frends.Confluence.Request/CHANGELOG.md (1)

7-7: Missing period at the end of the sentence.

Add a period at the end of the sentence for consistency.

- - Added methodes: CreatePage, UpdatePage, GetPageById, DeletePage, GetPageByTitle, CreateSpace, DeleteSpace, GetSpaceByName
+ - Added methodes: CreatePage, UpdatePage, GetPageById, DeletePage, GetPageByTitle, CreateSpace, DeleteSpace, GetSpaceByName.
Frends.Confluence.Request/Frends.Confluence.Request.sln (3)

6-6: GUID change for Frends.Confluence.Request project.

Ensure that the new GUID is correct and consistent with the project configuration.


8-8: GUID change for Frends.Confluence.Request.Tests project.

Ensure that the new GUID is correct and consistent with the project configuration.


28-30: Addition of ExtensibilityGlobals section.

Verify that the SolutionGuid is correct and necessary for the solution's extensibility features.

Frends.Confluence.Request/Frends.Confluence.Request.Tests/TestsBase.cs (8)

3-3: New import statement using System.Linq;.

Ensure that the System.Linq namespace is required and used in the code.


29-29: Addition of PageId property.

The PageId property is added to store the ID of the created page. Ensure its usage is consistent and necessary.


79-79: Ensure proper error handling in DeleteSpace.

Verify that the DeleteSpace method handles errors appropriately, such as when the space does not exist.


98-98: Ensure proper error handling in CreatePage.

Verify that the CreatePage method handles errors appropriately, such as when the page cannot be created.


101-101: Usage of ConfluenceMethod.CreatePage in CreatePage method.

Ensure that the ConfluenceMethod.CreatePage is the correct method for creating a page and verify its implementation.


106-106: Addition of SpaceId property in CreatePage method.

Ensure that the SpaceId is correctly used and passed in the request.


112-112: Conditional check for PageId assignment.

Ensure that the conditional check for assigning PageId is correct and handles all edge cases.


114-115: Assignment of PageId from JSON response.

Ensure that the PageId is correctly extracted from the JSON response and handles cases where the id field is missing.

Frends.Confluence.Request/Frends.Confluence.Request/Definitions/Input.cs (14)

9-9: Ensure the summary is accurate.

Verify that the summary accurately represents the different methods for interacting with Confluence.


12-58: Addition of ConfluenceMethod enum.

The ConfluenceMethod enum is added to represent various Confluence interactions. Ensure that each method is correctly implemented and used.


65-65: Ensure the summary is accurate.

Verify that the summary accurately represents the input parameters.


68-68: Addition of ConfluenceMethod property.

The ConfluenceMethod property is added to choose the method for interacting with Confluence. Ensure that it is correctly used in the code.


87-87: Ensure the HttpMethod property is used correctly.

Verify that the HttpMethod property is used correctly and only for CustomRequest.


106-106: Ensure the OperationSufix property is used correctly.

Verify that the OperationSufix property is used correctly and only for CustomRequest.


119-119: Ensure the QueryParameters property is used correctly.

Verify that the QueryParameters property is used correctly and only for CustomRequest.


123-128: Addition of SpaceKey property.

The SpaceKey property is added for creating or deleting a space. Ensure that it is correctly used in the code.


130-135: Addition of Title property.

The Title property is added for creating, updating, or getting a page by title. Ensure that it is correctly used in the code.


137-142: Addition of Body property.

The Body property is added for creating or updating a page. Ensure that it is correctly used in the code.


144-149: Addition of PageId property.

The PageId property is added for updating, deleting, or getting a page by ID. Ensure that it is correctly used in the code.


151-156: Addition of Version property.

The Version property is added for updating a page. Ensure that it is correctly used in the code.


158-163: Addition of SpaceName property.

The SpaceName property is added for creating or getting a space by name. Ensure that it is correctly used in the code.


165-170: Addition of SpaceId property.

The SpaceId property is added for creating a page. Ensure that it is correctly used in the code.

Frends.Confluence.Request/Frends.Confluence.Request.Tests/Tests.cs (1)

Line range hint 45-46: LGTM!

The AcceptPrecedingSlash method correctly tests making requests with and without a preceding slash in the URL.

Frends.Confluence.Request/Frends.Confluence.Request/Request.cs (9)

Line range hint 69-107: LGTM!

The CustomRequest method correctly handles making a custom request to Confluence based on the input parameters and handles various content types in the response.


152-178: LGTM!

The CreatePage method correctly handles creating a new page in Confluence based on the input parameters.


186-212: LGTM!

The UpdatePage method correctly handles updating an existing page in Confluence based on the input parameters.


220-233: LGTM!

The GetPageById method correctly handles retrieving a page from Confluence by its ID based on the input parameters.


241-254: LGTM!

The DeletePage method correctly handles deleting a page from Confluence by its ID based on the input parameters.


263-283: LGTM!

The GetPageByTitle method correctly handles retrieving a page from Confluence by its title based on the input parameters.


291-311: LGTM!

The CreateSpace method correctly handles creating a new space in Confluence based on the input parameters.


319-332: LGTM!

The DeleteSpace method correctly handles deleting a space from Confluence by its key based on the input parameters.


340-359: LGTM!

The GetSpaceByName method correctly handles retrieving a space from Confluence by its name based on the input parameters.

Comment thread Frends.Confluence.Request/CHANGELOG.md Outdated

### Changed

- Changed Request method name for CustomRequest.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect preposition 'for'.

Change 'for' to 'to' for grammatical correctness.

- - Changed Request method name for CustomRequest.
+ - Changed Request method name to CustomRequest.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Changed Request method name for CustomRequest.
- Changed Request method name to CustomRequest.
Tools
LanguageTool

[uncategorized] ~11-~11: The preposition “to” seems more likely in this position than the preposition “for”.
Context: ... Changed - Changed Request method name for CustomRequest. ## [1.0.0] - 2024-05-21...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_FOR_TO)

Comment thread Frends.Confluence.Request/CHANGELOG.md Outdated
@@ -1,5 +1,15 @@
# Changelog

## [1.0.1] - 2024-06-28

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Typo in the word 'methodes'.

Correct the typo to 'methods'.

- - Added methodes: CreatePage, UpdatePage, GetPageById, DeletePage, GetPageByTitle, CreateSpace, DeleteSpace, GetSpaceByName.
+ - Added methods: CreatePage, UpdatePage, GetPageById, DeletePage, GetPageByTitle, CreateSpace, DeleteSpace, GetSpaceByName.

Committable suggestion was skipped due to low confidence.

);
Assert.AreEqual(200, result.StatusCode);
}

@coderabbitai coderabbitai Bot Jul 1, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure PageId is set after page creation

The RequestWithBody method creates a page but does not set the PageId static property in TestsBase. This might be necessary for subsequent tests that rely on the created page.

        Assert.AreEqual(200, result.StatusCode);
+       PageId = result.Content["id"].ToString();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Assert.AreEqual(200, result.StatusCode);
PageId = result.Content["id"].ToString();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The result of the RequestWithBody() method is not used in any other tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@MichalFrends1, upon further investigation, it appears that PageId is indeed used in other tests. Therefore, it is important to set the PageId after page creation in the RequestWithBody() method to ensure that subsequent tests relying on this value have the correct data.

To address this, you can update the RequestWithBody() method as follows:

Assert.AreEqual(200, result.StatusCode);
PageId = result.Content["id"].ToString();

This will help ensure that the PageId is correctly set for other tests that depend on it.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the usage of PageId in the test file to confirm if it is used in other tests.
rg 'PageId' Frends.Confluence.Request/Frends.Confluence.Request.Tests/Tests.cs

Length of output: 177


Learnings added
Learnt from: MichalFrends1
PR: FrendsPlatform/Frends.Confluence#4
File: Frends.Confluence.Request/Frends.Confluence.Request.Tests/Tests.cs:159-159
Timestamp: 2024-07-01T14:46:52.579Z
Learning: The `PageId` static property in `TestsBase` is used in multiple tests within `Frends.Confluence.Request/Frends.Confluence.Request.Tests/Tests.cs`, making it important to set this value correctly after page creation in methods like `RequestWithBody()`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines +273 to +286
public async Task DeleteSpace()
{
var input = new Input
{
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
};
var result = await Confluence.DeleteSpace(input, CancellationToken.None);

Assert.AreEqual(202, result.StatusCode);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure SpaceKey is set before deleting the space

The DeleteSpace method deletes a space by its key but does not ensure that SpaceKey is set before the deletion. This might lead to issues if SpaceKey is not set.

    public async Task DeleteSpace()
    {
        var input = new Input
        {
+           Assert.IsFalse(string.IsNullOrEmpty(SpaceKey), "SpaceKey is not set.");
            SpaceKey = "TEST",
            Username = username,
            ApiToken = apiToken,
            ApiVersion = ApiVersion.V2,
            ConfluenceDomainName = domainName
        };
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task DeleteSpace()
{
var input = new Input
{
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
};
var result = await Confluence.DeleteSpace(input, CancellationToken.None);
Assert.AreEqual(202, result.StatusCode);
}
public async Task DeleteSpace()
{
var input = new Input
{
Assert.IsFalse(string.IsNullOrEmpty(SpaceKey), "SpaceKey is not set.");
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
};
var result = await Confluence.DeleteSpace(input, CancellationToken.None);
Assert.AreEqual(202, result.StatusCode);
}

Comment on lines +181 to +198
public async Task UpdatePage()
{
var result = await Confluence.UpdatePage(
new Input
{
Title = "UpdatedTitle",
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
Body = "Updated new page created by the API",
Version = 2
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure PageId is set before updating the page

The UpdatePage method updates a page but does not ensure that PageId is set before the update. This might lead to issues if PageId is not set.

    public async Task UpdatePage()
    {
+       Assert.IsFalse(string.IsNullOrEmpty(PageId), "PageId is not set.");
        var result = await Confluence.UpdatePage(
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task UpdatePage()
{
var result = await Confluence.UpdatePage(
new Input
{
Title = "UpdatedTitle",
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
Body = "Updated new page created by the API",
Version = 2
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
}
public async Task UpdatePage()
{
Assert.IsFalse(string.IsNullOrEmpty(PageId), "PageId is not set.");
var result = await Confluence.UpdatePage(
new Input
{
Title = "UpdatedTitle",
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
Body = "Updated new page created by the API",
Version = 2
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
}

Comment on lines +235 to +249
public async Task GetPageByTitle()
{
var result = await Confluence.GetPageByTitle(
new Input
{
Title = "TestPage1",
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure SpaceKey is set before retrieving the page

The GetPageByTitle method retrieves a page by its title but does not ensure that SpaceKey is set before the retrieval. This might lead to issues if SpaceKey is not set.

    public async Task GetPageByTitle()
    {
+       Assert.IsFalse(string.IsNullOrEmpty(SpaceKey), "SpaceKey is not set.");
        var result = await Confluence.GetPageByTitle(
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task GetPageByTitle()
{
var result = await Confluence.GetPageByTitle(
new Input
{
Title = "TestPage1",
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
public async Task GetPageByTitle()
{
Assert.IsFalse(string.IsNullOrEmpty(SpaceKey), "SpaceKey is not set.");
var result = await Confluence.GetPageByTitle(
new Input
{
Title = "TestPage1",
SpaceKey = "TEST",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);

Comment on lines +161 to +178
public async Task CreatePage()
{
var result = await Confluence.CreatePage(
new Input
{
ConfluenceMethod = ConfluenceMethod.CreatePage,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
SpaceId = WorkSpaceId,
Title = "TestPage3",
Body = "This is a new page 3 created by the API"
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure PageId is set after page creation

The CreatePage method creates a page but does not set the PageId static property in TestsBase. This might be necessary for subsequent tests that rely on the created page.

        Assert.AreEqual(200, result.StatusCode);
+       PageId = result.Content["id"].ToString();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task CreatePage()
{
var result = await Confluence.CreatePage(
new Input
{
ConfluenceMethod = ConfluenceMethod.CreatePage,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
SpaceId = WorkSpaceId,
Title = "TestPage3",
Body = "This is a new page 3 created by the API"
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
}
public async Task CreatePage()
{
var result = await Confluence.CreatePage(
new Input
{
ConfluenceMethod = ConfluenceMethod.CreatePage,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName,
SpaceId = WorkSpaceId,
Title = "TestPage3",
Body = "This is a new page 3 created by the API"
},
CancellationToken.None
);
Assert.AreEqual(200, result.StatusCode);
PageId = result.Content["id"].ToString();
}

Comment on lines +289 to +301
public async Task GetSpaceByName()
{
var input = new Input
{
SpaceName = "Test123",
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
};
await Confluence.CreateSpace(input, CancellationToken.None);
var result = await Confluence.GetSpaceByName(input, CancellationToken.None);
Assert.AreEqual(200, result.StatusCode);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure SpaceName is set before retrieving the space

The GetSpaceByName method retrieves a space by its name but does not ensure that SpaceName is set before the retrieval. This might lead to issues if SpaceName is not set.

    public async Task GetSpaceByName()
    {
        var input = new Input
        {
+           Assert.IsFalse(string.IsNullOrEmpty(SpaceName), "SpaceName is not set.");
            SpaceName = "Test123",
            Username = username,
            ApiToken = apiToken,
            ApiVersion = ApiVersion.V2,
            ConfluenceDomainName = domainName
        };

Committable suggestion was skipped due to low confidence.

Comment on lines +218 to +231
public async Task DeletePage()
{
var result = await Confluence.DeletePage(
new Input
{
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(204, result.StatusCode);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ensure PageId is set before deleting the page

The DeletePage method deletes a page by its ID but does not ensure that PageId is set before the deletion. This might lead to issues if PageId is not set.

    public async Task DeletePage()
    {
+       Assert.IsFalse(string.IsNullOrEmpty(PageId), "PageId is not set.");
        var result = await Confluence.DeletePage(
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task DeletePage()
{
var result = await Confluence.DeletePage(
new Input
{
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(204, result.StatusCode);
public async Task DeletePage()
{
Assert.IsFalse(string.IsNullOrEmpty(PageId), "PageId is not set.");
var result = await Confluence.DeletePage(
new Input
{
PageId = PageId,
Username = username,
ApiToken = apiToken,
ApiVersion = ApiVersion.V2,
ConfluenceDomainName = domainName
},
CancellationToken.None
);
Assert.AreEqual(204, result.StatusCode);

Comment thread Frends.Confluence.Request/Frends.Confluence.Request/Request.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 04a4671 and 3ff2b1b.

Files selected for processing (1)
  • Frends.Confluence.Request/CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Frends.Confluence.Request/CHANGELOG.md

@MichalFrends1
MichalFrends1 requested a review from jefim July 2, 2024 08:37
@MichalFrends1 MichalFrends1 self-assigned this Jul 2, 2024
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.

2 participants