Update tests for creating variants (#1718)

* merge

* add data-test-id to sku input

* remove data-test-id from sku input

* update stories

* remove duplicated attribute
This commit is contained in:
Karolina Rakoczy 2022-01-04 16:13:15 +01:00 committed by GitHub
parent 6e09ec9bb2
commit a01a2b5a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 30 deletions

View file

@ -3,7 +3,7 @@ export const VARIANTS_SELECTORS = {
valueContainer: "[data-test-id='value-container']",
nextButton: "[class*='MuiButton-containedPrimary']",
warehouseCheckboxes: "[name*='warehouse:']",
skuInput: "[ data-test-id='sku-input']",
skuInput: "[ name='sku']",
attributeSelector: "[data-test='attribute-value']",
attributeOption:
"[data-test-type='option'], [data-test='multiautocomplete-select-option']",

View file

@ -104,7 +104,6 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
cy.visit(`${urlList.products}${createdProduct.id}`);
createFirstVariant({
sku: name,
warehouseId: warehouse.id,
price,
attribute: attributeValues[0]
});
@ -139,7 +138,6 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
cy.visit(`${urlList.products}${createdProduct.id}`);
createVariant({
sku: secondVariantSku,
warehouseName: warehouse.name,
attributeName: variants[1].name,
price: variants[1].price,
channelName: defaultChannel.name
@ -187,7 +185,6 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
cy.visit(`${urlList.products}${createdProduct.id}`);
createFirstVariant({
sku: name,
warehouseId: warehouse.id,
price: variantsPrice,
attribute: attributeValues[0]
});

View file

@ -121,6 +121,7 @@ filterTests({ definedTags: ["all", "critical"], version: "3.1.0" }, () => {
channelId: defaultChannel.id
});
cy.visit(`${urlList.products}${createdProduct.id}`);
cy.waitForProgressBarToNotBeVisible();
createFirstVariant({
warehouseId: warehouse.id,
price,
@ -135,7 +136,7 @@ filterTests({ definedTags: ["all", "critical"], version: "3.1.0" }, () => {
channelSlug: defaultChannel.slug,
email: "example@example.com",
variantsList: [variant],
shippingMethodId: shippingMethod.id,
shippingMethodName: shippingMethod.name,
address
});
})
@ -180,7 +181,7 @@ filterTests({ definedTags: ["all", "critical"], version: "3.1.0" }, () => {
channelSlug: defaultChannel.slug,
email: "example@example.com",
variantsList: [secondVariant],
shippingMethodId: shippingMethod.id,
shippingMethodName: shippingMethod.name,
address
});
})
@ -234,7 +235,7 @@ filterTests({ definedTags: ["all", "critical"], version: "3.1.0" }, () => {
channelSlug: defaultChannel.slug,
email: "example@example.com",
variantsList: variants,
shippingMethodId: shippingMethod.id,
shippingMethodName: shippingMethod.name,
address
});
});

View file

@ -208,7 +208,6 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
.get(SHARED_ELEMENTS.skeleton)
.should("not.exist")
.get(VARIANTS_SELECTORS.skuInput)
.find("input")
.clear()
.addAliasToGraphRequest("VariantUpdate")
.get(BUTTON_SELECTORS.confirm)
@ -267,7 +266,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
address,
channelSlug: defaultChannel.slug,
email,
shippingMethodId: shippingMethod.id,
shippingMethodName: shippingMethod.name,
variantsList: [variant]
}).then(({ order }) => {
expect(order.id).to.be.ok;

View file

@ -30,9 +30,14 @@ export function createFirstVariant({
.get(VARIANTS_SELECTORS.nextButton)
.click();
fillUpPriceList(price);
cy.get(`[name*='${warehouseId}']`)
.click()
.get(VARIANTS_SELECTORS.stockInput)
if (warehouseId) {
cy.get(`[name*='${warehouseId}']`).click();
} else {
cy.get(VARIANTS_SELECTORS.warehouseCheckboxes)
.first()
.click();
}
cy.get(VARIANTS_SELECTORS.stockInput)
.type(quantity)
.get(VARIANTS_SELECTORS.nextButton)
.click();
@ -80,9 +85,15 @@ export function fillUpGeneralVariantInputs({
}) {
fillUpVariantAttributeAndSku({ attributeName, sku });
cy.get(VARIANTS_SELECTORS.addWarehouseButton).click();
cy.contains(VARIANTS_SELECTORS.warehouseOption, warehouseName).click({
force: true
});
if (warehouseName) {
cy.contains(VARIANTS_SELECTORS.warehouseOption, warehouseName).click({
force: true
});
} else {
cy.get(VARIANTS_SELECTORS.warehouseOption)
.first()
.click({ force: true });
}
cy.get(VARIANTS_SELECTORS.stockInput).type(quantity);
}

View file

@ -225,7 +225,6 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
<CardContent>
<div className={classes.skuInputContainer}>
<TextField
data-test-id="sku-input"
disabled={disabled}
error={!!formErrors.sku}
fullWidth

View file

@ -183700,7 +183700,6 @@ exports[`Storyshots Views / Products / Create product variant add first variant
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id"
@ -184759,7 +184758,6 @@ exports[`Storyshots Views / Products / Create product variant default 1`] = `
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id"
@ -185818,7 +185816,6 @@ exports[`Storyshots Views / Products / Create product variant no warehouses 1`]
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id"
@ -186616,7 +186613,6 @@ exports[`Storyshots Views / Products / Create product variant when loading data
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id"
@ -187685,7 +187681,6 @@ exports[`Storyshots Views / Products / Create product variant with errors 1`] =
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id MuiFormLabel-error-id MuiInputLabel-error-id"
@ -195386,7 +195381,6 @@ exports[`Storyshots Views / Products / Product edit no stock and no variants 1`]
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -196967,7 +196961,6 @@ exports[`Storyshots Views / Products / Product edit no stock, no variants and no
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -198548,7 +198541,6 @@ exports[`Storyshots Views / Products / Product edit no variants 1`] = `
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -201505,7 +201497,6 @@ exports[`Storyshots Views / Products / Product edit when loading data 1`] = `
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id"
@ -204522,7 +204513,6 @@ exports[`Storyshots Views / Products / Product edit when product has no variants
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -222332,7 +222322,6 @@ exports[`Storyshots Views / Products / Product variant details attribute errors
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-error-id MuiInputLabel-error-id MuiFormLabel-filled-id"
@ -224281,7 +224270,6 @@ exports[`Storyshots Views / Products / Product variant details no warehouses 1`]
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -226225,7 +226213,6 @@ exports[`Storyshots Views / Products / Product variant details when loaded data
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-filled-id"
@ -227397,7 +227384,6 @@ exports[`Storyshots Views / Products / Product variant details when loading data
>
<div
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
data-test-id="sku-input"
>
<label
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id"