Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions config/bolt/contenttypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ tests:
picture:
type: image
postfix: An image, named differently.
attachment:
type: file
markdown_field:
type: markdown
textarea_field:
Expand Down
13 changes: 13 additions & 0 deletions public/theme/skeleton/custom/test.twig
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@
<hr>
{% endif %}

<h2>Testing output for files</h2>

{% if record.attachment %}
<div id="attachment">
<p id="filename">Filename: {{ record.attachment.filename }}</p>
<p id="path">Path: {{ record.attachment.path }}</p>
<p id="fieldname">Fieldname: {{ record.attachment.fieldname }}</p>
<p id="url">URL: {{ record.attachment.url }}</p>
<p id="title">{{ record.attachment.title }}</p>
{{ dump(record.attachment) }}
</div>
{% endif %}


{# Output all fields, in the order as defined in the content type.
To change the generated html and configure the options, see:
Expand Down
28 changes: 26 additions & 2 deletions src/DataFixtures/ContentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,22 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool

break;
case 'image':
case 'file':
$randomImage = $this->imagesIndex->random();
$data = [
'filename' => $randomImage->getRelativePathname(),
'alt' => $this->faker->sentence(4, true),
'media' => '',
];

break;
case 'file':
$randomImage = $this->imagesIndex->random();
$data = [
'filename' => $randomImage->getRelativePathname(),
'title' => $this->faker->sentence(4, true),
'media' => '',
];

break;
case 'slug':
$data = $this->lastTitle ?? [$this->faker->sentence(3, true)];
Expand Down Expand Up @@ -260,7 +268,6 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool

break;
case 'imagelist':
case 'filelist':
$data = [];
for ($i = 1; $i < 5; $i++) {
$randomImage = $this->imagesIndex->random();
Expand All @@ -271,6 +278,18 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool
];
}

break;
case 'filelist':
$data = [];
for ($i = 1; $i < 5; $i++) {
$randomImage = $this->imagesIndex->random();
$data[] = [
'filename' => $randomImage->getRelativePathname(),
'title' => $this->faker->sentence(4, true),
'media' => '',
];
}

break;
default:
$data = [$this->faker->sentence(6, true)];
Expand Down Expand Up @@ -319,6 +338,11 @@ private function getPresetRecords(): array
'markdown_field' => 'Markdown field with *simple* Markdown in it.',
'text_not_sanitised' => 'Text field with <strong>markup</strong>, including <script>console.log(\'hoi\')</script>. The end.',
'text_sanitised' => 'Text field with <strong>markup</strong>, including <script>console.log(\'hoi\')</script>. The end.',
'attachment' => [
'filename' => 'joey.jpg',
'title' => $this->faker->sentence(4, true),
'media' => '',
],
];
$records['pages'][] = [
'heading' => 'This is a page',
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/display_record_test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ Feature: Test field output

And I should see "Text field with <strong>markup</strong>, including <script>console.log('hoi')</script>. The end." in the ".text_sanitise_a" element
And I should see "Text field with <strong>markup</strong>, including . The end." in the ".text_sanitise_b" element

@javascript
Scenario: As a user I want to see how file fields are displayed
Given I am on "/test/title-of-the-test"
Then I wait for ".title"

And I should see "joey.jpg" in the "#attachment #filename" element
And I should see "/files/joey.jpg" in the "#attachment #path" element
And I should see "attachment" in the "#attachment #fieldname" element
And I should see "http" in the "#attachment #url" element
And I should see "://" in the "#attachment #url" element
And I should see "/files/joey.jpg" in the "#attachment #url" element