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

Solve problem saving empty swatches in admin #13220

Merged

Conversation

enriquei4
Copy link
Contributor

@enriquei4 enriquei4 commented Jan 16, 2018

Description

Solve problem saving empty swatches in admin remving html ement instead of add hidden.

Fixed Issues (if relevant)

  1. Swatch Attribute is not getting save while deleting a swatch row with empty admin scope text Swatch Attribute is not getting save while deleting a swatch row with empty admin scope text #13117

Manual testing scenarios

  1. Login to admin and Goto Store- >Attribute->Product
  2. Find a attribute like color
  3. Open color attribute and make it to Visual Swatch type
  4. In Manage Swatches section add color swatches
  5. Now Click on Add Swatch button, a row will appear just remove it without filling anything into it.
  6. Now is saved. Before it throws: The value of Admin scope can't be empty.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@enriquei4 enriquei4 added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Jan 16, 2018
@enriquei4
Copy link
Contributor Author

enriquei4 commented Jan 16, 2018

@serhii-balko i commited with a different email, i created this new PR to clean: #13154

@@ -110,6 +110,11 @@ public function execute()
$options
);
$valueOptions = (isset($options['value']) && is_array($options['value'])) ? $options['value'] : [];
foreach ($valueOptions as $key => $valueOption) {
if (isset($options['delete'][$key]) && $options['delete'][$key]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use if(!empty($options['delete'][$key])).

Copy link
Contributor

@serhii-balko serhii-balko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enriquei4
Copy link
Contributor Author

Hi guys, i fixed the dataprovider it had a mistake, now is solved. $isError should be "false"

Copy link
Contributor

@serhii-balko serhii-balko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the best way to test this case: add new cases in provideEmptyOption provider like this

'empty admin scope options and deleted' => [
                [
                    'value' => [
                        "option_0" => [''],
                    ],
                    'delete' => [
                        'option_0' => '1',
                    ],
                ],
                (object) [
                    'error' => false,
                ],
            ],
            'empty admin scope options and not deleted' => [
                [
                    'value' => [
                        "option_0" => [''],
                    ],
                    'delete' => [
                        'option_0' => '0',
                    ],
                ],
                (object) [
                    'error' => true,
                    'message' => 'The value of Admin scope can\'t be empty.',
                ],
            ],

@enriquei4
Copy link
Contributor Author

Hi @serhii-balko should I remove the previous test case for testUniqueValidation?

fix codestyle

Fix codacy unused variable in for, and improve condition

add test

Fix test

add testcases empty
Copy link
Contributor

@serhii-balko serhii-balko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be better if you remove it

@enriquei4
Copy link
Contributor Author

But that (first)case is working well, and is testing well the code. If i remove the new code (validate.php) the test fails, then i think that is useful.

@enriquei4
Copy link
Contributor Author

@serhii-balko did you read my last comment :) (I understand that you could be busy)

Copy link
Contributor

@magento-engcom-team magento-engcom-team left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, We approved this changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Award: test coverage Progress: accept Release Line: 2.3 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants