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

OP-320: Add possibility to select section type and fill up collection of items of this type #500

Merged
merged 25 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
Empty file added etc/build/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions features/admin/adding_block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Feature: Adding blocks
Then I should be notified that the block has been created

@ui @javascript
Scenario: Adding block with sections
Given there are existing sections named "Blog" and "Homepage"
Scenario: Adding block with collections
Given there are existing collections named "Blog" and "Homepage"
When I go to the create block page
And I fill the code with "intro"
And I add "Blog" and "Homepage" sections to it
And I add "Blog" and "Homepage" collections to it
And I fill the content with "Hello world!"
And I add it
Then I should be notified that the block has been created
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
@managing_sections
Feature: Adding new section
@managing_collections
Feature: Adding new collection
In order to present more sophisticated content
As an Administrator
I want to be able to add new CMS sections to the store
I want to be able to add new CMS collections to the store

Background:
Given the store operates on a single channel in "United States"
And I am logged in as an administrator

@ui
Scenario: Adding new section
When I go to the create section page
Scenario: Adding new collection
When I go to the create collection page
And I fill the code with "blog"
And I fill the name with "Blog"
And I add it
Then I should be notified that new section has been created
Then I should be notified that new collection has been created

@ui
Scenario: Trying to add a section with an existing code
Given there is an existing section with "blog" code
When I go to the create section page
Scenario: Trying to add a collection with an existing code
Given there is an existing collection with "blog" code
When I go to the create collection page
And I fill the code with "blog"
And I try to add it
Then I should be notified that there is already an existing section with provided code
Then I should be notified that there is already an existing collection with provided code

@ui
Scenario: Trying to add section with blank data
When I go to the create section page
Scenario: Trying to add collection with blank data
When I go to the create collection page
And I try to add it
Then I should be notified that "Code, Name" fields cannot be blank

@ui
Scenario: Trying to add section with too short data
When I go to the create section page
Scenario: Trying to add collection with too short data
When I go to the create collection page
And I fill "Code, Name" fields with 1 character
And I try to add it
Then I should be notified that "Code, Name" fields are too short

@ui
Scenario: Trying to add section with too long data
When I go to the create section page
Scenario: Trying to add collection with too long data
When I go to the create collection page
And I fill "Code, Name" fields with 251 characters
And I try to add it
Then I should be notified that "Code, Name" fields are too long
4 changes: 2 additions & 2 deletions features/admin/adding_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ Feature: Adding new page

@ui @javascript
Scenario: Adding page with sections
Given there are existing sections named "Blog" and "Homepage"
Given there are existing collections named "Blog" and "Homepage"
When I go to the create page page
And I fill the code with "best_day_ever"
And I add "Blog" and "Homepage" sections to it
And I add "Blog" and "Homepage" collections to it
And I fill the slug with "Slug"
And I fill the name with "Best day ever"
And I fill the content with "This was the best day of my life"
Expand Down
23 changes: 23 additions & 0 deletions features/admin/managing_collections.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@managing_collections
Feature: Managing collections
In order to present the content in specific collections in my store
As an Administrator
I want to be able to edit and remove existing collections

Background:
Given the store operates on a single channel in "United States"
Given I am logged in as an administrator

@ui
Scenario: Deleting collection
Given there is a collection in the store
When I go to the collections page
And I delete this collection
Then I should be notified that the collection has been deleted
And I should see empty list of collections

@ui
Scenario: Seeing disabled code field while editing a collection
Given there is a collection in the store
When I want to edit this collection
Then the code field should be disabled
23 changes: 0 additions & 23 deletions features/admin/managing_sections.feature

This file was deleted.

21 changes: 21 additions & 0 deletions features/api/viewing_collections.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@shop_collections
Feature: Getting data from cms collections
In order to present dynamic content in my store
As an API user
I want to be able to display collections

Background:
Given the store operates on a single channel in "United States"
And there is a collection in the store
And there is an existing collection with "collection-1" code

@api
Scenario: Browsing collections
Given I want to browse collections
Then I should see 2 collections in the list
And I should see collection with code "collection-1"

@api
Scenario: Displaying collection
Given I view collection with code "collection-1"
Then I should see collection name
4 changes: 2 additions & 2 deletions features/api/viewing_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Feature: Getting data from cms pages
And the store has "iPhone 8" and "iPhone X" products
And there is a page in the store
And this page has these products associated with it
And there are existing sections named "Blog" and "General"
And this page has these sections associated with it
And there are existing collections named "Blog" and "General"
And this page has these collections associated with it
And this page has "About us" name
And this page has "about" code
And this page also has "about-us" slug
Expand Down
21 changes: 0 additions & 21 deletions features/api/viewing_sections.feature

This file was deleted.

12 changes: 6 additions & 6 deletions features/shop/browsing_pages_by_section.feature
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@shop_pages
Feature: Browsing pages by section
Feature: Browsing pages by collection
In order to read content like articles or blog posts
As a Customer
I want to browse pages by specific sections
I want to browse pages by specific collections

Background:
Given the store operates on a single channel in "United States"

@ui
Scenario: Browsing pages by section
Given there is a "Blog" section in the store
Scenario: Browsing pages by collection
Given there is a "Blog" collection in the store
And there are 15 pages in the store
And these pages have this section associated with it
When I go to the section pages list for the "blog" section
And these pages have this collection associated with it
When I go to the collection pages list for the "blog" collection
Then I should see 10 pages on the page
12 changes: 6 additions & 6 deletions features/shop/displaying_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ Feature: Displaying pages
Given there is a page in the store
And the store has "iPhone 8" and "iPhone X" products
And this page has these products associated with it
And there are existing sections named "Blog" and "General"
And this page has these sections associated with it
And there are existing collections named "Blog" and "General"
And this page has these collections associated with it
And this page has "About us" name
And this page also has "about-us" slug
And this page also has "Lorem ipsum" content
When I go to the "about-us" page
Then I should see a page with "About us" name
And I should also see "Lorem ipsum" content
And I should also see "iPhone 8" and "iPhone X" products associated with this page
And I should also see "Blog" and "General" sections associated with this page
And I should also see "Blog" and "General" collections associated with this page

@ui
Scenario: Displaying page link
Expand All @@ -36,8 +36,8 @@ Feature: Displaying pages
Given there is a page in the store
And the store has "iPhone 8" and "iPhone X" products
And this page has these products associated with it
And there are existing sections named "Blog" and "General"
And this page has these sections associated with it
And there are existing collections named "Blog" and "General"
And this page has these collections associated with it
And this page has "About us" name
And this page also has "about-us" slug
And this page also has "Lorem ipsum" content
Expand All @@ -46,7 +46,7 @@ Feature: Displaying pages
Then I should see a page with "About us" name
And I should also see "Lorem ipsum" content
And I should also see "iPhone 8" and "iPhone X" products associated with this page
And I should also see "Blog" and "General" sections associated with this page
And I should also see "Blog" and "General" collections associated with this page
And I should also see page image

@ui @javascript @title
Expand Down
46 changes: 46 additions & 0 deletions spec/Assigner/CollectionsAssignerSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
jkindly marked this conversation as resolved.
Show resolved Hide resolved

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Assigner;

use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssigner;
use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface;
use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface;
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface;
use PhpSpec\ObjectBehavior;

final class CollectionsAssignerSpec extends ObjectBehavior
{
public function let(CollectionRepositoryInterface $collectionRepository): void
{
$this->beConstructedWith($collectionRepository);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(CollectionsAssigner::class);
}

public function it_implements_collections_assigner_interface(): void
{
$this->shouldHaveType(CollectionsAssignerInterface::class);
}

public function it_assigns_collections(
CollectionRepositoryInterface $collectionRepository,
CollectionInterface $aboutCollection,
CollectionInterface $blogCollection,
CollectionableInterface $collectionsAware
jkindly marked this conversation as resolved.
Show resolved Hide resolved
): void
{
$collectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutCollection);
$collectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogCollection);

$collectionsAware->addCollection($aboutCollection)->shouldBeCalled();
$collectionsAware->addCollection($blogCollection)->shouldBeCalled();

$this->assign($collectionsAware, ['about', 'blog']);
}
}
45 changes: 0 additions & 45 deletions spec/Assigner/SectionsAssignerSpec.php

This file was deleted.

14 changes: 7 additions & 7 deletions spec/Entity/BlockSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use BitBag\SyliusCmsPlugin\Entity\Block;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
Expand Down Expand Up @@ -57,16 +57,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn
$this->hasProduct($firstProduct)->shouldReturn(false);
}

public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void
public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void
{
$this->addSection($firstSection);
$this->hasSection($firstSection)->shouldReturn(true);
$this->addCollection($firstCollection);
$this->hasCollection($firstCollection)->shouldReturn(true);

$this->hasSection($secondSection)->shouldReturn(false);
$this->hasCollection($secondCollection)->shouldReturn(false);

$this->removeSection($firstSection);
$this->removeCollection($firstCollection);

$this->hasSection($firstSection)->shouldReturn(false);
$this->hasCollection($firstCollection)->shouldReturn(false);
}

public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void
Expand Down
Loading
Loading