Skip to content

Commit

Permalink
Fix jsonld and slick tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbosen authored Oct 24, 2023
1 parent 212acce commit 8fa33cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
11 changes: 10 additions & 1 deletion modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ public function testSchema(): void {
$this->config('metatag.metatag_defaults.node__article')->set('tags', $tags)
->save();

$this->runAndTestQuery('jsonld');
$schema = 'jsonld';

$query = $this->getQueryFromFile($schema);
$variables = $this->getVariablesFromFile($schema);

$responseData = $this->jsonDecode(strip_tags($this->getResponseData($query, $variables)['jsonld']));
$expectedData = $this->jsonDecode(strip_tags($this->jsonDecode($this->getExpectedResponseFromFile($schema))['data']['jsonld']));

$this->assertEqualsCanonicalizing($expectedData, $responseData);

}

}
28 changes: 13 additions & 15 deletions tests/src/FunctionalJavascript/MediaGalleryModifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ public function testOrderChange(): void {

$this->clickSave();

$gallery = $this->loadMediaByUuid('df67621b-518f-4159-a59e-1bad0700800c');
$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');

// Check that, 2nd image is file: 26357237683_0891e46ba5_k.jpg.
$fileNamePosition = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned):nth(1) img\').attr(\'src\').indexOf("26357237683_0891e46ba5_k.jpg")');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned):nth(1) img\').attr(\'src\').indexOf("26357237683_0891e46ba5_k.jpg")');
$this->assertNotEquals(-1, $fileNamePosition, 'For 2nd image in gallery, used file should be "26357237683_0891e46ba5_k.jpg".');
}

Expand All @@ -99,17 +98,16 @@ public function testAddRemove(): void {

$this->clickSave();

$gallery = $this->loadMediaByUuid('df67621b-518f-4159-a59e-1bad0700800c');
$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');

// Check that, there are 4 images in gallery.
$numberOfImages = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned)\').length;');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned)\').length;');
$this->assertEquals(4, $numberOfImages, 'There should be 4 images in Gallery.');

// Check that, 2nd image is file: 26315068204_24ffa6cfc4_o.jpg.
$fileNamePosition = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned):nth(1) img\').attr(\'src\').indexOf("26315068204_24ffa6cfc4_o.jpg")');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned):nth(1) img\').attr(\'src\').indexOf("26315068204_24ffa6cfc4_o.jpg")');
$this->assertNotEquals(-1, $fileNamePosition, 'For 2nd image in gallery, used file should be "26315068204_24ffa6cfc4_o.jpg".');

// Test add + reorder inside media library.
Expand All @@ -131,15 +129,15 @@ public function testAddRemove(): void {

// Check that, there are 5 images in gallery.
$numberOfImages = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned)\').length;');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned)\').length;');
$this->assertEquals(5, $numberOfImages, 'There should be 5 images in Gallery.');

$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');

// Check that, 3rd image is file: reference.jpg.
$fileNamePosition = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned):nth(2) img\').attr(\'src\').indexOf("reference.jpg")');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned):nth(2) img\').attr(\'src\').indexOf("reference.jpg")');
$this->assertNotEquals(-1, $fileNamePosition, 'For 3rd image in gallery, used file should be "reference.jpg".');

// Test remove inside media library.
Expand All @@ -159,15 +157,15 @@ public function testAddRemove(): void {

// Check that, there are 4 images in gallery.
$numberOfImages = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned)\').length;');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned)\').length;');
$this->assertEquals(4, $numberOfImages, 'There should be 4 images in Gallery.');

$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');
$this->clickCssSelector('div.slick--initialized.slick--field-media-images button.slick-next');

// Check that, 3rd image is not file: reference.jpg.
$fileNamePosition = $this->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 div.slick-slide:not(.slick-cloned):nth(2) img\').attr(\'src\').indexOf("reference.jpg")');
->evaluateScript('jQuery(\'div.slick--initialized.slick--field-media-images div.slick-slide:not(.slick-cloned):nth(2) img\').attr(\'src\').indexOf("reference.jpg")');
$this->assertEquals(-1, $fileNamePosition, 'For 2nd image in gallery, used file should not be "reference.jpg".');
}

Expand Down

0 comments on commit 8fa33cb

Please sign in to comment.