Skip to content

Commit

Permalink
reverted broken filepaths and reverting unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Medek authored and Martin Medek committed Dec 17, 2024
1 parent 4d615e7 commit 04eb395
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 56 deletions.
47 changes: 47 additions & 0 deletions examples/Kentico.Xperience.UMT.Example.AdminApp/Data/Samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -1607,5 +1607,52 @@
}
],
"PageData": null
},
{
"$type": "Workspace",
"WorkspaceGUID": "018fe300-d522-4cc8-9888-b7248e922077",
"WorkspaceDisplayName": "Sample Workspace",
"WorkspaceName": "SampleWorkspace"
},
{
"$type": "ContentItemSimplified",
"ContentItemGUID": "2867f7b2-2db4-429a-b1b7-7596a502b089",
"ContentItemContentFolderGUID": null,
"ContentItemWorkspaceGUID": "018fe300-d522-4cc8-9888-b7248e922077",
"IsSecured": false,
"ContentTypeName": "UMT.Event",
"Name": "EventInSampleWorkspace",
"IsReusable": true,
"ChannelName": null,
"LanguageData": [
{
"LanguageName": "en-US",
"DisplayName": "Sample workspace Event - en-US",
"VersionStatus": 2,
"IsLatest": true,
"UserGuid": "dbfcc244-2cb9-4934-857f-9d75404c1553",
"ScheduledPublishWhen": null,
"ScheduledUnpublishWhen": null,
"ContentItemData": {
"EventTitle": "en-US Sample workspace Event",
"EventText": "en-US Sample workspace Event (reusable)",
"EventDate": "2024-01-01T00:00:00Z",
"EventRecurrentYearly": true,
"EventTeaser": {
"$assetType": "AssetData",
"Data": "iVBORw0KGgoAAAANSUhEUgAAARsAAABlCAYAAAB9ckckAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABAESURBVHhe7d0JkBxVHQbw/xw7u5sN4b4hXEFABQRBQBOSgAYLVOQMkOIyaFQKTdDiUCCJHBZggaCoIVYlqOG\u002BFBFEQxLuMwY5lAgkHJEjkSvJXnM53\u002Bx7tZ2X1zPdMz1vjv1\u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Ykky5sbVwk1VEIkxES32jz4s2x4jX8HnIiGtSSYUNEjad5L0YioqbCsCEiJxg2ROQEw4aInGDYEJETDBsicoJhQ0ROMGyIyAmGDRE5wbAhIicYNkTkBMOGiJxg2BCREwwbInKCYUNETsTefmsF72dDRDUXu0v6GTZN5P3E2/JO2zLpj/WoJUTNgbtRTYRBQ81L5P9tTCaxUJPzFgAAAABJRU5ErkJggg==",
"ContentItemGuid": "2867f7b2-2db4-429a-b1b7-7596a502b089",
"Identifier": "57c26660-ef2f-4288-8f30-886135c2c8fb",
"Name": "byteArraySample.jpg",
"Extension": ".jpg",
"Size": null,
"LastModified": null,
"ImageWidth": null,
"ImageHeight": null
}
}
}
],
"PageData": null
}
]
51 changes: 12 additions & 39 deletions examples/Kentico.Xperience.UMT.Example.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@

using CMS.Core;
using CMS.DataEngine;
using CMS.IO;
using CMS.MediaLibrary;

using Kentico.Xperience.UMT;
using Kentico.Xperience.UMT.Examples;
using Kentico.Xperience.UMT.Model;
using Kentico.Xperience.UMT.Services;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -25,15 +21,9 @@

Service.Use<IConfiguration>(root);
CMS.Base.SystemContext.WebApplicationPhysicalPath = root.GetValue<string>("WebApplicationPhysicalPath");
string workDir = System.IO.Directory.GetCurrentDirectory();
string assetSearchPath = workDir;
if (args.Length > 0)
{
assetSearchPath = args[0];
}

string workDir = Directory.GetCurrentDirectory();
// note - this is currently required for asset import when UMT is used in other place then Kentico Xperience itself
System.IO.Directory.SetCurrentDirectory(root.GetValue<string>("WebApplicationPhysicalPath") ?? throw new InvalidOperationException("WebApplicationPhysicalPath must be set to valid directory path"));
Directory.SetCurrentDirectory(root.GetValue<string>("WebApplicationPhysicalPath") ?? throw new InvalidOperationException("WebApplicationPhysicalPath must be set to valid directory path"));

CMSApplication.Init();

Expand All @@ -52,22 +42,22 @@
if (useSerializedSample)
#pragma warning restore S2583
{
string path = System.IO.Path.GetFullPath(System.IO.Path.Combine(workDir, "../../../../../docs/Samples/basic.json"));
string sampleText = (await System.IO.File.ReadAllTextAsync(path) ?? throw new InvalidOperationException("Failed to load sample"))
.Replace("##ASSETDIR##", assetSearchPath.Replace(@"\", @"\\"));

string path = Path.GetFullPath(Path.Combine(workDir, "../../../../../docs/Samples/basic.json"));
string sampleText = (await File.ReadAllTextAsync(path) ?? throw new InvalidOperationException("Failed to load sample"))
.Replace("##ASSETDIR##", workDir.Replace(@"\", @"\\"));
sourceData = importService.FromJsonString(sampleText)?.ToList() ?? new List<IUmtModel>();
}
else
{
sourceData = SampleProvider.GetFullSample();

foreach (var umtModel in sourceData)
{
// update path to media files
if (umtModel is MediaFileModel mediaFileModel)
{
mediaFileModel.DataSourcePath = mediaFileModel.DataSourcePath?.Replace("##ASSETDIR##", assetSearchPath);
mediaFileModel.DataSourcePath = mediaFileModel.DataSourcePath?.Replace("##ASSETDIR##", workDir);
}

foreach ((string? key, object? value) in umtModel.CustomProperties)
Expand All @@ -76,7 +66,7 @@
{
case AssetFileSource assetSource:
{
assetSource.FilePath = assetSource.FilePath?.Replace("##ASSETDIR##", assetSearchPath);
assetSource.FilePath = assetSource.FilePath?.Replace("##ASSETDIR##", workDir);
umtModel.CustomProperties[key] = assetSource;
break;
}
Expand All @@ -97,7 +87,7 @@
{
case AssetFileSource assetSource:
{
assetSource.FilePath = assetSource.FilePath?.Replace("##ASSETDIR##", assetSearchPath);
assetSource.FilePath = assetSource.FilePath?.Replace("##ASSETDIR##", workDir);
break;
}
}
Expand All @@ -113,7 +103,7 @@
#pragma warning restore S2583
{
// simplified usage for streamlined import

// create observer to track import state
var importObserver = new ImportStateObserver();

Expand Down Expand Up @@ -151,7 +141,7 @@
switch (result)
{
// OK
case { Success: true, Imported: { } }:
case { Success: true, Imported: {} }:
{
Console.WriteLine($"{umtModel.PrintMe()} imported");
break;
Expand All @@ -177,23 +167,6 @@
}
}

foreach (var mediaLibraryInfo in MediaLibraryInfoProvider.ProviderObject.Get())
{
try
{
string libraryFolderPath = MediaLibraryInfoProvider.GetMediaLibraryFolderPath(mediaLibraryInfo.LibraryFolder);
Console.WriteLine($"{mediaLibraryInfo.LibraryName}: {libraryFolderPath}");
}
catch (Exception ex)
{
Console.WriteLine($"{mediaLibraryInfo.LibraryName}: {mediaLibraryInfo.LibraryFolder} Error: {ex}");
}
}

Console.WriteLine($"WorkDir-Current: {System.IO.Directory.GetCurrentDirectory()}");
Console.WriteLine($"WorkDir-Prev : {workDir}");
Console.WriteLine($"WebAppPath : {CMS.Base.SystemContext.WebApplicationPhysicalPath}");

Console.WriteLine("Finished!");

#pragma warning restore S1135
3 changes: 3 additions & 0 deletions examples/Kentico.Xperience.UMT.Examples/SampleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public static List<IUmtModel> GetFullSample()
sourceData.Add(ContentItemSimplifiedSamples.SampleFaqContentItemSimplifiedModel); // references sample content subfolder
sourceData.Add(ContentItemSimplifiedSamples.SampleEventContentItemWithAsset);

sourceData.Add(WorkspaceSamples.SampleWorkspace);
sourceData.Add(ContentItemSimplifiedSamples.EventInSampleWorkspace);

return sourceData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class AssetSamples
FileName = "NewTestFile",
FileExtension = ".png",
FileTitle = "Title",
FilePath = "NewTestFile.png"
FilePath = "customdir/NewTestFile.png"
};

[Sample("mediafile.sample.fromurl", "", "Sample of media file downloaded from url")]
Expand All @@ -29,7 +29,7 @@ public static class AssetSamples
FileName = "NewTestFileFromUri",
FileExtension = ".jpg",
FileTitle = "Old devnet screen",
FilePath = "NewTestFileFromUri.jpg"
FilePath = "customdir/NewTestFileFromUri.jpg"
};

// https://res-5.cloudinary.com/xperience-io/image/upload/c_lfill,dpr_1,w_768/f_auto,q_auto/v1/homepage/k-02-your-real-needs-at-its-core-1600x1200px_ihqknl
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Kentico.Xperience.UMT.Model;

namespace Kentico.Xperience.UMT.Examples;

public static class WorkspaceSamples
{
public static readonly Guid SampleWorkspaceGuid = new Guid("018FE300-D522-4CC8-9888-B7248E922077");

[Sample("WorkspaceModel.Sample", "", "Workspace sample")]
public static WorkspaceModel SampleWorkspace => new()

Check failure on line 10 in examples/Kentico.Xperience.UMT.Examples/Samples/WorkspaceSamples.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'WorkspaceModel' could not be found (are you missing a using directive or an assembly reference?)
{
WorkspaceGUID = SampleWorkspaceGuid,
WorkspaceName = "SampleWorkspace",
WorkspaceDisplayName = "Sample Workspace",
};
}
4 changes: 1 addition & 3 deletions src/Kentico.Xperience.UMT/InfoAdapter/MediaFileAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ protected override MediaFileInfo ObjectFactory(UmtModelInfo umtModelInfo, IUmtMo

var mediaLibrary = MediaLibraryInfoProvider.ProviderObject.Get(model.FileLibraryGuid!.Value);
MediaLibraryInfoProvider.CreateMediaLibraryFolder(mediaLibrary.LibraryID, Path.GetDirectoryName(model.FilePath));
Console.WriteLine("Path.getdir : " + Path.GetDirectoryName(model.FilePath));
Console.WriteLine("model.filepath: " + model.FilePath);

mediaFileInfo = new MediaFileInfo(uploadedFile, 0);
mediaFileInfo.SaveFileToDisk(true);
Expand Down Expand Up @@ -97,4 +95,4 @@ protected override MediaFileInfo MapProperties(IUmtModel umtModel, MediaFileInfo

return current;
}
}
}
2 changes: 1 addition & 1 deletion test.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<ADMINISTRATION_PASSWORD>administrator</ADMINISTRATION_PASSWORD>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
</RunSettings>
1 change: 0 additions & 1 deletion tests/Kentico.Xperience.UMT.Tests/Tests/AdminTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class AdminTestBase
protected static string BaseURL => Environment.GetEnvironmentVariable("BASE_URL") ?? "";
protected static string AdministratorUser => Environment.GetEnvironmentVariable("ADMINISTRATION_USER") ?? "";
protected static string AdministratorPassword => Environment.GetEnvironmentVariable("ADMINISTRATION_PASSWORD") ?? "";
protected static string ReportPath => Environment.GetEnvironmentVariable("REPORT_PATH") ?? "";

[SetUp]
public async Task Setup()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Globalization;

using Microsoft.Playwright;
using System.Reflection;

using TestAfterMigration.Extensions;
using TestAfterMigration.Helpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,34 @@ namespace TestAfterMigration.Tests
{
public class Tests_03_ContentHubTests : AdminTestBase
{
[Test]
public async Task Test00100_Folder_With_Subfolder_Exists()
private async Task OpenContentHub(string workspace = "Default")
{
await OpenAdminApplication("Content hub");
await SelectTopDropdownLanguage("English (United States)");
await SelectTopDropdownWorkspace(workspace);
}

private async Task SelectTopDropdownWorkspace(string workspaceTitle)
{
if (!(await Page.GetByTestId("WorkspaceSelector").TextContentAsync())?.Contains(workspaceTitle, StringComparison.OrdinalIgnoreCase) ?? false)
{
await Page.GetByTestId("WorkspaceSelector").Locator("div[class^=\"select_\"]").Nth(0).ClickAsync();
await Page.GetByTestId("WorkspaceSelector").GetByTestId("action-menu").GetByTestId("menu-item").Filter(new LocatorFilterOptions { HasText = workspaceTitle }).ClickAsync();
await Debounce();
}
}

public new async Task SelectTopDropdownLanguage(string languageTitle)
{
await Page.GetByTestId("WorkspaceSelector").Locator("div[class^=\"select_\"]").Nth(1).ClickAsync();
await Page.GetByTestId("WorkspaceSelector").GetByTestId("action-menu").GetByTestId("menu-item").Filter(new LocatorFilterOptions { HasText = languageTitle }).ClickAsync();
await Debounce();
}

[Test]
public async Task Test00100_Folder_With_Subfolder_Exists()
{
await OpenContentHub();

var folderDiv = Page.Locator("div[class*=\"folder-view\"]");
var parentFolder = folderDiv.GetByRole(AriaRole.Treeitem);
Expand All @@ -23,8 +46,7 @@ public async Task Test00100_Folder_With_Subfolder_Exists()
[Test]
public async Task Test00200_Child_Folder_Contains_Item()
{
await OpenAdminApplication("Content hub");
await SelectTopDropdownLanguage("English (United States)");
await OpenContentHub();

var folderDiv = Page.Locator("div[class*=\"folder-view\"]");
var parentFolder = folderDiv.GetByRole(AriaRole.Treeitem);
Expand All @@ -39,8 +61,7 @@ public async Task Test00200_Child_Folder_Contains_Item()
[Test]
public async Task Test00300_Draft_And_Scheduled_Items_Present()
{
await OpenAdminApplication("Content hub");
await SelectTopDropdownLanguage("English (United States)");
await OpenContentHub();

await Page.GetByLabel("All content items").ClickAsync();
await Debounce();
Expand All @@ -52,8 +73,7 @@ public async Task Test00300_Draft_And_Scheduled_Items_Present()
[Test]
public async Task Test00400_No_Errors_When_Viewing_Tabs()
{
await OpenAdminApplication("Content hub");
await SelectTopDropdownLanguage("English (United States)");
await OpenContentHub();

await Page.GetByLabel("All content items").ClickAsync();
await Debounce();
Expand All @@ -80,5 +100,16 @@ public async Task Test00400_No_Errors_When_Viewing_Tabs()
await AssertNoEventlogErrors();
}

[Test]
public async Task Test00500_Published_Item_Exists_In_Sample_Workspace()
{
await OpenContentHub("Sample Workspace");

await Page.GetByLabel("All content items").ClickAsync();
await Debounce();

await Assertions.Expect(Page.GetByTestId("table-row").Filter(new LocatorFilterOptions { HasText = "Published" })).Not.ToHaveCountAsync(0);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Playwright;

using System.Text.RegularExpressions;

namespace TestAfterMigration.Tests
Expand Down

0 comments on commit 04eb395

Please sign in to comment.