Skip to content

Commit

Permalink
Merge pull request #104 from lilt/3.x-neo-fallback
Browse files Browse the repository at this point in the history
Added fallback for block elements without a created structure
  • Loading branch information
hadomskyi authored May 20, 2023
2 parents 30ff9d7 + 48aa883 commit b9cac05
Show file tree
Hide file tree
Showing 21 changed files with 3,327 additions and 40 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 3.5.3 - 2023-05-18
### Fixed
- Added fallback for block elements without a created structure to fix content provider

## 3.5.2 - 2023-05-17
### Changed
- Updated error message for failed jobs after retries

### Fixed
- Resolved duplication issue with Neo and SuperTable fields

## 3.5.1 - 2023-04-04
### Fixed
- Query for fetching translations by status and id
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lilt/craft-lilt-plugin",
"description": "The Lilt plugin makes it easy for you to send content to Lilt for translation right from within Craft CMS.",
"type": "craft-plugin",
"version": "3.5.1",
"version": "3.5.3",
"keywords": [
"craft",
"cms",
Expand Down
1 change: 1 addition & 0 deletions e2e/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CYPRESS_APP_URL=
CYPRESS_API_URL=
CYPRESS_API_KEY=
CYPRESS_MOCKSERVER_HOST=
CYPRESS_MOCKSERVER_PORT=
CYPRESS_USER_NAME=
Expand Down
1 change: 1 addition & 0 deletions e2e/.env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CYPRESS_APP_URL=http://app:8080
CYPRESS_API_URL=http://mockserver:1080
CYPRESS_API_KEY=this_is_apy_key
CYPRESS_MOCKSERVER_HOST=mockserver
CYPRESS_MOCKSERVER_PORT=1080
CYPRESS_MOCKSERVER_ENABLED=true
Expand Down
2 changes: 1 addition & 1 deletion e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
cypress/videos
.idea
cypress.env.json
*.env.json
happy-lager-main/
!happy-lager-override/composer.lock
*.override.yml
3 changes: 3 additions & 0 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ up: clone down
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=5 >> .env'
docker-compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'
docker-compose exec -T app sh -c 'php craft plugin/install neo'
docker-compose exec -T app sh -c 'php craft plugin/install super-table'
docker-compose exec -T app sh -c 'php craft project-config/rebuild'
docker-compose exec -T app sh -c 'php craft up'
docker-compose exec -T app sh -c 'php craft migrate/up'
docker-compose exec -T app sh -c 'php craft queue/run'
Expand Down
11 changes: 11 additions & 0 deletions e2e/cypress.env.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"APP_URL": "http://localhost:88",
"API_URL": "http://mockserver:1080",
"API_KEY": "this_is_apy_key",
"MOCKSERVER_HOST": "localhost",
"MOCKSERVER_PORT": "1080",
"MOCKSERVER_ENABLED": "true",
"USER_NAME": "admin",
"USER_PASSWORD": "password",
"ASSERT_ENTRY_CONTENT": "false"
}
6 changes: 2 additions & 4 deletions e2e/cypress/e2e/queues/failed.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ describe(
invoke('attr', 'data-status').
should('equal', 'failed');

cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Job failed after 0 attempt(s). Error message: [500] Server error: `POST http://mockserver:1080/jobs` resulted in a `500 Internal Server Error` response')
cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Job failed after 1 attempt(s). Error message: [500] Server error: `POST http://mockserver:1080/jobs` resulted in a `500 Internal Server Error` response')
cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Job failed after 2 attempt(s). Error message: [500] Server error: `POST http://mockserver:1080/jobs` resulted in a `500 Internal Server Error` response')
cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Job failed after 3 attempt(s). Error message: [500] Server error: `POST http://mockserver:1080/jobs` resulted in a `500 Internal Server Error` response')
cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Unexpected error: [500] Server error: `POST http://mockserver:1080/jobs` resulted in a `500 Internal Server Error` response')
cy.get('.lilt-job-activity-log').invoke('text').should('contain', 'Job failed after 3 attempt(s)')
});
});
68 changes: 46 additions & 22 deletions e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Cypress.Commands.add('openJob', (title) => {
*/
Cypress.Commands.add('setConfigurationOption', (option, enabled) => {
const apiUrl = Cypress.env('API_URL');
const apiKey = Cypress.env('API_KEY');
const appUrl = Cypress.env('APP_URL');

const options = {
Expand Down Expand Up @@ -140,8 +141,13 @@ Cypress.Commands.add('setConfigurationOption', (option, enabled) => {

cy.visit(`${appUrl}/admin/craft-lilt-plugin/settings`);

cy.get('#connectorApiUrl').clear().type(apiUrl);
cy.get('#connectorApiKey').clear().type('this_is_apy_key');
if (apiUrl) {
cy.get('#connectorApiUrl').clear().type(apiUrl);
}

if(apiKey) {
cy.get('#connectorApiKey').clear().type('this_is_apy_key');
}

cy.get('#content .btn.submit').click();

Expand Down Expand Up @@ -292,15 +298,15 @@ Cypress.Commands.add('resetEntryContent', (entryId, languages) => {

cy.get('.redactor-in').then(els => {
[...els].forEach(el => {
cy.wrap(el).clear();
cy.wrap(el).type('This content should be changed');
cy.wrap(el).clear({force: true});
cy.wrap(el).type('This content should be changed', {force: true});
});
});

cy.get('#fields .input input[type="text"]').then(els => {
[...els].forEach(el => {
cy.wrap(el).clear();
cy.wrap(el).type('This content should be changed');
cy.wrap(el).clear({force: true});
cy.wrap(el).type('This content should be changed', {force: true});
});
});

Expand Down Expand Up @@ -556,22 +562,40 @@ Cypress.Commands.add('assertEntryContent',
capture: 'fullPage',
});

for (let expectedValue of expected[language]) {
//TODO: check why CraftCMS add or remove extra spaces on html elements
cy.get(expectedValue.id, {timeout: 1000}).
invoke(expectedValue.functionName).
should('not.equal', 'This content should be changed');

cy.get(expectedValue.id, {timeout: 1000}).
invoke(expectedValue.functionName).
then(text => {
expect(
text.replace(/<[^>]*>/g, ''),
).to.equal(
expectedValue.value.replace(/<[^>]*>/g, ''),
);
});
}
let values = [];
cy.get('input, textarea').each(($input) => {
const value = $input.val(); // Assuming the input uses jQuery syntax

if (value != '') {
values.push(value.replace(/<[^>]*>/g, ''));
}
}).then(() => {
for (let expectedValue of expected[language]) {
if (expectedValue.type === 'nested') {
expect(values.indexOf(expectedValue.value.replace(/<[^>]*>/g, '')), `Asserting that page has input or textarea with content: "${expectedValue.value}"`).
to.
be.
not.
equal(-1);

continue;
}
//TODO: check why CraftCMS add or remove extra spaces on html elements
cy.get(expectedValue.id, {timeout: 1000}).
invoke(expectedValue.functionName).
should('not.equal', 'This content should be changed');

cy.get(expectedValue.id, {timeout: 1000}).
invoke(expectedValue.functionName).
then(text => {
expect(
text.replace(/<[^>]*>/g, ''),
).to.equal(
expectedValue.value.replace(/<[^>]*>/g, ''),
);
});
}
});
}
});

Expand Down
Loading

0 comments on commit b9cac05

Please sign in to comment.