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

add update language test #11333

Closed
wants to merge 1 commit into from
Closed

Conversation

jemayn
Copy link
Contributor

@jemayn jemayn commented Oct 8, 2021

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes

Description

I have the same question as I wrote in #11307, what am I supposed to do if I need new cypress commands that aren't in the package? It makes sense to me to just add them to the commands file and you can then transfer the ones in the into the package whenever you want to make a new release of it?

I also wrote some ts definitions of the 2 methods, but the chainable.ts file seems to be gitignored so not sure of the procedure there?

Leaving them here to remember:

/**
 * Checks to see if the language with specified name does not exist
 * If it does it will automatically delete it
 * @param  {string} name Name of language to delete
 * @example cy.umbracoEnsureLanguageNotExists('Danish');
 */
umbracoEnsureLanguageNotExists: (name: 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>;

Anyways, this test does the following:

  • Creates a new language through the backoffice api - culture: da, mandatory with fallback to english
  • Navigates to that language through the ui
  • Untoggles mandatory through ui
  • Unselects a fallback language through ui
  • Saves and verifies it saves
  • Deletes the language again

@jemayn jemayn mentioned this pull request Oct 8, 2021
7 tasks
@umbrabot
Copy link

umbrabot commented Oct 8, 2021

Hi there @jemayn, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things that needs updating, but stellar job on all of the cypress tests 💪

Comment on lines +34 to +59
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;
});
});
});
Copy link
Member

@Zeegaan Zeegaan Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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('umbracoCreateLanguage', (culture, isMandatory = false, fallbackLanguageId = 1) => {
var langData =
{
"culture": culture,
"isMandatory": isMandatory,
"fallbackLanguageId": fallbackLanguageId
};
// Create language through API
let url = '/umbraco/backoffice/umbracoapi/language/SaveLanguage';
cy.umbracoApiRequest(url, 'POST', langData);
});

Should probably use cy.umbracoApiRequest instead of manually calling the API

}
});
});
});
Copy link
Member

@Zeegaan Zeegaan Oct 27, 2021

Choose a reason for hiding this comment

The 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 🙈 )

@elit0451
Copy link
Member

elit0451 commented Nov 4, 2021

Just FYI: The just merged PR #11527 moves the languages.ts to the tests folder, instead of src. 🙂

@jemayn
Copy link
Contributor Author

jemayn commented Nov 4, 2021

I will update this PR after #11546 has gone through review - few questions in that one about where to place custom commands and their TS definitions, which will also be relevant in this one 🙂

Will make sure to update the path to the new location.

@nathanwoulfe
Copy link
Contributor

Hey @jemayn if you have time to come back to this one and make the changes, I'll happily merge it 😄

@jemayn
Copy link
Contributor Author

jemayn commented Feb 23, 2022

@nathanwoulfe Sorry had forgotten all about this again! Will write a reminder for when I have a spare evening to get it finished! 🙂

@nathanwoulfe
Copy link
Contributor

All good @jemayn, I'm happy to push the buttons when it's ready to go

@nul800sebastiaan
Copy link
Member

We've since moved away from cypress to playwright so this never came to fruition. I am not sure if these tests are now in playwright but maybe you'd like to try again for playwright? 😁 Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants