From ca8f3d97669a1be99f7907e863617c0df3cee51c Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 00:38:19 +0300 Subject: [PATCH 01/23] Use defaultSrc too if it is set --- src/Form/Control/UploadImage.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index faa98b4b3d..6ff338b3ab 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -44,10 +44,8 @@ protected function init(): void /** * Set the thumbnail img src value. - * - * @param string $src */ - public function setThumbnailSrc($src): void + public function setThumbnailSrc(string $src): void { $this->thumbnail->setAttr(['src' => $src]); $action = $this->thumbnail->js(); @@ -58,11 +56,11 @@ public function setThumbnailSrc($src): void /** * Clear the thumbnail src. * You can also supply a default thumbnail src. - * - * @param string $defaultThumbnail */ - public function clearThumbnail($defaultThumbnail = null): void + public function clearThumbnail(string $defaultThumbnail = null): void { + $defaultThumbnail = defaultThumbnail ?? $this->defaultSrc; + $action = $this->thumbnail->js(); if ($defaultThumbnail !== null) { $action->attr('src', $defaultThumbnail); From 184a1f734e25c626fc019daef8799e759c3b8253 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 00:40:19 +0300 Subject: [PATCH 02/23] typo fix --- src/Form/Control/UploadImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 6ff338b3ab..ab43772946 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -59,7 +59,7 @@ public function setThumbnailSrc(string $src): void */ public function clearThumbnail(string $defaultThumbnail = null): void { - $defaultThumbnail = defaultThumbnail ?? $this->defaultSrc; + $defaultThumbnail = $defaultThumbnail ?? $this->defaultSrc; $action = $this->thumbnail->js(); if ($defaultThumbnail !== null) { From db237d688688fb775405172f80588ca96d0b87a4 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 00:46:48 +0300 Subject: [PATCH 03/23] phpfixer --- src/Form/Control/UploadImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index ab43772946..4d04cbc698 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -59,7 +59,7 @@ public function setThumbnailSrc(string $src): void */ public function clearThumbnail(string $defaultThumbnail = null): void { - $defaultThumbnail = $defaultThumbnail ?? $this->defaultSrc; + $defaultThumbnail ??= $this->defaultSrc; $action = $this->thumbnail->js(); if ($defaultThumbnail !== null) { From 836d9ac5649c362bf46f38954eb7d4d7d19bdd96 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 00:49:45 +0300 Subject: [PATCH 04/23] bugfix in demo --- demos/form-control/upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/form-control/upload.php b/demos/form-control/upload.php index a0bf309a6c..06e84e9605 100644 --- a/demos/form-control/upload.php +++ b/demos/form-control/upload.php @@ -21,7 +21,7 @@ // $control->set('a_generated_token'); $img->onDelete(function (string $fileId) use ($img) { - $img->clearThumbnail('./images/default.png'); + $img->clearThumbnail(); return new JsToast([ 'title' => 'Delete successfully', From 541b901ea58484c33cb3605dcc66d1920531916f Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 01:24:04 +0300 Subject: [PATCH 05/23] hint --- src/Form/Control/UploadImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 4d04cbc698..bf3b9f31da 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -19,7 +19,7 @@ class UploadImage extends Upload */ public $thumnailRegion = 'AfterAfterInput'; - /** @var string The default thumbnail source. */ + /** @var string|null The default thumbnail source. */ public $defaultSrc; protected function init(): void From 7738325f484f9f71e13cfbfd23c8a95c96ef1199 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Fri, 31 Mar 2023 12:38:12 +0300 Subject: [PATCH 06/23] better way --- src/Form/Control/UploadImage.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index bf3b9f31da..3200fb2ec0 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -59,7 +59,9 @@ public function setThumbnailSrc(string $src): void */ public function clearThumbnail(string $defaultThumbnail = null): void { - $defaultThumbnail ??= $this->defaultSrc; + if ($defaultThumbnail === null) { + $defaultThumbnail = $this->defaultSrc; + } $action = $this->thumbnail->js(); if ($defaultThumbnail !== null) { From d6de63e4093625743ba3197e7584639f5446450e Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 13:28:22 +0300 Subject: [PATCH 07/23] test behat --- tests-behat/upload.feature | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index ef64d0e80a..ddf65522d4 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -7,3 +7,6 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" + + When I click using selector "#atk_layout_maestro_form_form_layout_file_button" + Then Toast display should contain text "has been removed" From 0f68d20facc289d8b714dbf87c84e26178ff0a95 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 13:49:33 +0300 Subject: [PATCH 08/23] add behat test --- src/Behat/Context.php | 12 ++++++++++++ tests-behat/upload.feature | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 7048670b9a..0adbcc64e4 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -561,6 +561,18 @@ public function iSelectFile(string $inputName, string $fileContent, string $file EOF, [$element, array_map('ord', str_split($fileContent)), $fileName]); } + /** + * @Then Element :arg1 attribute :arg2 should contain text :arg3 + */ + public function elementAttributeShouldContainText(string $selector, string $attribute, string $text): void + { + $element = $this->findElement(null, $selector); + $attr = $element->getAttr($attribute); + if (!str_contains($attr, $text)) { + throw new \Exception('Element " . $selector . " attribute "' . $attribute . '" does not contain "' . $text . '"'); + } + } + private function getScopeBuilderRuleElem(string $ruleName): NodeElement { return $this->findElement(null, '.vqb-rule[data-name=' . $ruleName . ']'); diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index ddf65522d4..b727c23c9e 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -10,3 +10,10 @@ Feature: Upload When I click using selector "#atk_layout_maestro_form_form_layout_file_button" Then Toast display should contain text "has been removed" + + When I select file input "img" with "Foo" as "bar.png" + Then Toast display should contain text "is uploaded" + + When I click using selector "#atk_layout_maestro_form_form_layout_img_button" + Then Toast display should contain text "has been removed" + Then Element "#atk_layout_maestro_form_form_layout_img_view" attribute "src" contain text "default.png" From a1dfdb4f3b82c4d062cb8fc0b96c11a784409c1c Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 13:52:25 +0300 Subject: [PATCH 09/23] fix test --- src/Behat/Context.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 0adbcc64e4..4ca085340b 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -567,7 +567,7 @@ public function iSelectFile(string $inputName, string $fileContent, string $file public function elementAttributeShouldContainText(string $selector, string $attribute, string $text): void { $element = $this->findElement(null, $selector); - $attr = $element->getAttr($attribute); + $attr = $element->getAttribute($attribute); if (!str_contains($attr, $text)) { throw new \Exception('Element " . $selector . " attribute "' . $attribute . '" does not contain "' . $text . '"'); } From 9bb0f97e4422ae88cf67ea990fd43a6c6611fd3c Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 14:25:21 +0300 Subject: [PATCH 10/23] fix behat test --- tests-behat/upload.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index b727c23c9e..c9b766d849 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -16,4 +16,4 @@ Feature: Upload When I click using selector "#atk_layout_maestro_form_form_layout_img_button" Then Toast display should contain text "has been removed" - Then Element "#atk_layout_maestro_form_form_layout_img_view" attribute "src" contain text "default.png" + Then Element "#atk_layout_maestro_form_form_layout_img_view" attribute "src" should contain text "default.png" From 1f4e92b2b1e3cd4bd82013f0ece84cb4b9a1a47e Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 14:49:06 +0300 Subject: [PATCH 11/23] use getter to clean up init method --- src/Form/Control/UploadImage.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 3200fb2ec0..751351359e 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -17,7 +17,7 @@ class UploadImage extends Upload * * @var string */ - public $thumnailRegion = 'AfterAfterInput'; + public $thumbnailRegion = 'AfterAfterInput'; /** @var string|null The default thumbnail source. */ public $defaultSrc; @@ -30,16 +30,23 @@ protected function init(): void $this->accept = ['.jpg', '.jpeg', '.png']; } - if (!$this->thumbnail) { - $this->thumbnail = (new View(['element' => 'img', 'class' => ['right', 'floated', 'image'], 'ui' => true])) - ->setAttr(['width' => 36, 'height' => 36]); + $this->add($this->getThumbnail(), $this->thumnailRegion); + } + + public function getThumbnail(): View + { + if ($this->thumbnail) { + return $this->thumbnail; } + $this->thumbnail = (new View(['element' => 'img', 'class' => ['right', 'floated', 'image'], 'ui' => true])) + ->setAttr(['width' => 36, 'height' => 36]); + if ($this->defaultSrc) { $this->thumbnail->setAttr(['src' => $this->defaultSrc]); } - $this->add($this->thumbnail, $this->thumnailRegion); + return $this->thumbnail; } /** From 1af1c6b3d3b4c9515f6f499b16e6f0ef08e0ba35 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 14:51:08 +0300 Subject: [PATCH 12/23] typo fix --- docs/fileupload.rst | 2 +- src/Form/Control/UploadImage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fileupload.rst b/docs/fileupload.rst index 9016e48536..a6e44ad08c 100644 --- a/docs/fileupload.rst +++ b/docs/fileupload.rst @@ -140,7 +140,7 @@ UploadImage form control inherits all of the Upload properties plus these ones: The thumbnail view associated with the form control. -.. php:attr:: thumnailRegion +.. php:attr:: thumbnailRegion The region in input template where to add the thumbnail view, default to AfterAfterInput region. diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 751351359e..2ebb57568e 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -30,7 +30,7 @@ protected function init(): void $this->accept = ['.jpg', '.jpeg', '.png']; } - $this->add($this->getThumbnail(), $this->thumnailRegion); + $this->add($this->getThumbnail(), $this->thumbnailRegion); } public function getThumbnail(): View From 568593af40b6beda79e271f0ebe1eaa9db7f530e Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 19:06:05 +0300 Subject: [PATCH 13/23] whatever --- src/Form/Control/UploadImage.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 2ebb57568e..1d68a720c8 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -35,15 +35,13 @@ protected function init(): void public function getThumbnail(): View { - if ($this->thumbnail) { - return $this->thumbnail; - } - - $this->thumbnail = (new View(['element' => 'img', 'class' => ['right', 'floated', 'image'], 'ui' => true])) - ->setAttr(['width' => 36, 'height' => 36]); + if ($this->thumbnail === null) { + $this->thumbnail = (new View(['element' => 'img', 'class' => ['right', 'floated', 'image'], 'ui' => true])) + ->setAttr(['width' => 36, 'height' => 36]); - if ($this->defaultSrc) { - $this->thumbnail->setAttr(['src' => $this->defaultSrc]); + if ($this->defaultSrc) { + $this->thumbnail->setAttr(['src' => $this->defaultSrc]); + } } return $this->thumbnail; @@ -62,17 +60,12 @@ public function setThumbnailSrc(string $src): void /** * Clear the thumbnail src. - * You can also supply a default thumbnail src. */ - public function clearThumbnail(string $defaultThumbnail = null): void + public function clearThumbnail(): void { - if ($defaultThumbnail === null) { - $defaultThumbnail = $this->defaultSrc; - } - $action = $this->thumbnail->js(); - if ($defaultThumbnail !== null) { - $action->attr('src', $defaultThumbnail); + if ($this->defaultSrc !== null) { + $action->attr('src', $this->defaultSrc); } else { $action->removeAttr('src'); } From 0cc53c57b9771187be2451e063496aceeaa8be01 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 19:51:44 +0300 Subject: [PATCH 14/23] move method somewhere, not sure if better place --- src/Behat/Context.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 4ca085340b..8819d4c4db 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -561,18 +561,6 @@ public function iSelectFile(string $inputName, string $fileContent, string $file EOF, [$element, array_map('ord', str_split($fileContent)), $fileName]); } - /** - * @Then Element :arg1 attribute :arg2 should contain text :arg3 - */ - public function elementAttributeShouldContainText(string $selector, string $attribute, string $text): void - { - $element = $this->findElement(null, $selector); - $attr = $element->getAttribute($attribute); - if (!str_contains($attr, $text)) { - throw new \Exception('Element " . $selector . " attribute "' . $attribute . '" does not contain "' . $text . '"'); - } - } - private function getScopeBuilderRuleElem(string $ruleName): NodeElement { return $this->findElement(null, '.vqb-rule[data-name=' . $ruleName . ']'); @@ -821,6 +809,18 @@ public function textInContainerShouldMatchRegex(string $selector, string $regex) } } + /** + * @Then Element :arg1 attribute :arg2 should contain text :arg3 + */ + public function elementAttributeShouldContainText(string $selector, string $attribute, string $text): void + { + $element = $this->findElement(null, $selector); + $attr = $element->getAttribute($attribute); + if (!str_contains($attr, $text)) { + throw new \Exception('Element " . $selector . " attribute "' . $attribute . '" does not contain "' . $text . '"'); + } + } + // }}} /** From 1e1bb24527ac73fa83a8cdea930d2736b2869f1a Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 19:51:57 +0300 Subject: [PATCH 15/23] set more proper selector --- tests-behat/upload.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index c9b766d849..475512f1de 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "#atk_layout_maestro_form_form_layout_file_button" + When I click using selector "div[id$='file'] .action .button" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "#atk_layout_maestro_form_form_layout_img_button" + When I click using selector "div[id$='img'] .action .button" Then Toast display should contain text "has been removed" Then Element "#atk_layout_maestro_form_form_layout_img_view" attribute "src" should contain text "default.png" From b960ab9e3a2396981cc9dae4042dd05b4037c661 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 19:53:05 +0300 Subject: [PATCH 16/23] this one too --- tests-behat/upload.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index 475512f1de..97df471302 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -16,4 +16,4 @@ Feature: Upload When I click using selector "div[id$='img'] .action .button" Then Toast display should contain text "has been removed" - Then Element "#atk_layout_maestro_form_form_layout_img_view" attribute "src" should contain text "default.png" + Then Element "div[id$='img'] .action img" attribute "src" should contain text "default.png" From 6df348792fa9b90ef187788d32b4d66212ec78e1 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 20:39:34 +0300 Subject: [PATCH 17/23] better selectors --- tests-behat/upload.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index 97df471302..efbdf1c1de 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "div[id$='file'] .action .button" + When I click using selector "div.action[./div/input[@name='file']]/.button" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "div[id$='img'] .action .button" + When I click using selector "div.action[./div/input[@name='img']]/.button" Then Toast display should contain text "has been removed" - Then Element "div[id$='img'] .action img" attribute "src" should contain text "default.png" + Then Element "div.action[./div/input[@name='foo']]/img" attribute "src" should contain text "default.png" From 7f8abcefcc8eb7106e2036f29c4ef6725eeeea0e Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 20:47:01 +0300 Subject: [PATCH 18/23] double escape --- tests-behat/upload.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index efbdf1c1de..0bcaa68b2d 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "div.action[./div/input[@name='file']]/.button" + When I click using selector "div.action[.//div//input[@name='file']]//.button" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "div.action[./div/input[@name='img']]/.button" + When I click using selector "div.action[.//div//input[@name='img']]//.button" Then Toast display should contain text "has been removed" - Then Element "div.action[./div/input[@name='foo']]/img" attribute "src" should contain text "default.png" + Then Element "div.action[.//div//input[@name='foo']]//img" attribute "src" should contain text "default.png" From c8d4350e22001b99c2e73e52a51e0468f5f13a89 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 21:56:05 +0300 Subject: [PATCH 19/23] another try --- tests-behat/upload.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index 0bcaa68b2d..0b896ec928 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "div.action[.//div//input[@name='file']]//.button" + When I click using selector "xpath(//div.action[.//div//input[@name='file']]//.button[1])" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "div.action[.//div//input[@name='img']]//.button" + When I click using selector "xpath(//div.action[.//div//input[@name='img']]//.button[1])" Then Toast display should contain text "has been removed" - Then Element "div.action[.//div//input[@name='foo']]//img" attribute "src" should contain text "default.png" + Then Element "xpath(//div.action[.//div//input[@name='img']]//.img[1])" attribute "src" should contain text "default.png" From 549faf85d1093c544428ffd2c2ef891142d44998 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 22:27:37 +0300 Subject: [PATCH 20/23] wtf --- tests-behat/upload.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index 0b896ec928..ad72237f19 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "xpath(//div.action[.//div//input[@name='file']]//.button[1])" + When I click using selector "xpath(//div.action[.//div//input[@name='file']]//div.button[1])" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "xpath(//div.action[.//div//input[@name='img']]//.button[1])" + When I click using selector "xpath(//div.action[.//div//input[@name='img']]//div.button[1])" Then Toast display should contain text "has been removed" - Then Element "xpath(//div.action[.//div//input[@name='img']]//.img[1])" attribute "src" should contain text "default.png" + Then Element "xpath(//div.action[.//div//input[@name='img']]//img[1])" attribute "src" should contain text "default.png" From ac64b5d92704a60255439f2799372730d47c0d82 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 3 Apr 2023 22:40:30 +0300 Subject: [PATCH 21/23] maybe now it should work? --- tests-behat/upload.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index ad72237f19..693e762495 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "xpath(//div.action[.//div//input[@name='file']]//div.button[1])" + When I click using selector "xpath(//div.action[.//input[@name='file']]//*[contains(concat(' ', normalize-space(@class), ' '), ' button ')][1])" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "xpath(//div.action[.//div//input[@name='img']]//div.button[1])" + When I click using selector "xpath(//div.action[.//input[@name='img']]//*[contains(concat(' ', normalize-space(@class), ' '), ' button ')][1])" Then Toast display should contain text "has been removed" Then Element "xpath(//div.action[.//div//input[@name='img']]//img[1])" attribute "src" should contain text "default.png" From b87b3063428b6abb5c1763fedcbd7ae7f0993c23 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Tue, 4 Apr 2023 12:09:25 +0300 Subject: [PATCH 22/23] simplify selector --- tests-behat/upload.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests-behat/upload.feature b/tests-behat/upload.feature index 693e762495..b251b9b9cb 100644 --- a/tests-behat/upload.feature +++ b/tests-behat/upload.feature @@ -8,12 +8,12 @@ Feature: Upload When I select file input "file" with "Žlutý kůň" as "$kůň" Then Toast display should contain text "(name: $kůň, md5: b047fb155be776f5bbae061c7b08cdf0)" - When I click using selector "xpath(//div.action[.//input[@name='file']]//*[contains(concat(' ', normalize-space(@class), ' '), ' button ')][1])" + When I click using selector "xpath(//div.action[.//input[@name='file']]//div.button)" Then Toast display should contain text "has been removed" When I select file input "img" with "Foo" as "bar.png" Then Toast display should contain text "is uploaded" - When I click using selector "xpath(//div.action[.//input[@name='img']]//*[contains(concat(' ', normalize-space(@class), ' '), ' button ')][1])" + When I click using selector "xpath(//div.action[.//input[@name='img']]//div.button)" Then Toast display should contain text "has been removed" - Then Element "xpath(//div.action[.//div//input[@name='img']]//img[1])" attribute "src" should contain text "default.png" + Then Element "xpath(//div.action[.//div//input[@name='img']]//img)" attribute "src" should contain text "default.png" From e218f5f9a67ad178ad175d3253266eade829a2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 4 Apr 2023 11:25:56 +0200 Subject: [PATCH 23/23] unify if --- src/Form/Control/UploadImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index 1d68a720c8..7ea1cc1bca 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -39,7 +39,7 @@ public function getThumbnail(): View $this->thumbnail = (new View(['element' => 'img', 'class' => ['right', 'floated', 'image'], 'ui' => true])) ->setAttr(['width' => 36, 'height' => 36]); - if ($this->defaultSrc) { + if ($this->defaultSrc !== null) { $this->thumbnail->setAttr(['src' => $this->defaultSrc]); } }