Fix channels in shipping (#1936)

* fix channels in shipping

* merge

* fix run tests

* fix run critical

* fix base url
This commit is contained in:
Karolina Rakoczy 2022-04-11 10:20:26 +02:00 committed by GitHub
parent 6358ee0b89
commit f78b4472b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 43 deletions

View file

@ -7,6 +7,8 @@ jobs:
deploy:
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
runs-on: ubuntu-latest
outputs:
base_URL: ${{ steps.set-domain.outputs.domain }}
steps:
- uses: actions/checkout@v2
@ -129,10 +131,6 @@ jobs:
fallback_uri: ${{ secrets.CYPRESS_API_URI }}
run: |
echo "::set-output name=custom_api_uri::$(echo $pull_request_body | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1 | { read custom_uri; if [ -z "$custom_uri" ]; then echo "$fallback_uri"; else echo "$custom_uri"; fi })"
- name: Get base_URL
id: base_URL
run: |
echo "::set-output name=base_URL::https://$(echo ${GITHUB_HEAD_REF}).dashboard.saleor.rocks"
- name: Setup Node
uses: actions/setup-node@v1
with:
@ -159,14 +157,14 @@ jobs:
env:
API_URI: ${{ steps.api_uri.outputs.custom_api_uri }}
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: ${{ steps.base_URL.outputs.base_URL }}
CYPRESS_baseUrl: https://${{needs.deploy.outputs.base_URL}}
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
command: npm run cy:run:critical
wait-on: ${{ steps.base_URL.outputs.base_URL }}
- uses: actions/upload-artifact@v1
with:
name: cypress-videos

View file

@ -14,8 +14,7 @@ import {
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
import filterTests from "../../../support/filterTests";
import { getCurrencyAndAmountInString } from "../../../support/formatData/formatCurrencyAmount";
import { enterHomePageChangeChannelAndReturn } from "../../../support/pages/channelsPage";
import { selectChannelInHeader } from "../../../support/pages/channelsPage";
import {
enterAndSelectShippings,
enterShippingZone
@ -25,22 +24,11 @@ filterTests({ definedTags: ["all"] }, () => {
describe("As a staff user I want have different shipping method prices for each channel", () => {
const startsWith = "ChannelShippingMethod";
let defaultChannel;
let plAddress;
before(() => {
cy.clearSessionData().loginUserViaRequest();
shippingUtils.deleteShippingStartsWith(startsWith);
channelsUtils.deleteChannelsStartsWith(startsWith);
channelsUtils
.getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
})
.then(addresses => {
plAddress = addresses.plAddress;
});
});
it("should be able to display different price for each channel. TC: SALEOR_0805", () => {
@ -54,26 +42,26 @@ filterTests({ definedTags: ["all"] }, () => {
let createdChannel;
cy.clearSessionData().loginUserViaRequest();
createChannel({
name: shippingName,
currencyCode: createdChannelCurrency
})
.then(channel => {
}).then(channel => {
createdChannel = channel;
shippingUtils.createShipping({
channelId: defaultChannel.id,
name: shippingName,
address: plAddress,
price: defaultChannelPrice
});
})
shippingUtils
.createShippingWithDefaultChannel(shippingName, defaultChannelPrice)
.then(
({
shippingMethod: shippingMethodResp,
shippingZone: shippingZoneResp
shippingZone: shippingZoneResp,
defaultChannel: defaultChannelResp
}) => {
shippingZone = shippingZoneResp;
shippingMethod = shippingMethodResp;
defaultChannel = defaultChannelResp;
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
() => {
addChannelToShippingMethod(
@ -91,7 +79,7 @@ filterTests({ definedTags: ["all"] }, () => {
ONE_PERMISSION_USERS.shipping
);
enterAndSelectShippings(shippingZone.id, enterShippingZone);
enterHomePageChangeChannelAndReturn(defaultChannel.name);
selectChannelInHeader(defaultChannel.name);
cy.waitForProgressBarToNotBeVisible()
.get(SHARED_ELEMENTS.skeleton)
.should("not.exist")
@ -99,13 +87,14 @@ filterTests({ definedTags: ["all"] }, () => {
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
)
.then(text => {
const expectedValue = getCurrencyAndAmountInString(
defaultChannelPrice,
defaultChannel.currencyCode
);
expect(text).to.eq(expectedValue);
enterHomePageChangeChannelAndReturn(createdChannel.name);
const value = defaultChannelPrice
.toFixed(2)
.toString()
.split(".");
const valueRegex = new RegExp(value.join("(.|,)"));
expect(text).to.match(valueRegex);
expect(text).to.includes(defaultChannel.currencyCode);
selectChannelInHeader(createdChannel.name);
cy.waitForProgressBarToNotBeVisible()
.get(SHARED_ELEMENTS.skeleton)
.should("not.exist");
@ -116,11 +105,13 @@ filterTests({ definedTags: ["all"] }, () => {
);
})
.then(text => {
const expectedValue = getCurrencyAndAmountInString(
createdChannelPrice,
createdChannelCurrency
);
expect(text).to.be.eq(expectedValue);
const value = createdChannelPrice
.toFixed(2)
.toString()
.split(".");
const valueRegex = new RegExp(value.join("(.|,)"));
expect(text).to.match(valueRegex);
expect(text).to.includes(createdChannelCurrency);
});
});
});

View file

@ -82,3 +82,26 @@ export function deleteShippingStartsWith(startsWith) {
startsWith
);
}
export function createShippingWithDefaultChannel(name, price) {
let defaultChannel;
return getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
})
.then(addresses => {
createShipping({
channelId: defaultChannel.id,
name,
address: addresses.usAddress,
price
});
})
.then(({ shippingMethod, shippingZone }) => ({
shippingMethod,
shippingZone,
defaultChannel
}));
}