Run cypress tests on correct branch (#2196)

This commit is contained in:
Karolina Rakoczy 2022-07-28 15:05:38 +02:00 committed by GitHub
parent 437a2130eb
commit 6cd42b0ae8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 87 additions and 95 deletions

View file

@ -151,8 +151,18 @@ jobs:
# run copies of the current job in parallel
containers: [1, 2, 3, 4]
steps:
- name: Get branch
id: branch
env:
version: ${{github.event.client_payload.version}}
run: |
echo "::set-output name=ref::$(echo $version | grep -ohE "[0-9]\.[0-9]+" )"
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ steps.branch.outputs.ref }}
- name: Get formatted version
id: version

View file

@ -17,7 +17,6 @@ import {
} from "../../../support/api/utils/products/productsUtils";
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
import { isShippingAvailableInCheckout } from "../../../support/api/utils/storeFront/checkoutUtils";
import { returnValueDependsOnShopVersion } from "../../../support/formatData/dataDependingOnVersion";
import {
createRateWithPostalCode,
postalCodesOptions,
@ -66,9 +65,7 @@ describe("As a user I want to create shipping method with postal codes", () => {
})
.then(warehouseResp => {
warehouse = warehouseResp;
if (returnValueDependsOnShopVersion("3.5", true, false)) {
updateChannelWarehouses(defaultChannel.id, warehouse.id);
}
updateChannelWarehouses(defaultChannel.id, warehouse.id);
createTypeAttributeAndCategoryForProduct({ name });
})
.then(({ attribute, productType, category }) => {

View file

@ -17,7 +17,6 @@ import {
} from "../../../../support/api/utils/products/productsUtils";
import { deleteShippingStartsWith } from "../../../../support/api/utils/shippingUtils";
import { isShippingAvailableInCheckout } from "../../../../support/api/utils/storeFront/checkoutUtils";
import { returnValueDependsOnShopVersion } from "../../../../support/formatData/dataDependingOnVersion";
import {
createShippingRate,
rateOptions,
@ -59,9 +58,7 @@ describe("As a staff user I want to manage shipping weights", () => {
})
.then(warehouseResp => {
warehouse = warehouseResp;
if (returnValueDependsOnShopVersion("3.5", true, false)) {
updateChannelWarehouses(defaultChannel.id, warehouse.id);
}
updateChannelWarehouses(defaultChannel.id, warehouse.id);
createTypeAttributeAndCategoryForProduct({ name });
})
.then(({ attribute, productType, category }) => {

View file

@ -1,9 +1,8 @@
import { stringify } from "../.././formatData/formatJson";
import { returnValueDependsOnShopVersion } from "../../formatData/dataDependingOnVersion";
import {
getDataForDescriptionInVariables,
getValueWithDefault,
getVariantsListIds
getVariantsListIds,
} from "./utils/Utils";
export function getFirstProducts(first, search) {
@ -55,7 +54,7 @@ export function updateChannelInProduct({
variantsIdsToRemove = "[]",
isPublished = true,
isAvailableForPurchase = true,
visibleInListings = true
visibleInListings = true,
}) {
const mutation = `mutation{
productChannelListingUpdate(id:"${productId}",
@ -99,24 +98,24 @@ export function createProduct({
productTypeId,
categoryId,
collectionId,
description
description,
}) {
const collection = getValueWithDefault(
collectionId,
`collections:["${collectionId}"]`
`collections:["${collectionId}"]`,
);
const category = getValueWithDefault(categoryId, `category:"${categoryId}"`);
const descriptionData = getDataForDescriptionInVariables(description);
const attributeValuesLine = getValueWithDefault(
attributeValue,
`values:["${attributeValue}"]`
`values:["${attributeValue}"]`,
);
const attributes = getValueWithDefault(
attributeId,
`attributes:[{
id:"${attributeId}"
${attributeValuesLine}
}]`
}]`,
);
const mutation = `mutation createProduct${descriptionData.mutationVariables}{
productCreate(input:{
@ -156,11 +155,11 @@ export function createVariant({
trackInventory = true,
weight = 1,
attributeName = "value",
preorder
preorder,
}) {
const preorderLines = getValueWithDefault(
preorder,
`preorder:${stringify(preorder)}`
`preorder:${stringify(preorder)}`,
);
const skuLines = getValueWithDefault(sku, `sku: "${sku}"`);
@ -170,7 +169,7 @@ export function createVariant({
id:"${attributeId}"
values: ["${attributeName}"]
}]`,
"attributes:[]"
"attributes:[]",
);
const channelListings = getValueWithDefault(
@ -179,7 +178,7 @@ export function createVariant({
channelId:"${channelId}"
price:"${price}"
costPrice:"${costPrice}"
}`
}`,
);
const stocks = getValueWithDefault(
@ -187,7 +186,7 @@ export function createVariant({
`stocks:{
warehouse:"${warehouseId}"
quantity:${quantityInWarehouse}
}`
}`,
);
const mutation = `mutation{
@ -248,14 +247,11 @@ export function getVariants(variantsList) {
}
export function getVariant(id, channelSlug, auth = "auth") {
const preorder = returnValueDependsOnShopVersion(
"3.1",
`preorder{
const preorder = `preorder{
globalThreshold
globalSoldUnits
endDate
}`
);
}`;
const query = `query{
productVariant(id:"${id}" channel:"${channelSlug}"){
@ -317,11 +313,11 @@ export function deactivatePreorderOnVariant(variantId) {
export function activatePreorderOnVariant({
variantId,
threshold = 50,
endDate
endDate,
}) {
const thresholdLine = getValueWithDefault(
threshold,
`globalThreshold:${threshold}`
`globalThreshold:${threshold}`,
);
const endDateLine = getValueWithDefault(endDate, `endDate:${endDate}`);
const mutation = `mutation{

View file

@ -1,4 +1,3 @@
import { returnValueDependsOnShopVersion } from "../../formatData/dataDependingOnVersion";
import { getValueWithDefault } from "./utils/Utils";
export function createTypeProduct({
@ -8,16 +7,16 @@ export function createTypeProduct({
slug = name,
shippable = true,
kind = "NORMAL",
productAttributes = true
productAttributes = true,
}) {
const kindLines = returnValueDependsOnShopVersion("3.1", `kind: ${kind}`);
const kindLines = `kind: ${kind}`;
const productAttributesLine = getValueWithDefault(
productAttributes && attributeId,
`productAttributes: "${attributeId}"`
`productAttributes: "${attributeId}"`,
);
const variantAttributesLine = getValueWithDefault(
hasVariants && attributeId,
`variantAttributes: "${attributeId}"`
`variantAttributes: "${attributeId}"`,
);
const mutation = `mutation{
productTypeCreate(input: {
@ -78,7 +77,7 @@ export function deleteProductType(productTypeId) {
export function productAttributeAssignmentUpdate({
productTypeId,
attributeId,
variantSelection = false
variantSelection = false,
}) {
const mutation = `mutation {
productAttributeAssignmentUpdate(
@ -152,7 +151,7 @@ export function setProductTypeAsDigital(productTypeId, isDigital = true) {
export function assignAttribute(
productTypeId,
attributeId,
attributeType = "VARIANT"
attributeType = "VARIANT",
) {
const mutation = `mutation{
productAttributeAssign(productTypeId:"${productTypeId}", operations:{

View file

@ -1,4 +1,3 @@
import { returnValueDependsOnShopVersion } from "../../../formatData/dataDependingOnVersion";
import * as attributeRequest from "../../requests/Attribute";
import * as categoryRequest from "../../requests/Category";
import { createChannel } from "../../requests/Channels";
@ -10,13 +9,13 @@ import {
deleteProductType,
getProductTypes,
productAttributeAssignmentUpdate,
setProductTypeAsDigital
setProductTypeAsDigital,
} from "../../requests/ProductType";
import { deleteAttributesStartsWith } from "../attributes/attributeUtils";
import { getDefaultChannel } from "../channelsUtils";
import {
createShipping,
createShippingWithDefaultChannelAndAddress
createShippingWithDefaultChannelAndAddress,
} from "../shippingUtils";
export function createProductInChannel({
@ -36,7 +35,7 @@ export function createProductInChannel({
trackInventory = true,
weight = 1,
preorder,
sku = name
sku = name,
}) {
let product;
let variantsList;
@ -50,7 +49,7 @@ export function createProductInChannel({
isAvailableForPurchase,
visibleInListings,
collectionId,
description
description,
})
.then(productResp => {
product = productResp;
@ -64,7 +63,7 @@ export function createProductInChannel({
price,
trackInventory,
weight,
preorder
preorder,
});
})
.then(variantsResp => {
@ -76,7 +75,7 @@ export function createProductInChannel({
export function createTypeAttributeAndCategoryForProduct({
name,
attributeValues,
kind = "NORMAL"
kind = "NORMAL",
}) {
let attribute;
let productType;
@ -89,14 +88,11 @@ export function createTypeAttributeAndCategoryForProduct({
})
.then(productTypeResp => {
productType = productTypeResp;
const updateAssign = returnValueDependsOnShopVersion("3.1", true, false);
if (updateAssign) {
productAttributeAssignmentUpdate({
productTypeId: productType.id,
attributeId: attribute.id,
variantSelection: true
});
}
productAttributeAssignmentUpdate({
productTypeId: productType.id,
attributeId: attribute.id,
variantSelection: true,
});
categoryRequest.createCategory({ name });
})
.then(categoryResp => {
@ -111,12 +107,12 @@ export function deleteProductsStartsWith(startsWith) {
cy.deleteElementsStartsWith(
categoryRequest.deleteCategory,
categoryRequest.getCategories,
startsWith
startsWith,
);
cy.deleteElementsStartsWith(
productRequest.deleteProduct,
productRequest.getFirstProducts,
startsWith
startsWith,
);
}
@ -127,7 +123,7 @@ export function createNewProductWithNewDataAndDefaultChannel({
preorder,
attributeValues = ["value"],
sku = name,
productPrice = 10
productPrice = 10,
}) {
return getDefaultChannel().then(channel => {
createNewProductWithNewDataAndChannel({
@ -138,7 +134,7 @@ export function createNewProductWithNewDataAndDefaultChannel({
attributeValues,
sku,
productPrice,
defaultChannel: channel
defaultChannel: channel,
});
});
}
@ -151,7 +147,7 @@ export function createNewProductWithNewDataAndChannel({
attributeValues = ["value"],
sku = name,
productPrice = 10,
defaultChannel
defaultChannel,
}) {
let collection;
let attribute;
@ -167,7 +163,7 @@ export function createNewProductWithNewDataAndChannel({
({
attribute: attributeResp,
category: categoryResp,
productType: productTypeResp
productType: productTypeResp,
}) => {
attribute = attributeResp;
category = categoryResp;
@ -183,16 +179,16 @@ export function createNewProductWithNewDataAndChannel({
warehouseId,
price: productPrice,
preorder,
sku
sku,
});
}
},
)
.then(({ product, variantsList }) => ({
product,
variantsList,
attribute,
category,
productType
productType,
}));
}
@ -203,7 +199,7 @@ export function createProductWithShipping({
productPrice = 10,
shippingPrice = 10,
preorder,
newChannel = false
newChannel = false,
}) {
let address;
let warehouse;
@ -227,14 +223,14 @@ export function createProductWithShipping({
channelId: defaultChannel.id,
name,
address,
price: shippingPrice
price: shippingPrice,
});
})
.then(
({
warehouse: warehouseResp,
shippingZone: shippingZoneResp,
shippingMethod: shippingMethodResp
shippingMethod: shippingMethodResp,
}) => {
warehouse = warehouseResp;
shippingMethod = shippingMethodResp;
@ -246,9 +242,9 @@ export function createProductWithShipping({
preorder,
attributeValues,
sku,
defaultChannel
defaultChannel,
});
}
},
)
.then(({ variantsList, product, attribute, category, productType }) => ({
variantsList,
@ -260,7 +256,7 @@ export function createProductWithShipping({
address,
attribute,
category,
productType
productType,
}));
}
@ -274,7 +270,7 @@ export function createProductInChannelWithoutVariants({
isAvailableForPurchase = true,
visibleInListings = true,
collectionId = null,
description = null
description = null,
}) {
let product;
return productRequest
@ -284,7 +280,7 @@ export function createProductInChannelWithoutVariants({
productTypeId,
categoryId,
collectionId,
description
description,
})
.then(productResp => {
product = productResp;
@ -293,7 +289,7 @@ export function createProductInChannelWithoutVariants({
channelId,
isPublished,
isAvailableForPurchase,
visibleInListings
visibleInListings,
});
})
.then(() => product);
@ -303,7 +299,7 @@ export function addDigitalContentAndUpdateProductType(
variantId,
productTypeId,
channelId,
price = 1
price = 1,
) {
createDigitalContent(variantId);
setProductTypeAsDigital(productTypeId);
@ -312,7 +308,7 @@ export function addDigitalContentAndUpdateProductType(
export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
physicalProductName,
digitalProductName
digitalProductName,
}) {
let physicalVariants;
let digitalVariants;
@ -326,7 +322,7 @@ export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
return createProductWithShipping({
name: physicalProductName,
attributeValues: ["physical"]
attributeValues: ["physical"],
})
.then(resp => {
physicalVariants = resp.variantsList;
@ -340,7 +336,7 @@ export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
createTypeProduct({
name: digitalProductName,
shippable: false,
attributeId: attribute.id
attributeId: attribute.id,
});
})
.then(productType => {
@ -351,7 +347,7 @@ export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
categoryId: category.id,
channelId: defaultChannel.id,
name: digitalProductName,
warehouseId: warehouse.id
warehouseId: warehouse.id,
});
})
.then(({ variantsList }) => {
@ -359,7 +355,7 @@ export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
addDigitalContentAndUpdateProductType(
digitalVariants[0].id,
digitalProductType.id,
defaultChannel.id
defaultChannel.id,
);
})
.then(() => ({
@ -367,7 +363,7 @@ export function createDigitalAndPhysicalProductWithNewDataAndDefaultChannel({
physicalVariants,
shippingMethod,
defaultChannel,
address
address,
}));
}
@ -392,7 +388,7 @@ export function createNewProductWithSeveralVariants(name, variantsData) {
createShipping({
channelId: defaultChannel.id,
name,
address
address,
});
})
.then(
@ -407,15 +403,15 @@ export function createNewProductWithSeveralVariants(name, variantsData) {
createTypeAttributeAndCategoryForProduct({
name,
attributeValues
attributeValues,
});
}
},
)
.then(
({
attribute: attributeResp,
category: categoryResp,
productType: productTypeResp
productType: productTypeResp,
}) => {
attribute = attributeResp;
category = categoryResp;
@ -426,9 +422,9 @@ export function createNewProductWithSeveralVariants(name, variantsData) {
categoryId: category.id,
productTypeId: productType.id,
channelId: defaultChannel.id,
name
name,
});
}
},
)
.then(product => {
variantsData.forEach(variant => {
@ -440,7 +436,7 @@ export function createNewProductWithSeveralVariants(name, variantsData) {
attributeName: variant.name,
trackInventory: variant.trackInventory,
warehouseId: warehouse.id,
quantityInWarehouse: variant.quantityInWarehouse
quantityInWarehouse: variant.quantityInWarehouse,
})
.then(variants => {
createdVariants.push(variants[0]);
@ -452,7 +448,7 @@ export function createNewProductWithSeveralVariants(name, variantsData) {
export function createShippingProductTypeAttributeAndCategory(
name,
attributeValues
attributeValues,
) {
let warehouse;
let defaultChannel;
@ -469,6 +465,6 @@ export function createShippingProductTypeAttributeAndCategory(
productType,
category,
warehouse,
defaultChannel
defaultChannel,
}));
}

View file

@ -1,4 +1,3 @@
import { returnValueDependsOnShopVersion } from "../../formatData/dataDependingOnVersion";
import { updateChannelWarehouses } from "../requests/Channels";
import * as shippingMethodRequest from "../requests/ShippingMethod";
import * as warehouseRequest from "../requests/Warehouse";
@ -27,9 +26,7 @@ export function createShipping({
})
.then(warehouseResp => {
warehouse = warehouseResp;
if (returnValueDependsOnShopVersion("3.5", true, false)) {
updateChannelWarehouses(channelId, warehouse.id);
}
updateChannelWarehouses(channelId, warehouse.id);
shippingMethodRequest.createShippingRate({
name,
shippingZone: shippingZone.id,

16
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "saleor-dashboard",
"version": "3.4.0-dev",
"version": "3.6.0-dev",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -10091,7 +10091,7 @@
"buffer-crc32": {
"version": "0.2.13",
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
"integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=",
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
"dev": true
},
"buffer-equal-constant-time": {
@ -14970,7 +14970,7 @@
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
"dev": true
}
}
@ -15453,7 +15453,7 @@
"fd-slicer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==",
"dev": true,
"requires": {
"pend": "~1.2.0"
@ -23602,7 +23602,7 @@
"ospath": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/ospath/-/ospath-1.2.2.tgz",
"integrity": "sha1-EnZjl3Sj+O8lcvf+QoDg6kVQwHs=",
"integrity": "sha512-o6E5qJV5zkAbIDNhGSIlyOhScKXgQrSRMilfph0clDfM0nEnBOlKlH4sWDmG95BW/CvwNz0vmm7dJVtU2KlMiA==",
"dev": true
},
"p-cancelable": {
@ -24155,7 +24155,7 @@
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=",
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
"dev": true
},
"performance-now": {
@ -29949,7 +29949,7 @@
"throttleit": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz",
"integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=",
"integrity": "sha512-rkTVqu6IjfQ/6+uNuuc3sZek4CEYxTJom3IktzgdSxcZqdARuebbA/f4QmAxMQIxqq9ZLEUkSYqvuk1I6VKq4g==",
"dev": true
},
"through": {
@ -32750,7 +32750,7 @@
"yauzl": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
"dev": true,
"requires": {
"buffer-crc32": "~0.2.3",