tests/Add-SkylineContentEditorWebPart.Tests.ps1

Describe "Add-SkylineContentEditorWebPart" {
    BeforeAll {

    }
    Context "upload a new webpart to the webpart gallery" {
        It "should upload a new webpart" {
            Add-SkylineContentEditorWebPart -Title "TestContentEditorWebPart1" -ContentLink "https://test.local/test.html" -Group "Tests"
        }
        It "should have uploaded the new webpart named TestContentEditorWebPart1.dwp" {
            Get-PnPFile -Url "_catalogs/wp/TestContentEditorWebPart1.dwp" -AsString -ErrorAction SilentlyContinue | Should Not BeNullOrEmpty
        }
        It "should have set the content link to 'https://test.local/test.html'" {
            [XML]$WebPartXml = Get-PnPFile -Url "_catalogs/wp/TestContentEditorWebPart1.dwp" -AsString -ErrorAction SilentlyContinue
            $WebPartXml.WebPart.ContentLink.InnerText | Should Be "https://test.local/test.html"
        }
        It "should have set the web part group to 'Tests'" {
            $WebPartItem = Get-PnPFile -Url "_catalogs/wp/TestContentEditorWebPart1.dwp" -AsListItem -ErrorAction SilentlyContinue
            $WebPartItem["Group"] | Should Be "Tests"
        }
    }

    AfterAll {
        Remove-PnPFile -SiteRelativeUrl "_catalogs/wp/TestContentEditorWebPart1.dwp" -Force
    }
}