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

feat(admin): add batch updating #157

Merged
merged 60 commits into from
Jun 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cdf22ad
fix(admin): fix error with strapi v4.8
layaxx Mar 18, 2023
71b60a3
Merge pull request #143 from Fekide/142-bug-cannot-read-properties-of…
sargreal Mar 19, 2023
62e8a25
chore(release): 1.0.1 [skip ci]
semantic-release-bot Mar 19, 2023
c313e27
chore(release): 1.1.2 [skip ci]
semantic-release-bot Mar 19, 2023
c556d3c
chore(release): 1.1.2 [skip ci]
semantic-release-bot Mar 19, 2023
f0249a1
Merge branch 'main' into next
layaxx Mar 19, 2023
32ca027
build(deps-dev): bump multi-semantic-release from 3.0.1 to 3.0.2
dependabot[bot] Mar 20, 2023
83c26d7
Merge pull request #145 from Fekide/dependabot/npm_and_yarn/multi-sem…
sargreal Mar 20, 2023
f12262e
test(e2e): setup e2e tests using cypress
sargreal Mar 15, 2023
7c5ee48
ci(test): create default test environment variables
sargreal Mar 19, 2023
cf96db5
test(cypress): add additional tests for direct and batch translation
sargreal Mar 19, 2023
bd915e3
ci(pr): add copy of env file to pr pipeline
sargreal Mar 19, 2023
dfe4c1b
ci(test): add playground strapi build before test
sargreal Mar 19, 2023
e45aeb7
ci(e2e): move cypress tests to own e2e job
sargreal Mar 20, 2023
1095148
test(e2e): fix failing test with node 14
sargreal Mar 20, 2023
b24f692
test(e2e): add test for auto publish
sargreal Mar 20, 2023
4f107c1
test(e2e): disable ratelimit as tests are sometimes too fast
sargreal Mar 20, 2023
d3c9c9b
test(e2e): wait for server on 0.0.0.0 instead of localhost
sargreal Mar 20, 2023
ba44a12
test(e2e): wait for first uid generate command
sargreal Mar 20, 2023
d576d7e
ci(e2e): add upload action for cypress artifacts
sargreal Mar 20, 2023
d6527bb
test(e2e): fill slug field manually
sargreal Mar 20, 2023
9f95982
ci(e2e): add node version to cypress results
sargreal Mar 20, 2023
9e5246b
ci(e2e): add matrix for strapi versions
sargreal Mar 20, 2023
bf88e10
feat(admin): add batch updating
layaxx Mar 24, 2023
2bd372f
feat(batch-update): add customization options
layaxx Mar 27, 2023
c7d3267
docs(batch-update): add configuration options to README
layaxx Mar 27, 2023
2506054
feat(plugin): optionally regenerate uids after single translation
layaxx Mar 27, 2023
f44b8a4
ci(workflows): restructure workflows to be reusable and remove code d…
sargreal Apr 2, 2023
1c3b9c6
chore(e2e): load environment variables with dotenv
sargreal Apr 2, 2023
e5776b2
chore(e2e): remove unnecessary fixture file
sargreal Apr 2, 2023
edc2d0c
ci(e2e): always upload videos
sargreal Apr 2, 2023
c781446
Merge pull request #141 from Fekide/test/e2e
sargreal Apr 2, 2023
4f1f697
ci(build): fix release job dependencies
sargreal Apr 2, 2023
867d47b
build(deps): playground: remove graphql plugin
sargreal Apr 6, 2023
99a7762
test(e2e): update login command to not use login page
sargreal Apr 6, 2023
dba0ec1
chore(playground): add single type categories-page
sargreal Apr 6, 2023
0039644
test(e2e): add failing test for translating relations in components
sargreal Apr 6, 2023
9599782
fix(direct-translation): issue with translating relations in components
sargreal Apr 6, 2023
4aea538
chore(playground): remove graphql plugin from template
sargreal Apr 6, 2023
e54b751
test(e2e): fix flaky batch translation
sargreal Apr 7, 2023
bf03402
fix(relations): make default behavior translations
sargreal Apr 7, 2023
fc25bc2
ci(github-actions): add action to check files that should be identical
layaxx Apr 8, 2023
7f39047
chore(playground): fix mismatch between package.json and template
layaxx Apr 8, 2023
ce88000
docs(readme): update content
sargreal Apr 9, 2023
79c664c
Merge pull request #171 from Fekide/170-feature-development-automatic…
sargreal Apr 9, 2023
3bb91cc
Merge pull request #169 from Fekide/doc/update
sargreal Apr 9, 2023
beca6f9
Merge pull request #168 from Fekide/161-bug-when-we-use-translator-we…
sargreal Apr 9, 2023
815243a
Merge pull request #167 from Fekide/152-bug-no-correct-direct-transla…
sargreal Apr 9, 2023
ee69a88
chore(release): 1.0.2 [skip ci]
semantic-release-bot Apr 9, 2023
74658b7
chore(release): 1.1.3 [skip ci]
semantic-release-bot Apr 9, 2023
62d2744
chore(release): 1.1.3 [skip ci]
semantic-release-bot Apr 9, 2023
d692ccf
Merge branch 'next' into 109-update-translations
layaxx Apr 16, 2023
27d33f0
Merge branch 'main' into 109-update-translations
layaxx Apr 16, 2023
53baa9b
test(batch-update): add first e2e test for batch updating
layaxx Apr 16, 2023
c9ae544
fix(batch-update): fix error during updating updated-entry entity
layaxx Apr 16, 2023
1cd1d0b
feat(batch-update): group updates by content type
layaxx Apr 16, 2023
8c327e4
refactor(batch-update): change update process
layaxx Jun 2, 2023
3184891
test(batch-update): fix failing e2e test
layaxx Jun 2, 2023
01b987e
refactor(batch-update): improve layout and localization
layaxx Jun 3, 2023
31c5ebc
ci(commitlint): fix parsing of release commit
sargreal Jun 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(cypress): add additional tests for direct and batch translation
Adds two tests for direct translation and a single one for batch translation.

fix #135
sargreal committed Mar 20, 2023

Verified

This commit was signed with the committer’s verified signature.
Asphaltt Leon Hwang
commit cf96db529124e04d735e4bad0d6141ada8043de1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -135,3 +135,4 @@ build/


**/cypress/videos
**/cypress/screenshots
53 changes: 53 additions & 0 deletions playground/cypress/e2e/batch-translation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
describe('batch translation', () => {
beforeEach(() => {
cy.exec('yarn reset')
})

it('should translate all articles', () => {
cy.intercept('/translate/batch-translate').as('batchTranslateExecution')
cy.intercept('/translate/batch-translate/content-types/').as(
'batchTranslateContentTypes'
)

// Login and Navigate to Translate Page
cy.login('[email protected]', 'admin')
cy.get('nav').contains('Translate').click()

cy.wait('@batchTranslateContentTypes')

// Start batch translation

cy.get('tbody tr ')
.first()
.find('td[aria-colindex=3]')
.find('button')
.first()
.click()

// Complete dialog
cy.get('div[role=dialog]')
.contains('label', 'Locales')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.click()
cy.get('li[data-strapi-value=en]').click()
cy.get('div[role=dialog] button').filter(':contains("Translate")').click()

// Verify translation finished

cy.wait('@batchTranslateContentTypes')

cy.get('tbody tr ')
.first()
.find('td[aria-colindex=3]')
.contains('Job finished')
.should('exist')
cy.get('tbody tr ')
.first()
.find('td[aria-colindex=3]')
.contains('complete')
.should('exist')
})
})
154 changes: 154 additions & 0 deletions playground/cypress/e2e/direct-translation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
describe('direct translation', () => {
beforeEach(() => {
cy.exec('yarn reset')
})

it('single article', () => {
cy.intercept('/translate/translate').as('translateExecution')
cy.intercept('/content-manager/uid/check-availability').as('regenerateUID')

// Login and Navigate to article
cy.login('[email protected]', 'admin')
cy.get('nav').contains('Content Manager').click()
cy.contains('A bug is becoming a meme on the internet').click()

// Go to page for creating German locale
cy.contains('label', 'Locales')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.click()
cy.contains('German (de)').click()

// Translate from English
cy.contains('Translate from another locale').click()
cy.contains('button', 'Yes, fill in').click()
cy.wait('@translateExecution')

// Regenerate UID
cy.get('button[aria-label=regenerate]').click()
cy.wait('@regenerateUID')
cy.wait(100)

// Save and Publish
cy.contains('button', 'Save').click()
cy.contains('button', 'Publish').click()

// Verify
cy.contains('button', 'Unpublish').should('be.visible')
cy.contains('span', 'Sarah Baker').should('be.visible')
cy.contains('span', 'tech').should('not.exist')
})

it('category and article', () => {
cy.intercept('/translate/translate').as('translateExecution')
cy.intercept('/content-manager/uid/check-availability').as('regenerateUID')

// Login and Navigate to article
cy.login('[email protected]', 'admin')
cy.get('nav').contains('Content Manager').click()

cy.get('nav[aria-label=Content]').contains('Category').click()

cy.contains('tech').click()

// Go to page for creating German locale
cy.contains('label', 'Locales')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.click()
cy.contains('German (de)').click()

// Translate from English
cy.contains('Translate from another locale').click()
cy.contains('button', 'Yes, fill in').click()
cy.wait('@translateExecution')

// Regenerate UID
cy.get('button[aria-label=regenerate]').click()
cy.wait('@regenerateUID')
cy.wait(50)

// Save
cy.contains('button', 'Save').click()

cy.get('nav[aria-label=Content]').contains('Article').click()

cy.contains('A bug is becoming a meme on the internet').click()

// Go to page for creating German locale
cy.contains('label', 'Locales')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.click()
cy.contains('German (de)').click()

// Translate from English
cy.contains('Translate from another locale').click()
cy.contains('button', 'Yes, fill in').click()
cy.wait('@translateExecution')

// Regenerate UID
cy.get('button[aria-label=regenerate]').click()
cy.wait('@regenerateUID')
cy.wait(100)

// Save and Publish
cy.contains('button', 'Save').click()
cy.contains('button', 'Publish').click()

// Verify
cy.contains('button', 'Unpublish').should('be.visible')
cy.contains('span', 'Sarah Baker').should('be.visible')
cy.contains('span', 'tech').should('be.visible')
})

it('single type with components', () => {
cy.intercept('/translate/translate').as('translateExecution')
cy.intercept('/content-manager/uid/check-availability').as('regenerateUID')

// Login and Navigate to article
cy.login('[email protected]', 'admin')
cy.get('nav').contains('Content Manager').click()

cy.get('nav[aria-label=Content]').contains('Homepage').click()

// Go to page for creating German locale
cy.contains('label', 'Locales')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.click()
cy.contains('German (de)').click()

// Translate from English
cy.contains('Translate from another locale').click()
cy.contains('button', 'Yes, fill in').click()
cy.wait('@translateExecution')

// Save
cy.contains('button', 'Save').click()

// Verify
cy.contains('label', 'metaTitle')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id.replace('.', '\\.'))
})
.should('have.value', 'My personal Strapi blog')
cy.contains('label', 'shareImage')
.invoke('attr', 'for')
.then((id) => {
cy.get('#' + id)
})
.get('img')
.should('be.visible')
cy.contains('button', 'Save').should('be.disabled')
})
})
44 changes: 0 additions & 44 deletions playground/cypress/e2e/translate-direct.cy.js

This file was deleted.

4 changes: 2 additions & 2 deletions playground/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
// import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
require('./commands')
31 changes: 27 additions & 4 deletions playground/src/api/homepage/content-types/homepage/schema.json
Original file line number Diff line number Diff line change
@@ -5,23 +5,46 @@
"singularName": "homepage",
"pluralName": "homepages",
"displayName": "Homepage",
"name": "homepage"
"name": "homepage",
"description": ""
},
"options": {
"increments": true,
"timestamps": true
"timestamps": true,
"draftAndPublish": false
},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"seo": {
"type": "component",
"repeatable": false,
"component": "shared.seo"
"component": "shared.seo",
"pluginOptions": {
"translate": {
"translate": "translate"
},
"i18n": {
"localized": true
}
}
},
"hero": {
"type": "component",
"repeatable": false,
"component": "sections.hero",
"required": true
"required": true,
"pluginOptions": {
"translate": {
"translate": "translate"
},
"i18n": {
"localized": true
}
}
}
}
}
17 changes: 10 additions & 7 deletions playground/src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -171,14 +171,17 @@ async function importGlobal() {

async function addLocales(locales) {
return Promise.all(
locales.map((locale) =>
strapi
locales.map(async (locale) => {
const existing = await strapi
.service('plugin::i18n.locales')
.create(locale)
.catch(() =>
console.log(`Failed to create locale ${locale.code}. Already exists`)
)
)
.findByCode(locale.code)
if (!existing) {
strapi
.service('plugin::i18n.locales')
.create(locale)
.catch(() => console.log(`Failed to create locale ${locale.code}.`))
}
})
)
}