Fixed tests for creating and updating page (#2273)

This commit is contained in:
Karolina Rakoczy 2022-09-02 10:07:43 +02:00 committed by GitHub
parent d13cf7d06d
commit c236d5346a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View file

@ -154,12 +154,13 @@ describe("Tests for pages", () => {
createPageRequest({
pageTypeId: pageType.id,
title: randomName,
isPublished: true,
})
.then(({ page }) => {
cy.visit(pageDetailsUrl(page.id))
.get(PAGE_DETAILS.nameInput)
.clearAndType(updatedName)
.get(PAGE_DETAILS.isPublishedCheckbox)
.get(PAGE_DETAILS.isNotPublishedCheckbox)
.click()
.addAliasToGraphRequest("PageUpdate")
.get(BUTTON_SELECTORS.confirm)
@ -169,7 +170,7 @@ describe("Tests for pages", () => {
})
.then(page => {
expect(page.title).to.eq(updatedName);
expect(page.isPublished).to.eq(true);
expect(page.isPublished).to.eq(false);
});
});
});

View file

@ -3,9 +3,9 @@ export const PAGE_DETAILS = {
pageTypesAutocompleteSelect:
'[data-test-id="page-types-autocomplete-select"]',
attributeValues: '[data-test-id="attribute-value"]',
isPublishedCheckbox: '[name="isPublished"][value=true]',
isNotPublishedCheckbox: '[name="isPublished"][value=false]',
uploadFileButton: '[data-test-id="button-upload-file"]',
richTextEditorAttributeValue: '[class*="ce-paragraph"]',
booleanAttributeValueCheckbox: '[name*="attribute:"][type="checkbox"]',
numericAttributeValueInput: '[name*="attribute:"]'
numericAttributeValueInput: '[name*="attribute:"]',
};

View file

@ -18,9 +18,10 @@ export function getPage(pageId, auth = "auth") {
return cy.sendRequestWithQuery(query, auth).its("body.data.page");
}
export function createPage({ title, pageTypeId }) {
export function createPage({ title, pageTypeId, isPublished = false }) {
const mutation = `mutation{
pageCreate(input:{
isPublished: ${isPublished}
title:"${title}"
pageType:"${pageTypeId}"
}){

View file

@ -9,14 +9,14 @@ export const attributesTypes = {
MULTISELECT: addSelectAttributeValue,
RICH_TEXT: addRichTextAttributeValue,
BOOLEAN: addBooleanAttributeValue,
NUMERIC: addNumericAttributeValue
NUMERIC: addNumericAttributeValue,
};
export function createPage({
pageName,
pageTypeName,
isPublished = false,
attributeType = "DROPDOWN",
attributeValue
attributeValue,
}) {
openCreatePageAndFillUpGeneralFields({ pageName, pageTypeName, isPublished });
attributesTypes[attributeType](attributeValue);
@ -48,19 +48,19 @@ export function addNumericAttributeValue(attributeValue) {
function openCreatePageAndFillUpGeneralFields({
pageName,
pageTypeName,
isPublished
isPublished,
}) {
cy.visit(urlList.pages)
.get(PAGES_LIST.createPageButton)
.click()
.get(PAGE_DETAILS.nameInput)
.type(pageName);
if (isPublished) {
cy.get(PAGE_DETAILS.isPublishedCheckbox).click();
if (!isPublished) {
cy.get(PAGE_DETAILS.isNotPublishedCheckbox).click();
}
cy.fillAutocompleteSelect(
PAGE_DETAILS.pageTypesAutocompleteSelect,
pageTypeName
pageTypeName,
);
}