fix for translation tests (#2306)

* fix for flaky chane user email tests and refactor of plugins tests

* fix for translation tests

* adding an option to run plugin tests in pull_request_temple

* adding an option to run translation tests
This commit is contained in:
Ewa Czerniak 2022-09-15 08:28:46 +00:00 committed by GitHub
parent 81319a67a6
commit 7a469029fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 41 deletions

View file

@ -49,5 +49,6 @@ Tests will be re-run only when the "run e2e" label is added.
17. [ ] products 17. [ ] products
18. [ ] app 18. [ ] app
19. [ ] plugins 19. [ ] plugins
20. [ ] translations
CONTAINERS=1 CONTAINERS=1

View file

@ -11,7 +11,7 @@ import {
import { deleteCategoriesStartsWith } from "../support/api/utils/catalog/categoryUtils"; import { deleteCategoriesStartsWith } from "../support/api/utils/catalog/categoryUtils";
import { updateTranslationToCategory } from "../support/pages/translationsPage"; import { updateTranslationToCategory } from "../support/pages/translationsPage";
xdescribe("As an admin I want to manage translations", () => { describe("As an admin I want to manage translations", () => {
const startsWith = "TestTranslations"; const startsWith = "TestTranslations";
const randomNumber = faker.datatype.number(); const randomNumber = faker.datatype.number();
@ -31,7 +31,7 @@ xdescribe("As an admin I want to manage translations", () => {
it( it(
"should be able to create new translation. TC:SALEOR_1701", "should be able to create new translation. TC:SALEOR_1701",
{ tags: ["@translations", "@stagedOnly"] }, { tags: ["@translations", "@stagedOnly", "@stable"] },
() => { () => {
const translatedName = `TranslatedName${randomNumber}`; const translatedName = `TranslatedName${randomNumber}`;
const translatedDescription = `TranslatedDescription${randomNumber}`; const translatedDescription = `TranslatedDescription${randomNumber}`;
@ -45,24 +45,20 @@ xdescribe("As an admin I want to manage translations", () => {
translatedSeoTitle, translatedSeoTitle,
translatedSeoDescription, translatedSeoDescription,
}); });
getCategory(category.id, "PL").then(({ translation }) => { getCategory(category.id, "PL")
expect(translation.name).to.eq(`TranslatedName${randomNumber}`); .its("translation")
expect(translation.description).to.includes( .should("include", { name: `${translatedName}` })
`TranslatedDescription${randomNumber}`, .and("include", { seoDescription: `${translatedSeoDescription}` })
); .and("include", { seoTitle: `${translatedSeoTitle}` })
expect(translation.seoTitle).to.eq(`TranslatedSeoTitle${randomNumber}`); .its("description")
expect(translation.seoDescription).to.eq( .should("have.string", `{"text": "${translatedDescription}"}`);
`TranslatedSeoDescription${randomNumber}`,
);
});
}, },
); );
it( it(
"should be able to update translation. TC:SALEOR_1702", "should be able to update translation. TC:SALEOR_1702",
{ tags: ["@translations", "@stagedOnly"] }, { tags: ["@translations", "@stagedOnly", "@stable"] },
() => { () => {
const randomNumber = faker.datatype.number();
const startWithUpdate = `Translations_Update_${randomNumber}`; const startWithUpdate = `Translations_Update_${randomNumber}`;
const seoTitleUpdate = `${startWithUpdate}_seoTitle`; const seoTitleUpdate = `${startWithUpdate}_seoTitle`;
const seoDescriptionUpdate = `${startWithUpdate}_seoDescription`; const seoDescriptionUpdate = `${startWithUpdate}_seoDescription`;
@ -76,8 +72,7 @@ xdescribe("As an admin I want to manage translations", () => {
seoDescription: "test", seoDescription: "test",
name: "test", name: "test",
description: "test", description: "test",
}) }).then(() => {
.then(() => {
updateTranslationToCategory({ updateTranslationToCategory({
categoryName: category.name, categoryName: category.name,
translatedName: nameUpdate, translatedName: nameUpdate,
@ -85,13 +80,13 @@ xdescribe("As an admin I want to manage translations", () => {
translatedSeoTitle: seoTitleUpdate, translatedSeoTitle: seoTitleUpdate,
translatedSeoDescription: seoDescriptionUpdate, translatedSeoDescription: seoDescriptionUpdate,
}); });
getCategory(category.id, "PL"); getCategory(category.id, "PL")
}) .its("translation")
.then(({ translation }) => { .should("include", { name: `${nameUpdate}` })
expect(translation.name).to.eq(nameUpdate); .and("include", { seoDescription: `${seoDescriptionUpdate}` })
expect(translation.description).to.includes(descriptionUpdate); .and("include", { seoTitle: `${seoTitleUpdate}` })
expect(translation.seoTitle).to.eq(seoTitleUpdate); .its("description")
expect(translation.seoDescription).to.includes(seoDescriptionUpdate); .should("have.string", `{"text": "${descriptionUpdate}"}`);
}); });
}, },
); );

View file

@ -9,7 +9,7 @@ export function updateTranslationToCategory({
translatedName, translatedName,
translatedDescription, translatedDescription,
translatedSeoTitle, translatedSeoTitle,
translatedSeoDescription translatedSeoDescription,
}) { }) {
cy.visit(urlList.translations); cy.visit(urlList.translations);
enterCategoryTranslation(LANGUAGES_LIST.polishLanguageButton, categoryName); enterCategoryTranslation(LANGUAGES_LIST.polishLanguageButton, categoryName);
@ -28,7 +28,6 @@ export function updateTranslationToCategory({
.should("not.exist") .should("not.exist")
.get(ELEMENT_TRANSLATION.translationTextEditor) .get(ELEMENT_TRANSLATION.translationTextEditor)
.clearAndType(translatedDescription) .clearAndType(translatedDescription)
.wait(500)
.get(BUTTON_SELECTORS.confirm) .get(BUTTON_SELECTORS.confirm)
.click() .click()
.confirmationMessageShouldDisappear() .confirmationMessageShouldDisappear()
@ -50,23 +49,22 @@ export function updateTranslationToCategory({
export function enterCategoryTranslation(language, categoryName) { export function enterCategoryTranslation(language, categoryName) {
cy.addAliasToGraphRequest("CategoryTranslations"); cy.addAliasToGraphRequest("CategoryTranslations");
cy.get(language).click(); cy.get(language)
.click()
.waitForProgressBarToNotExist();
getCategoryFromTable(categoryName); getCategoryFromTable(categoryName);
} }
function getCategoryFromTable(categoryName) { function getCategoryFromTable(categoryName) {
cy.wait("@CategoryTranslations") cy.wait("@CategoryTranslations")
.its("response.body") .its("response.body.data.translations.edges")
.then(bodies => { .then(edges => {
const body = bodies[0];
const edges = body.data.translations.edges;
const isCategoryInResp = edges.find( const isCategoryInResp = edges.find(
edge => edge.node.category.name === categoryName edge => edge.node.category.name === categoryName,
); );
if (isCategoryInResp) { if (isCategoryInResp) {
cy.contains(SHARED_ELEMENTS.tableRow, categoryName).click({ cy.contains(SHARED_ELEMENTS.tableRow, categoryName).click();
force: true
});
} else { } else {
cy.get(BUTTON_SELECTORS.nextPaginationButton).click(); cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
getCategoryFromTable(categoryName); getCategoryFromTable(categoryName);