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

OSOE-920: Create a reusable widget for the carousel in Lombiq.UIKit #69

Merged
merged 35 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d3b05a4
Setting up Lombiq.UIKit.Widgets project.
milosh-96 Dec 4, 2024
a8df717
Removing Controller, Views and cleaning up Startup.cs for Widgets mod…
milosh-96 Dec 4, 2024
945bb38
Reorganizing some code.
milosh-96 Dec 5, 2024
4df70b0
Removing capabilities from Slide and CarouselWidget content types.
milosh-96 Dec 5, 2024
423df7d
Removing capabilities from Slide and CarouselWidget content types - u…
milosh-96 Dec 5, 2024
75f59d8
Adding Slide shapes to be displayed in SlickCarousel shape.
milosh-96 Dec 6, 2024
78c61c2
Fixing formatting.
milosh-96 Dec 6, 2024
c4708d0
Updating namespace.
milosh-96 Dec 7, 2024
f5aca16
Adding Settings class for CarouselWidget.
milosh-96 Dec 7, 2024
9f5e92c
Working on Carousel Widget Settings; Adding DefaultValues class.
milosh-96 Dec 10, 2024
78b402f
Completing Carousel Widget part settings and utilizing the default va…
milosh-96 Dec 10, 2024
1fe6382
Completing the viewmodel class for CarouselPartSettings with all prop…
milosh-96 Dec 10, 2024
9e7bc9f
Adding CenterMode setting property.
milosh-96 Dec 10, 2024
d4b2477
Adding missing options; utilizing reflection to map all properties; u…
milosh-96 Dec 10, 2024
a3b7f0c
Merge branch 'dev' into issue/OSOE-920
milosh-96 Dec 10, 2024
40d5514
Updating NuGET packages in Lombiq.UIKit.Widgets project.
milosh-96 Dec 12, 2024
11779ad
Removing all options from the part settings and adding just one in th…
milosh-96 Dec 12, 2024
5748fd7
Adding content recipe for demo of carousel widget.
milosh-96 Dec 12, 2024
acdc4f3
Utilizing CodeMirror for JSON editing on Carousel widget part setting…
milosh-96 Dec 14, 2024
2e1ade4
Adding Lombiq UI Kit Widgets tests.
milosh-96 Dec 20, 2024
80fb030
Working on testing behaviour.
milosh-96 Dec 20, 2024
83e9220
Adding nullable types in viewmodels.
milosh-96 Dec 21, 2024
f7d710b
Fixing nullable reference type error in display driver and adding def…
milosh-96 Dec 21, 2024
b5cd1f0
Changing package version in Widgets project to 2.1.0.
milosh-96 Dec 21, 2024
08dfa9e
Updating Lombiq.Tests.UI package to 12.0.0.
milosh-96 Dec 21, 2024
3bdaf05
Fixing code formatting issues in Lombiq.UIKit.Widgets.
milosh-96 Dec 21, 2024
36a942d
Removing async methods from Lombiq.UIKit.Widgets UI Test case class.
milosh-96 Dec 22, 2024
6d10194
Adding options test for CarouselWidget part.
milosh-96 Dec 22, 2024
47296ca
Removing unused namespaces.
milosh-96 Dec 22, 2024
c92d294
Merge branch 'dev' into issue/OSOE-920
milosh-96 Dec 25, 2024
08f8513
Adding an example page for Carousel widget and removing the home page…
milosh-96 Dec 26, 2024
2ce2a89
Fixing project details (name, description..); Cleaning up the code; a…
milosh-96 Jan 13, 2025
08d874f
Renaming 'SlidesToShow' JSON property to 'slidesToShow' in Carousel t…
milosh-96 Jan 15, 2025
b9fd301
Improving code style.
milosh-96 Jan 16, 2025
63530b0
Updating recipe to include its media; adding image files; updating co…
milosh-96 Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Atata;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using Shouldly;
using System;
using System.Text.Json;
using System.Threading.Tasks;

namespace Lombiq.UIKit.Widgets.Tests.UI.Extensions;

public static class TestCaseUITestContextExtensions
{
private const string CarouselWidgetPartSettingsUrl = "/ContentTypes/CarouselWidget/ContentParts/CarouselWidgetPart/Edit";
private const string CarouselWidgetExamplePageUrl = "/carousel-widget-example";

public static async Task TestCarouselWidgetBehaviorAsync(this UITestContext context)
{
await context.GoToRelativeUrlAsync(CarouselWidgetExamplePageUrl);
context.TestCarouselWidgetContainerExistence();
context.TestSlickCarouselExistence();
context.TestCorrectNumberOfItemsIsDisplayed();
}

public static async Task TestCarouselWidgetOptionsAsync(this UITestContext context)
{
int slidesToShow = 3;
bool showDots = false;
barthamark marked this conversation as resolved.
Show resolved Hide resolved

await context.SignInDirectlyAndGoToAdminRelativeUrlAsync(CarouselWidgetPartSettingsUrl);
context.WaitForPageLoad();
var options = JsonSerializer.Serialize(new { slidesToShow, dots = showDots });
context.ExecuteScript($"codeMirrorJsonEditor.setValue('{options}')");
await context.ClickReliablyOnSubmitAsync();
await context.GoToRelativeUrlAsync(CarouselWidgetExamplePageUrl);
context.TestCorrectNumberOfItemsIsDisplayed(slidesToShow);
context.TestCarouselWidgetDotsVisibility(showDots);
}

public static void TestCorrectNumberOfItemsIsDisplayed(this UITestContext context, int numberOfItems = 1) =>
context.GetAll(By.ClassName("slick-active")).Count.ShouldBe(numberOfItems);

public static void TestSlickCarouselExistence(this UITestContext context) =>
context.Exists(By.ClassName("slickCarousel__carousel"));

public static void TestCarouselWidgetContainerExistence(this UITestContext context) =>
context.Exists(By.ClassName("carouselWidget"));

public static void TestCarouselWidgetDotsVisibility(this UITestContext context, bool showDots)
{
var by = By.CssSelector("ul.slick-dots");
if (showDots)
context.Exists(by);
else
context.GetAll(by).Count.ShouldBe(0);
}
}
36 changes: 36 additions & 0 deletions Lombiq.UIKit.Widgets.Tests.UI/Lombiq.UIKit.Widgets.Tests.UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<Title>Lombiq UI Kit Widgets for Orchard Core - UI Test Extensions</Title>
<Authors>Lombiq Technologies</Authors>
<Copyright>Copyright © 2022, Lombiq Technologies Ltd.</Copyright>
<Description>Lombiq UI Kit for Orchard Core - UI Test Extensions: Extensions to aid in UI testing Lombiq UI Kit for Orchard Core.</Description>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageTags>OrchardCore;Lombiq;AspNetCore;UIKit</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Orchard-Chart.js</RepositoryUrl>
barthamark marked this conversation as resolved.
Show resolved Hide resolved
<PackageProjectUrl>https://github.com/Lombiq/Orchard-UIKit/blob/dev/Lombiq.UIKit.Widgets.Tests.UI/Readme.md</PackageProjectUrl>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.UIKit.Widgets\Lombiq.UIKit.Widgets.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
<ProjectReference Include="..\..\..\..\test\Lombiq.UITestingToolbox\Lombiq.Tests.UI\Lombiq.Tests.UI.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="12.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
<None Include="Readme.md" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
Binary file added Lombiq.UIKit.Widgets.Tests.UI/NuGetIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Lombiq.UIKit.Widgets.Tests.UI/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Lombiq UI Kit for Orchard Core - UI Test Extensions
barthamark marked this conversation as resolved.
Show resolved Hide resolved

## About

Extension methods that test various features in UI Kit for Orchard Core.

Call these from a UI test project that also references _Lombiq.UIKit._ to verify the module's basic features; as seen in [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions).

## Contributing and support

Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.

This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.
6 changes: 6 additions & 0 deletions Lombiq.UIKit.Widgets/Constants/DefaultValues.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Lombiq.UIKit.Widgets.Constants;

public static class DefaultValues
{
public const string CarouselWidgetPartOptions = "{}";
}
10 changes: 10 additions & 0 deletions Lombiq.UIKit.Widgets/Handlers/SlidePartHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Lombiq.UIKit.Widgets.Models;
using OrchardCore.ContentManagement.Handlers;

namespace Lombiq.UIKit.Widgets.Handlers;

public class SlidePartHandler : ContentPartHandler<SlidePart>
{
public override Task UpdatedAsync(UpdateContentContext context, SlidePart part) =>
Task.Run(() => context.ContentItem.DisplayText = part.Title.Text);
}
28 changes: 28 additions & 0 deletions Lombiq.UIKit.Widgets/Lombiq.UIKit.Widgets.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="2.1.0" />
<PackageReference Include="OrchardCore.Contents" Version="2.1.0" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.1.0" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.1.0" />
<PackageReference Include="OrchardCore.Flows" Version="2.1.0" />
<PackageReference Include="OrchardCore.Media" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.UIKit\Lombiq.UIKit.csproj" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions Lombiq.UIKit.Widgets/Manifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using OrchardCore.Modules.Manifest;

[assembly: Module(
Name = "Lombiq UI Kit Widgets",
Author = "Lombiq Technologies",
Version = "0.0.1",
Description = "Module for reusable widgets based on Lombiq UI Kit.",
Website = "https://github.com/Lombiq/Orchard-UIKit"
)]
Copy link
Member

Choose a reason for hiding this comment

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

Add the following dependencies: Lombiq.UIKit (use an appropriate const from the module), OrchardCore.ContentFields, OrchardCore.Media.

Copy link
Member

Choose a reason for hiding this comment

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

Add an appropriate category.

54 changes: 54 additions & 0 deletions Lombiq.UIKit.Widgets/Migrations/CarouselWidgetMigrations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Lombiq.HelpfulLibraries.OrchardCore.Contents;
using Lombiq.UIKit.Widgets.Models;
using Lombiq.UIKit.Widgets.Settings;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using OrchardCore.Flows.Models;
using OrchardCore.Media.Settings;

namespace Lombiq.UIKit.Widgets.Migrations;

public class CarouselWidgetMigrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;

public CarouselWidgetMigrations(IContentDefinitionManager contentDefinitionManager) => _contentDefinitionManager = contentDefinitionManager;

public async Task<int> CreateAsync()
{
await _contentDefinitionManager.AlterPartDefinitionAsync<SlidePart>(
part =>
{
part.WithField(part => part.Title, field => field.WithPosition("0"));
barthamark marked this conversation as resolved.
Show resolved Hide resolved
part.WithField(part => part.Image, field => field.WithSettings(new MediaFieldSettings
{
Multiple = false,
}).WithPosition("1")
);
}
);
barthamark marked this conversation as resolved.
Show resolved Hide resolved

await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(CarouselWidgetPart), part => part
.Attachable()
.WithSettings(new CarouselWidgetPartSettings())
);
barthamark marked this conversation as resolved.
Show resolved Hide resolved

await _contentDefinitionManager.AlterTypeDefinitionAsync("Slide", type =>
barthamark marked this conversation as resolved.
Show resolved Hide resolved
type
.Securable()
.WithPart(nameof(SlidePart)));

await _contentDefinitionManager.AlterTypeDefinitionAsync("CarouselWidget", type =>
type
.Securable()
.WithPart(nameof(CarouselWidgetPart), part => part.WithSettings(new CarouselWidgetPartSettings()))
.WithPart(nameof(BagPart), part => part.WithSettings(new BagPartSettings
{
ContainedContentTypes = ["Slide"],
})
).Stereotype(CommonStereotypes.Widget));
barthamark marked this conversation as resolved.
Show resolved Hide resolved

return 1;
}
}
4 changes: 4 additions & 0 deletions Lombiq.UIKit.Widgets/Models/CarouselWidgetPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using OrchardCore.ContentManagement;

namespace Lombiq.UIKit.Widgets.Models;
public class CarouselWidgetPart : ContentPart;
barthamark marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions Lombiq.UIKit.Widgets/Models/SlidePart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using OrchardCore.ContentFields.Fields;
using OrchardCore.ContentManagement;
using OrchardCore.Media.Fields;

namespace Lombiq.UIKit.Widgets.Models;
public class SlidePart : ContentPart
barthamark marked this conversation as resolved.
Show resolved Hide resolved
{
public TextField Title { get; set; } = new();
public MediaField Image { get; set; } = new();
}
Loading
Loading