Fix test related to saving variant (#2962)
* Update test after changes in variant name behaviour * remove comment * Add data-test-id and update tests
This commit is contained in:
parent
2714ac82b6
commit
d90abd4f8b
6 changed files with 28 additions and 14 deletions
|
@ -98,13 +98,13 @@ describe("As an admin I should be able to create variant", () => {
|
||||||
getProductVariants(createdProduct.id, defaultChannel.slug);
|
getProductVariants(createdProduct.id, defaultChannel.slug);
|
||||||
})
|
})
|
||||||
.then(([variant]) => {
|
.then(([variant]) => {
|
||||||
expect(variant).to.have.property("name", attributeValues[0]);
|
expect(variant).to.have.property("name", name);
|
||||||
expect(variant).to.have.property("price", price);
|
expect(variant).to.have.property("price", price);
|
||||||
expect(variant).to.have.property("currency", "USD");
|
expect(variant).to.have.property("currency", "USD");
|
||||||
getProductVariants(createdProduct.id, newChannel.slug);
|
getProductVariants(createdProduct.id, newChannel.slug);
|
||||||
})
|
})
|
||||||
.then(([variant]) => {
|
.then(([variant]) => {
|
||||||
expect(variant).to.have.property("name", attributeValues[0]);
|
expect(variant).to.have.property("name", name);
|
||||||
expect(variant).to.have.property("price", price);
|
expect(variant).to.have.property("price", price);
|
||||||
expect(variant).to.have.property("currency", "PLN");
|
expect(variant).to.have.property("currency", "PLN");
|
||||||
});
|
});
|
||||||
|
@ -150,7 +150,7 @@ describe("As an admin I should be able to create variant", () => {
|
||||||
expect(firstVariant).to.have.property("price", variants[0].price);
|
expect(firstVariant).to.have.property("price", variants[0].price);
|
||||||
expect(firstVariant).to.have.property("name", "value");
|
expect(firstVariant).to.have.property("name", "value");
|
||||||
expect(firstVariant).to.have.property("currency", "USD");
|
expect(firstVariant).to.have.property("currency", "USD");
|
||||||
expect(secondVariant).to.have.property("name", "value2");
|
expect(secondVariant).to.have.property("name", secondVariantSku);
|
||||||
expect(secondVariant).to.have.property(
|
expect(secondVariant).to.have.property(
|
||||||
"price",
|
"price",
|
||||||
variants[1].price,
|
variants[1].price,
|
||||||
|
|
|
@ -126,6 +126,7 @@ describe("Creating variants", () => {
|
||||||
price: variants[1].price,
|
price: variants[1].price,
|
||||||
channelName: defaultChannel.name,
|
channelName: defaultChannel.name,
|
||||||
warehouseId: warehouse.id,
|
warehouseId: warehouse.id,
|
||||||
|
variantName: name,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -134,7 +135,7 @@ describe("Creating variants", () => {
|
||||||
})
|
})
|
||||||
.then(([firstVariant, secondVariant]) => {
|
.then(([firstVariant, secondVariant]) => {
|
||||||
expect(firstVariant).to.have.property("price", variants[0].price);
|
expect(firstVariant).to.have.property("price", variants[0].price);
|
||||||
expect(secondVariant).to.have.property("name", variants[1].name);
|
expect(secondVariant).to.have.property("name", name);
|
||||||
expect(secondVariant).to.have.property("price", variants[1].price);
|
expect(secondVariant).to.have.property("price", variants[1].price);
|
||||||
createWaitingForCaptureOrder({
|
createWaitingForCaptureOrder({
|
||||||
channelSlug: defaultChannel.slug,
|
channelSlug: defaultChannel.slug,
|
||||||
|
|
|
@ -107,7 +107,7 @@ describe("Updating products without sku", () => {
|
||||||
)
|
)
|
||||||
.get(SHARED_ELEMENTS.skeleton)
|
.get(SHARED_ELEMENTS.skeleton)
|
||||||
.should("not.exist")
|
.should("not.exist")
|
||||||
.get(VARIANTS_SELECTORS.skuInput)
|
.get(VARIANTS_SELECTORS.skuTextField)
|
||||||
.type(sku)
|
.type(sku)
|
||||||
.addAliasToGraphRequest("VariantUpdate")
|
.addAliasToGraphRequest("VariantUpdate")
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
@ -143,7 +143,7 @@ describe("Updating products without sku", () => {
|
||||||
)
|
)
|
||||||
.get(SHARED_ELEMENTS.skeleton)
|
.get(SHARED_ELEMENTS.skeleton)
|
||||||
.should("not.exist")
|
.should("not.exist")
|
||||||
.get(VARIANTS_SELECTORS.skuInput)
|
.get(VARIANTS_SELECTORS.skuTextField)
|
||||||
.type(sku)
|
.type(sku)
|
||||||
.addAliasToGraphRequest("VariantUpdate")
|
.addAliasToGraphRequest("VariantUpdate")
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
@ -178,9 +178,12 @@ describe("Updating products without sku", () => {
|
||||||
)
|
)
|
||||||
.get(SHARED_ELEMENTS.skeleton)
|
.get(SHARED_ELEMENTS.skeleton)
|
||||||
.should("not.exist")
|
.should("not.exist")
|
||||||
.get(VARIANTS_SELECTORS.skuInput)
|
.get(VARIANTS_SELECTORS.skuTextField)
|
||||||
|
.find("input")
|
||||||
.clear()
|
.clear()
|
||||||
.addAliasToGraphRequest("VariantUpdate")
|
.addAliasToGraphRequest("VariantUpdate")
|
||||||
|
.get(VARIANTS_SELECTORS.variantNameInput)
|
||||||
|
.type(name)
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
.click()
|
.click()
|
||||||
.waitForRequestAndCheckIfNoErrors("@VariantUpdate");
|
.waitForRequestAndCheckIfNoErrors("@VariantUpdate");
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
export const VARIANTS_SELECTORS = {
|
export const VARIANTS_SELECTORS = {
|
||||||
skuInput: "[ name='sku']",
|
variantNameInput: '[data-test-id="variant-name"]',
|
||||||
|
skuTextField: '[data-test-id="sku"]',
|
||||||
attributeOption:
|
attributeOption:
|
||||||
"[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']",
|
"[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']",
|
||||||
attributeSelector: "[data-test-id='attribute-value']",
|
attributeSelector: "[data-test-id='attribute-value']",
|
||||||
addWarehouseButton: "[data-test-id='add-warehouse']",
|
addWarehouseButton: "[data-test-id='add-warehouse']",
|
||||||
warehouseOption: "[role='menuitem']",
|
warehouseOption: "[role='menuitem']",
|
||||||
saveButton: "[data-test-id='button-bar-confirm']",
|
saveButton: "[data-test-id='button-bar-confirm']",
|
||||||
skuInputInAddVariant: "[name='sku']",
|
|
||||||
stockInput: "[data-test-id='stock-input']",
|
stockInput: "[data-test-id='stock-input']",
|
||||||
booleanAttributeCheckbox: "[name*='attribute'][type='checkbox']",
|
booleanAttributeCheckbox: "[name*='attribute'][type='checkbox']",
|
||||||
selectOption: "[data-test-id='multi-autocomplete-select-option']",
|
selectOption: "[data-test-id='multi-autocomplete-select-option']",
|
||||||
|
|
|
@ -20,6 +20,7 @@ export function createVariant({
|
||||||
price,
|
price,
|
||||||
costPrice = price,
|
costPrice = price,
|
||||||
quantity = 10,
|
quantity = 10,
|
||||||
|
variantName,
|
||||||
}) {
|
}) {
|
||||||
fillUpVariantDetails({
|
fillUpVariantDetails({
|
||||||
attributeName,
|
attributeName,
|
||||||
|
@ -29,11 +30,15 @@ export function createVariant({
|
||||||
quantity,
|
quantity,
|
||||||
costPrice,
|
costPrice,
|
||||||
price,
|
price,
|
||||||
|
variantName,
|
||||||
});
|
});
|
||||||
cy.get(VARIANTS_SELECTORS.saveButton)
|
cy.addAliasToGraphRequest("WarehouseList")
|
||||||
|
.get(VARIANTS_SELECTORS.saveButton)
|
||||||
.click()
|
.click()
|
||||||
.get(VARIANTS_SELECTORS.skuInput)
|
.wait("@WarehouseList")
|
||||||
.should("be.enabled")
|
.get(VARIANTS_SELECTORS.skuTextField)
|
||||||
|
.find("input")
|
||||||
|
.and("be.enabled")
|
||||||
.get(BUTTON_SELECTORS.back)
|
.get(BUTTON_SELECTORS.back)
|
||||||
.click()
|
.click()
|
||||||
.get(PRODUCT_DETAILS.productNameInput)
|
.get(PRODUCT_DETAILS.productNameInput)
|
||||||
|
@ -69,6 +74,7 @@ export function fillUpVariantDetails({
|
||||||
quantity,
|
quantity,
|
||||||
costPrice,
|
costPrice,
|
||||||
price,
|
price,
|
||||||
|
variantName,
|
||||||
}) {
|
}) {
|
||||||
selectAttributeWithType({ attributeType, attributeName });
|
selectAttributeWithType({ attributeType, attributeName });
|
||||||
cy.get(PRICE_LIST.priceInput)
|
cy.get(PRICE_LIST.priceInput)
|
||||||
|
@ -80,8 +86,11 @@ export function fillUpVariantDetails({
|
||||||
cy.wrap(input).type(costPrice);
|
cy.wrap(input).type(costPrice);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (variantName) {
|
||||||
|
cy.get(VARIANTS_SELECTORS.variantNameInput).type(variantName);
|
||||||
|
}
|
||||||
if (sku) {
|
if (sku) {
|
||||||
cy.get(VARIANTS_SELECTORS.skuInputInAddVariant).type(sku);
|
cy.get(VARIANTS_SELECTORS.skuTextField).type(sku);
|
||||||
}
|
}
|
||||||
if (warehouseName) {
|
if (warehouseName) {
|
||||||
cy.get(VARIANTS_SELECTORS.addWarehouseButton).click();
|
cy.get(VARIANTS_SELECTORS.addWarehouseButton).click();
|
||||||
|
@ -109,7 +118,7 @@ export function fillUpVariantAttributeAndSku({ attributeName, sku }) {
|
||||||
.contains(attributeName)
|
.contains(attributeName)
|
||||||
.click();
|
.click();
|
||||||
if (sku) {
|
if (sku) {
|
||||||
cy.get(VARIANTS_SELECTORS.skuInputInAddVariant).type(sku);
|
cy.get(VARIANTS_SELECTORS.skuTextField).type(sku);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
|
||||||
name="sku"
|
name="sku"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={data.sku}
|
value={data.sku}
|
||||||
|
data-test-id="sku"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ControlledCheckbox
|
<ControlledCheckbox
|
||||||
|
|
Loading…
Reference in a new issue