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

Issue 28656 inline translation rest api #28856

Conversation

zaximus84
Copy link

Description (*)

When inline translation is enabled for the storefront, it should be limited to the frontend where HTML is rendered. However, making an API call to /rest/V1/integration/admin/token with bad credentials while inline translation is enabled results in inline translation markup around the error message in the API response.

Since inline translation markup is only useful in the adminhtml and frontend areas, this PR adds an area check in addition to the existing configuration checks before rendering inline translation markup.

Fixed Issues (if relevant)

  1. Fixes Enabled Translation inline affect to result of REST APIs. #28656

Manual testing scenarios (*)

  1. Go to admin
  2. Stores > Settings > Configuration
  3. In the left panel, expand Advanced and choose Developer
  4. Expand selector the Translate Inline section
  5. Set Enabled for Storefront to Yes
  6. Click on save config
  7. Try to login to admin as a user using API-
    POST - {Baseurl}/rest/V1/integration/admin/token
    Body - {"username": "","password": ""}
  8. Confirm the response does not contain inline translation markup (a )

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 are green)

Zach Nanninga added 3 commits June 19, 2020 11:24
…ranslated phrases for areas other than frontend and adminhtml.
…rios, and add scenarios for all other areas where other enabled checks are true
@m2-assistant
Copy link

m2-assistant bot commented Jun 23, 2020

Hi @zaximus84. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

@ghost ghost added this to Pending Review in Pull Requests Dashboard Jun 23, 2020
@swnsma swnsma self-requested a review June 24, 2020 10:26
@swnsma swnsma self-assigned this Jun 24, 2020
@ghost ghost added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Jun 24, 2020
Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

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

Hi @zaximus84!
Please check my suggestions.
Also, please check failed tests.

*
* @return bool
*/
private function isAreaAllowed()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private function isAreaAllowed()
private function isAreaAllowed(): bool

@@ -89,6 +103,7 @@ public function __construct(
\Magento\Framework\Translate\Inline\ConfigInterface $config,
\Magento\Framework\Translate\Inline\ParserInterface $parser,
\Magento\Framework\Translate\Inline\StateInterface $state,
\Magento\Framework\App\State $appState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
\Magento\Framework\App\State $appState,
\Magento\Framework\App\State $appState = null,

@@ -99,6 +114,7 @@ public function __construct(
$this->config = $config;
$this->parser = $parser;
$this->state = $state;
$this->appState = $appState;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->appState = $appState;
$this->appState = $appState ?: \Magento\Framework\App\ObjectManager::getInstance()
->(\Magento\Framework\App\State::class);

@ghost ghost moved this from Pending Review to Changes Requested in Pull Requests Dashboard Jun 24, 2020
@swnsma swnsma added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Jun 24, 2020
@swnsma
Copy link
Contributor

swnsma commented Jun 24, 2020

@magento run all tests

@engcom-Charlie engcom-Charlie self-assigned this Jun 30, 2020
@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

Hi @zaximus84, can You please fix failed tests and look through requested changes?

@swnsma
Copy link
Contributor

swnsma commented Jul 7, 2020

@magento run all tests

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@ghost ghost moved this from Review in Progress to Ready for Testing in Pull Requests Dashboard Jul 13, 2020
@magento-engcom-team
Copy link
Contributor

Hi @swnsma, thank you for the review.
ENGCOM-7829 has been created to process this Pull Request

@engcom-Alfa engcom-Alfa self-assigned this Jul 14, 2020
@engcom-Alfa engcom-Alfa moved this from Ready for Testing to Testing in Progress in Pull Requests Dashboard Jul 14, 2020
@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Go to Admin-> Stores -> Configuration -> Advanced -> Developer -> Translate Inline;
  2. Set Enabled for Storefront to Yes and Save;
  3. Clean cache;
  4. Go to Storefront -> Sign In

Actual Result: ✔️ Inline translate for Storefront is enabled

Screenshot from 2020-07-14 12-02-12

  1. Try to login to admin as a user using API-
    POST - {Baseurl}/rest/V1/integration/admin/token
    Body - {"username": "","password": ""}

Before: ✖️ Result from rest API:

2020-07-14_11-03

After: ✔️ Inline translation only affects frontend side and the response does not contain inline translation markup

{
  "message": "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.",
}

@engcom-Alfa engcom-Alfa moved this from Testing in Progress to Extended Testing (optional) in Pull Requests Dashboard Jul 14, 2020
@engcom-Charlie engcom-Charlie added the QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) label Jul 20, 2020
@engcom-Alfa engcom-Alfa added QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope and removed QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) labels Jul 22, 2020
@engcom-Charlie engcom-Charlie moved this from Extended Testing (optional) to Merge in Progress in Pull Requests Dashboard Jul 22, 2020
@slavvka slavvka added the Severity: S1 Affects critical data or functionality and forces users to employ a workaround. label Jul 22, 2020
@slavvka slavvka added this to the 2.4.1 milestone Jul 22, 2020
@magento-engcom-team magento-engcom-team merged commit 1b29b28 into magento:2.4-develop Jul 23, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jul 23, 2020

Hi @zaximus84, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@ghost ghost moved this from Merge in Progress to Recently Merged in Pull Requests Dashboard Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Component: Translate Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
Pull Requests Dashboard
  
Recently Merged
Development

Successfully merging this pull request may close these issues.

Enabled Translation inline affect to result of REST APIs.
6 participants