Problem/Motivation

View mode class appears only with the media--view-mode- prefix and no actual view mode. The reason for that is the fact that preprocess adds its machine name while template expects the object.

Comments

slashrsm created an issue. See original summary.

slashrsm’s picture

Status: Active » Needs review
StatusFileSize
new593 bytes
sarguna raj m’s picture

Assigned: Unassigned » sarguna raj m
sarguna raj m’s picture

Assigned: sarguna raj m » Unassigned

Hi slashrsm,

I have applied the patch #2 and it has applied successfully without any issue. But I'm unable to test it. Could please provide a Test case to test the patch.

Thanks.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pierre-nono’s picture

Thanks you slashrsm, this fixed our problem.

To sarguna raj M, I don't really see the point of a Test case pour this.
Just create a media, any type, and check the html if you see the class media--view-mode-your_view_id on it.

dawehner’s picture

StatusFileSize
new1.47 KB
new2.05 KB

I think here is a test which works.

berdir’s picture

+++ b/core/modules/media/tests/src/Kernel/MediaTemplateTest.php
@@ -0,0 +1,50 @@
+ * Tests the templates shipped by media module.

it's actually shipped by classy, and we're also only testing that now I think?

Also wondering if a kernel test for this really makes sense or if we should just add an assertContains() to \Drupal\Tests\media\Functional\MediaUiFunctionalTest or a similar existing actual web test?

dawehner’s picture

StatusFileSize
new1.42 KB
new861 bytes

That is a good point!

The last submitted patch, 7: 2930274-test.patch, failed testing. View results

The last submitted patch, 7: 2930274-7.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 9: 2920678-test.patch, failed testing. View results

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.48 KB
new919 bytes

Wow, it is not obvious that cssSelect works different on a different environment.

The last submitted patch, 13: 2930274-13.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 13: 2930274-test.patch, failed testing. View results

berdir’s picture

Status: Needs work » Reviewed & tested by the community

Just removed the print_r() leftover, I expect this will pass.

berdir’s picture

StatusFileSize
new1.42 KB
sam152’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.3 KB

Came here to RTBC, but tiny nit, this is also equivalent to:

  $this->assertSession()->elementsCount('css', '.media--view-mode-full', 1);
sam152’s picture

Status: Needs review » Reviewed & tested by the community

Whoops, this was already RTBC to begin with. Setting back for #17. If #18 passes, I suppose we can use that one too.

berdir’s picture

#18 looks fine, agreed that if that passes, that's the patch to commit :)

Yeah, I kind of RTBC'd my own patch but I just removed a debug line. This way it's better anyway :)

  • lauriii committed b888a36 on 8.6.x
    Issue #2930274 by dawehner, Berdir, slashrsm, Sam152: View mode class is...

  • lauriii committed 76c103f on 8.5.x
    Issue #2930274 by dawehner, Berdir, slashrsm, Sam152: View mode class is...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Committed b888a36 and pushed to 8.6.x. Also cherry-picked to 8.5.x 76c103f because it seems highly unlikely that anyone would have themed using the broken class name. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.