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

Fix jsonld and slick tests. #749

Merged
merged 7 commits into from
Oct 24, 2023
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
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