-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
add update language test #11333
Closed
Closed
add update language test #11333
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions
31
src/Umbraco.Tests.AcceptanceTest/cypress/integration/Languages/languages.ts
This file contains 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,31 @@ | ||
/// <reference types="Cypress" /> | ||
context('Languages', () => { | ||
|
||
beforeEach(() => { | ||
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false); | ||
}); | ||
|
||
it('Updates language', () => { | ||
// Setup | ||
const language = 'Danish'; | ||
cy.umbracoEnsureLanguageNotExists(language); | ||
cy.umbracoCreateLanguage('da', true, '1'); | ||
cy.umbracoSection('settings'); | ||
|
||
// Enter language tree and select the language we just created | ||
cy.umbracoTreeItem('settings', ['Languages']).click(); | ||
cy.get('tr').contains('Danish').click(); | ||
|
||
// Edit the language | ||
cy.get('div[ng-click="vm.toggleMandatory()"]').children('button').click(); // the mandatory language toggle | ||
cy.get('select[name="fallbackLanguage"]').select('No fall back language') | ||
|
||
// Save and assert success | ||
cy.umbracoButtonByLabelKey('buttons_save').click(); | ||
cy.umbracoSuccessNotification().should('be.visible'); | ||
|
||
// Cleanup | ||
cy.umbracoEnsureLanguageNotExists(language); | ||
}); | ||
|
||
}); |
This file contains 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 |
---|---|---|
|
@@ -26,5 +26,73 @@ | |
|
||
import {Command} from 'umbraco-cypress-testhelpers'; | ||
import {Chainable} from './chainable'; | ||
import { JsonHelper } from 'umbraco-cypress-testhelpers'; | ||
|
||
new Chainable(); | ||
new Command().registerCypressCommands(); | ||
|
||
Cypress.Commands.add('umbracoCreateLanguage', (culture, isMandatory = false, fallbackLanguageId = 1) => { | ||
|
||
var langData = | ||
{ | ||
"culture": culture, | ||
"isMandatory": isMandatory, | ||
"fallbackLanguageId": fallbackLanguageId | ||
}; | ||
|
||
// Create language through API | ||
cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/umbraco/backoffice/umbracoapi/language/SaveLanguage', | ||
followRedirect: true, | ||
headers: { | ||
Accept: 'application/json', | ||
'X-UMB-XSRF-TOKEN': token.value, | ||
}, | ||
body: langData, | ||
log: false, | ||
}).then((response) => { | ||
return; | ||
}); | ||
}); | ||
}); | ||
|
||
Cypress.Commands.add('umbracoEnsureLanguageNotExists', (name) => { | ||
cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/umbraco/backoffice/umbracoapi/language/GetAllLanguages', | ||
followRedirect: true, | ||
headers: { | ||
Accept: 'application/json', | ||
'X-UMB-XSRF-TOKEN': token.value, | ||
}, | ||
log: false, | ||
}).then((response) => { | ||
const searchBody = JsonHelper.getBody(response); | ||
if (searchBody.length > 0) { | ||
let languageId = null; | ||
for (const sb of searchBody) { | ||
if (sb.name === name) { | ||
languageId = sb.id; | ||
} | ||
} | ||
|
||
if (languageId !== null) { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/umbraco/backoffice/umbracoapi/language/DeleteLanguage?id=' + languageId, | ||
followRedirect: false, | ||
headers: { | ||
ContentType: 'application/json', | ||
'X-UMB-XSRF-TOKEN': token.value, | ||
}, | ||
}).then((resp) => { | ||
return; | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have already have a helper function that does this! its called umbracoEnsureLanguageNameNotExists (i just make that a few weeks ago for my system information tests 🙈 ) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use cy.umbracoApiRequest instead of manually calling the API