-
Notifications
You must be signed in to change notification settings - Fork 1
Acceptance test deepl #398
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
Draft
Tishasoumya-02
wants to merge
6
commits into
main
Choose a base branch
from
acceptance-test-deepl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
602ec7f
Add DeepL acceptance test support to test blocks translation with DeepL
Tishasoumya-02 8f04053
changelog
Tishasoumya-02 b3352ab
fix
Tishasoumya-02 b9c1099
Merge branch 'main' into acceptance-test-deepl
Tishasoumya-02 6973cdb
chores
Tishasoumya-02 fb76572
Remove ci-acceptance-deepl-test target from Makefile
Tishasoumya-02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add support for acceptance tests for blocks translation using DeepL @Tishasoumya-02 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| """Acceptance testing layer for the DeepL translation tests. | ||
|
|
||
| The intranet itself is monolingual, so the regular ``ROBOT_TESTING`` layer | ||
| stays English-only. The DeepL acceptance tests need a multilingual (en/de) | ||
| site with the DeepLSettings control panel, so they get their own layer that | ||
| installs the ``kitconcept.deepl`` profiles on top of the base fixture. | ||
| """ | ||
|
|
||
| from kitconcept.intranet.testing.base import BaseFixture | ||
| from plone.app.robotframework.autologin import AutoLogin | ||
| from plone.app.robotframework.content import Content | ||
| from plone.app.robotframework.genericsetup import GenericSetup | ||
| from plone.app.robotframework.i18n import I18N | ||
| from plone.app.robotframework.mailhost import MockMailHost | ||
| from plone.app.robotframework.quickinstaller import QuickInstaller | ||
| from plone.app.robotframework.remote import RemoteLibraryLayer | ||
| from plone.app.robotframework.server import Zope2ServerRemote | ||
| from plone.app.robotframework.testing import WSGI_SERVER_SINGLE_THREADED_FIXTURE | ||
| from plone.app.robotframework.testing import MockMailHostLayer as BaseMailLayer | ||
| from plone.app.robotframework.testing import PloneRobotFixture | ||
| from plone.app.robotframework.users import Users | ||
| from plone.app.testing import applyProfile | ||
| from plone.app.testing import FunctionalTesting | ||
| from plone.app.testing.interfaces import SITE_OWNER_NAME | ||
| from plone.testing import zope | ||
| from zope.globalrequest import setRequest | ||
|
|
||
|
|
||
| ANSWERS_CONTENT = { | ||
| "site_id": "plone", | ||
| "title": "Intranet", | ||
| "description": "Site created with A Plone distribution for Intranets with Plone. Created by kitconcept.", # noQA: E501 | ||
| "available_languages": ["en", "de"], | ||
| "portal_timezone": "Europe/Berlin", | ||
| "workflow": "public", | ||
| "setup_content": False, | ||
| "authentication": {"provider": "internal"}, | ||
| } | ||
|
|
||
|
|
||
| class DeepLContentFixture(BaseFixture): | ||
| sites = (("kitconcept-intranet", ANSWERS_CONTENT),) | ||
| # Load kitconcept.deepl ZCML so its control panel / services are available. | ||
| internal_packages = BaseFixture.internal_packages + ("kitconcept.deepl",) | ||
|
|
||
| def setUpDefaultContent(self, app): | ||
| super().setUpDefaultContent(app) | ||
| # Install the DeepL profiles on each created site so that the | ||
| # multilingual (en/de) language roots and the DeepLSettings control | ||
| # panel exist for the DeepL acceptance tests. | ||
| setRequest(app.REQUEST) | ||
| zope.login(app["acl_users"], SITE_OWNER_NAME) | ||
| for _distribution_name, answers in self.sites: | ||
| portal = app[answers["site_id"]] | ||
| applyProfile(portal, "kitconcept.deepl:initial") | ||
| applyProfile(portal, "kitconcept.deepl:default") | ||
| zope.logout() | ||
| setRequest(None) | ||
|
|
||
|
|
||
| DEEPL_CONTENT_FIXTURE = DeepLContentFixture() | ||
|
|
||
|
|
||
| class DeepLMockMailHostLayer(BaseMailLayer): | ||
| defaultBases = (DEEPL_CONTENT_FIXTURE,) | ||
|
|
||
|
|
||
| DEEPL_MOCK_MAILHOST_FIXTURE = DeepLMockMailHostLayer() | ||
|
|
||
|
|
||
| class DeepLRobotFixture(PloneRobotFixture): | ||
| """DeepL acceptance fixture, using robot framework, for kitconcept.intranet.""" | ||
|
|
||
| defaultBases = (DEEPL_MOCK_MAILHOST_FIXTURE,) | ||
|
|
||
| def setUpPloneSite(self, portal): | ||
| super().setUpPloneSite(portal) | ||
|
|
||
|
|
||
| DEEPL_ROBOT_FIXTURE = DeepLRobotFixture() | ||
|
|
||
| DEEPL_REMOTE_LIBRARY_BUNDLE_FIXTURE = RemoteLibraryLayer( | ||
| bases=(DEEPL_CONTENT_FIXTURE,), | ||
| libraries=( | ||
| AutoLogin, | ||
| QuickInstaller, | ||
| GenericSetup, | ||
| Content, | ||
| Users, | ||
| I18N, | ||
| MockMailHost, | ||
| Zope2ServerRemote, | ||
| ), | ||
| name="DeepLRemoteLibraryBundle:RobotRemote", | ||
| ) | ||
|
|
||
| DEEPL_ROBOT_TESTING = FunctionalTesting( | ||
| bases=( | ||
| DEEPL_ROBOT_FIXTURE, | ||
| DEEPL_REMOTE_LIBRARY_BUNDLE_FIXTURE, | ||
| WSGI_SERVER_SINGLE_THREADED_FIXTURE, | ||
| ), | ||
| name="Intranet:DeepLRobot", | ||
| ) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| context('Accordion Block', () => { | ||
| beforeEach(() => { | ||
| cy.intercept('GET', `/**/*?expand*`).as('content'); | ||
| cy.intercept('GET', '/**/Document').as('schema'); | ||
|
|
||
| cy.setupDeepL(); | ||
| cy.createContent({ | ||
| contentType: 'Document', | ||
| contentId: 'my-link-target', | ||
| contentTitle: 'Link Target', | ||
| path: '/en', | ||
| }); | ||
|
|
||
| cy.createContent({ | ||
| contentType: 'Document', | ||
| contentId: 'my-page', | ||
| contentTitle: 'Hello', | ||
| path: '/en', | ||
| }); | ||
| }); | ||
|
|
||
| it('create an accordion block (headline, panel title, nested text) and translate it', () => { | ||
| cy.visit('/en/my-link-target'); | ||
| cy.createTranslation(); | ||
| cy.url().should('include', '/de'); | ||
| cy.get('#toolbar-save').click(); | ||
|
|
||
| cy.visit('/en/my-page'); | ||
| cy.wait('@content'); | ||
| cy.navigate('/en/my-page/edit'); | ||
| cy.wait('@schema'); | ||
| cy.url().should('include', '/en'); | ||
|
|
||
| cy.getSlate().click(); | ||
| cy.addNewBlock('accordion'); | ||
|
|
||
| cy.get('.accordion:nth-child(2) > .title input').type('Same Title'); | ||
| cy.get('.accordion:nth-child(3) > .title input').type('Same Title'); | ||
| cy.get('.accordion:nth-child(4) > .title input').type('Different Title'); | ||
| cy.get('.text-slate-editor-inner') | ||
| .eq(0) | ||
| .click() | ||
| .type('Hello world{enter}', { | ||
| delay: 50, | ||
| }); | ||
|
|
||
| cy.focused().type('/image{enter}'); | ||
| cy.findAllByLabelText('Enter a URL to an image').filter(':visible').click(); | ||
| cy.get('.ui.input.editor-link.input-anchorlink-theme input').type( | ||
| 'https://github.com/plone/volto/raw/main/logos/volto-colorful.png{enter}', | ||
| ); | ||
| cy.get('.accordion:nth-child(2) .content .block.image figure img').should( | ||
| 'exist', | ||
| ); | ||
|
|
||
| cy.get( | ||
| '#blockform-fieldset-default .field-wrapper-title #field-title', | ||
| ).type('Hello image title'); | ||
| cy.get( | ||
| '#blockform-fieldset-default .field-wrapper-description #field-description', | ||
| ).type('Hello image description'); | ||
| cy.get( | ||
| '.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href"] button[aria-label="Open object browser"]', | ||
| ).click(); | ||
| cy.findByLabelText('Search SVG').click(); | ||
| cy.get('.ui.input.search').type('Link Target'); | ||
| cy.wait(500); | ||
| cy.get('[aria-label="Select Link Target"]').dblclick(); | ||
|
|
||
| cy.get('#toolbar-save').click(); | ||
| cy.createTranslation(); | ||
| cy.wait(2000); | ||
| cy.get('#toolbar-save').click(); | ||
| cy.url().should('include', '/de/'); | ||
|
|
||
| cy.get('.accordion-block .block.image figcaption .title').should( | ||
| 'contain', | ||
| 'Hallo', | ||
| ); | ||
| cy.get('.accordion-block .block.image figcaption .description').should( | ||
| 'contain', | ||
| 'Hallo', | ||
| ); | ||
| cy.get('.accordion-block .block.image a') | ||
| .should('have.attr', 'href') | ||
| .and('include', '/de'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.