From f8d7605d6d74ab0419a9f43a974ac91309040b83 Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 10:31:38 +0200 Subject: [PATCH 1/7] improve test --- .../tests/src/Functional/JsonLdSchemaTest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php b/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php index 319346dbf..fcd3f7e2f 100644 --- a/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php +++ b/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php @@ -22,7 +22,17 @@ 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); + } } From 44d90aa969d3ab3d2f2c364003a9b83414ba922b Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 10:33:40 +0200 Subject: [PATCH 2/7] fix cs --- modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php b/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php index fcd3f7e2f..c2b62e4c2 100644 --- a/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php +++ b/modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php @@ -30,7 +30,6 @@ public function testSchema(): void { $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); } From 31811e8eba8493c36f061494ab5cd1c348069478 Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 12:15:52 +0200 Subject: [PATCH 3/7] fix slick test --- tests/src/FunctionalJavascript/MediaGalleryModifyTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php index 139ab4346..86a5800ae 100644 --- a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php +++ b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php @@ -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 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 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".'); } From 7b7a1372ec82a0651d372ffa71665c204ffb2103 Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 12:50:22 +0200 Subject: [PATCH 4/7] more slick fixes --- .../MediaGalleryModifyTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php index 86a5800ae..25459dfc5 100644 --- a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php +++ b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php @@ -99,16 +99,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 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 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 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. @@ -133,12 +133,12 @@ public function testAddRemove(): void { ->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-' . $gallery->id() . '-1 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 button.slick-next'); + $this->clickCssSelector('div.slick--initialized 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 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. @@ -158,15 +158,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 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 button.slick-next'); + $this->clickCssSelector('div.slick--initialized 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 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".'); } From 6439da24684ce4d8ed51275dfbc831f062689b4b Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 13:23:48 +0200 Subject: [PATCH 5/7] and more fixes --- tests/src/FunctionalJavascript/MediaGalleryModifyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php index 25459dfc5..462a994da 100644 --- a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php +++ b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php @@ -130,7 +130,7 @@ 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 div.slick-slide:not(.slick-cloned)\').length;'); $this->assertEquals(5, $numberOfImages, 'There should be 5 images in Gallery.'); $this->clickCssSelector('div.slick--initialized button.slick-next'); From fc77ee5f3fdbef9a34aafae6d01aead383b1b29e Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 13:27:30 +0200 Subject: [PATCH 6/7] remove unused variable --- tests/src/FunctionalJavascript/MediaGalleryModifyTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php index 462a994da..df744f895 100644 --- a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php +++ b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php @@ -98,7 +98,6 @@ public function testAddRemove(): void { $this->clickSave(); - $gallery = $this->loadMediaByUuid('df67621b-518f-4159-a59e-1bad0700800c'); $this->clickCssSelector('div.slick--initialized button.slick-next'); // Check that, there are 4 images in gallery. From c716670f87357cb93ed273cbd9cb2adff4c703cf Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 24 Oct 2023 14:47:33 +0200 Subject: [PATCH 7/7] restrict to fieldname --- .../MediaGalleryModifyTest.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php index df744f895..0a57d6fd2 100644 --- a/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php +++ b/tests/src/FunctionalJavascript/MediaGalleryModifyTest.php @@ -67,11 +67,11 @@ public function testOrderChange(): void { $this->clickSave(); - $this->clickCssSelector('div.slick--initialized 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(\'div.slick--initialized 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".'); } @@ -98,16 +98,16 @@ public function testAddRemove(): void { $this->clickSave(); - $this->clickCssSelector('div.slick--initialized 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(\'div.slick--initialized 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(\'div.slick--initialized 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. @@ -129,15 +129,15 @@ public function testAddRemove(): void { // Check that, there are 5 images in gallery. $numberOfImages = $this->getSession() - ->evaluateScript('jQuery(\'div.slick--initialized 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('div.slick--initialized button.slick-next'); - $this->clickCssSelector('div.slick--initialized 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(\'div.slick--initialized 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. @@ -157,15 +157,15 @@ public function testAddRemove(): void { // Check that, there are 4 images in gallery. $numberOfImages = $this->getSession() - ->evaluateScript('jQuery(\'div.slick--initialized 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('div.slick--initialized button.slick-next'); - $this->clickCssSelector('div.slick--initialized 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(\'div.slick--initialized 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".'); }