Cy create language (#11546)
* add create language test * add create language test * fix bug, move test to new folder and add type definitions * update to use culture command Co-authored-by: Jesper <jmh@umbraco.dk>
This commit is contained in:
committed by
GitHub
parent
837cef0b14
commit
ea9d6919a8
@@ -1,16 +1,38 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
context('Languages', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false);
|
||||
});
|
||||
|
||||
it('Creates language', () => {
|
||||
// Setup
|
||||
const language = 'Danish';
|
||||
const culture = 'da';
|
||||
cy.umbracoEnsureLanguageCultureNotExists(culture);
|
||||
cy.umbracoSection('settings');
|
||||
|
||||
// Enter language tree and create new language
|
||||
cy.umbracoTreeItem('settings', ['Languages']).click();
|
||||
cy.umbracoButtonByLabelKey('languages_addLanguage').click();
|
||||
cy.get('select[name="newLang"]').select(language);
|
||||
|
||||
// Save and assert success
|
||||
cy.umbracoButtonByLabelKey('buttons_save').click();
|
||||
cy.umbracoSuccessNotification().should('be.visible');
|
||||
|
||||
// Cleanup
|
||||
cy.umbracoEnsureLanguageCultureNotExists(culture);
|
||||
});
|
||||
|
||||
it('Deletes language', () => {
|
||||
// Setup
|
||||
const language1 = 'da';
|
||||
const language2 = 'en-GB';
|
||||
cy.umbracoEnsureLanguageNotExists(language1);
|
||||
cy.umbracoEnsureLanguageNotExists(language2);
|
||||
cy.umbracoEnsureLanguageCultureNotExists(language1);
|
||||
cy.umbracoEnsureLanguageCultureNotExists(language2);
|
||||
|
||||
cy.umbracoCreateLanguage(language1, true, '1');
|
||||
cy.umbracoCreateLanguage(language2, true, '1');
|
||||
cy.umbracoSection('settings');
|
||||
@@ -28,11 +50,11 @@ context('Languages', () => {
|
||||
cy.umbracoButtonByLabelKey('contentTypeEditor_yesDelete').click();
|
||||
|
||||
// Assert there is only 2 language
|
||||
cy.get('tbody > tr').should('have.length', 3);
|
||||
cy.get('tbody > tr').should('have.length', 2);
|
||||
|
||||
// Cleanup
|
||||
cy.umbracoEnsureLanguageNotExists(language1);
|
||||
cy.umbracoEnsureLanguageNotExists(language2);
|
||||
cy.umbracoEnsureLanguageCultureNotExists(language1);
|
||||
cy.umbracoEnsureLanguageCultureNotExists(language2);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,9 +57,8 @@ Cypress.Commands.add('umbracoCreateLanguage', (culture, isMandatory = false, fal
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('umbracoEnsureLanguageNotExists', (culture) => {
|
||||
Cypress.Commands.add('umbracoEnsureLanguageCultureNotExists', (culture) => {
|
||||
cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => {
|
||||
console.log('hit commands')
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: '/umbraco/backoffice/umbracoapi/language/GetAllLanguages',
|
||||
|
||||
@@ -3,3 +3,28 @@
|
||||
|
||||
// type definitions for custom commands like "createDefaultTodos"
|
||||
// <reference types="support" />
|
||||
|
||||
export {};
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable<Subject> {
|
||||
/**
|
||||
* Checks to see if the language with specified culture does not exist
|
||||
* If it does it will automatically delete it
|
||||
* @param {string} culture Culture of language to delete
|
||||
* @example cy.umbracoEnsureLanguageCultureNotExists('da-DK');
|
||||
*/
|
||||
umbracoEnsureLanguageCultureNotExists: (culture: string) => Chainable<void>;
|
||||
/**
|
||||
* Creates a language from a culture
|
||||
* @param {string} culture Culture of the language - fx "da_DK"
|
||||
* @param {boolean} isMandatory Set whether the language is mandatory or not. Defaults to false
|
||||
* @param {string} fallbackLanguageId of the language to fallback to. Defaults to 1 which is en_US
|
||||
* @example cy.umbracoCreateLanguage('da', true, '1');
|
||||
*/
|
||||
umbracoCreateLanguage: (culture: string, isMandatory: boolean, fallbackLanguageId: string) => Chainable<void>;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user