-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add test for CoolPreview formatter. #82
base: main
Are you sure you want to change the base?
Conversation
@@ -1,4 +1,4 @@ | |||
<div> | |||
<div class="cool-preview__wrapper"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to target the preview wrapper, added class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I am not sure about these class names.
We have cool-preview__wrapper, cool-editor__dialog, cool-frame__preview.
But atm I can't think of something better, so let's review this later.
The main risk here is that people start using the class in their CSS, and then it becomes harder to change.
So we should review all the html before a stable release.
So, ok for now.
$media->getName(), | ||
$media->getName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template is displaying first element duplicated on a multivalued field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should even test for cardinality > 1, as the whole system doesn't work but for the first element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, removed multivalued field configuration. Add isApplicable() and readme instruccions in another branch.
|
||
$crawler = new Crawler((string) \Drupal::service('renderer')->renderRoot($build)); | ||
$elements = $crawler->filter('div.cool-preview__wrapper'); | ||
$this->assertCount(count($expected_medias), $elements); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertSameSize
$this->assertCount(1, $dialog); | ||
$this->assertCount(1, $dialog->filter('iframe.cool-frame__preview')); | ||
// Library for each file. | ||
$this->assertEquals(['collabora_online/cool.previewer'], $build[$i]['#attached']['library']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm we shouldn't check this, this way... Doesn't it bubble up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. Added a check to see that the library is present or not.
$media->getName(), | ||
$media->getName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should even test for cardinality > 1, as the whole system doesn't work but for the first element.
70c85de
to
601e3e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some intermediate comments, will continue later.
@@ -1,4 +1,4 @@ | |||
<div> | |||
<div class="cool-preview__wrapper"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I am not sure about these class names.
We have cool-preview__wrapper, cool-editor__dialog, cool-frame__preview.
But atm I can't think of something better, so let's review this later.
The main risk here is that people start using the class in their CSS, and then it becomes harder to change.
So we should review all the html before a stable release.
So, ok for now.
protected static $modules = [ | ||
'collabora_online', | ||
'key', | ||
'media', | ||
'user', | ||
'field', | ||
'system', | ||
'file', | ||
'image', | ||
'entity_test', | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to repeat modules from the parent class.
protected static $modules = [ | |
'collabora_online', | |
'key', | |
'media', | |
'user', | |
'field', | |
'system', | |
'file', | |
'image', | |
'entity_test', | |
]; | |
protected static $modules = [ | |
'entity_test', | |
]; |
|
||
// Create test file. | ||
file_put_contents('public://file-1.txt', $this->randomString()); | ||
File::create(['uri' => 'public://test-1.txt'])->save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for the '-1' in the example file name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover, changing the name.
601e3e2
to
ae43924
Compare
ae43924
to
74f3e69
Compare
No description provided.