Fix channels in shipping (#1936)
* fix channels in shipping * merge * fix run tests * fix run critical * fix base url
This commit is contained in:
parent
6358ee0b89
commit
f78b4472b7
3 changed files with 55 additions and 43 deletions
10
.github/workflows/test-env-deploy.yml
vendored
10
.github/workflows/test-env-deploy.yml
vendored
|
@ -7,6 +7,8 @@ jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
|
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
base_URL: ${{ steps.set-domain.outputs.domain }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
@ -129,10 +131,6 @@ jobs:
|
||||||
fallback_uri: ${{ secrets.CYPRESS_API_URI }}
|
fallback_uri: ${{ secrets.CYPRESS_API_URI }}
|
||||||
run: |
|
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 })"
|
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
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
|
@ -159,14 +157,14 @@ jobs:
|
||||||
env:
|
env:
|
||||||
API_URI: ${{ steps.api_uri.outputs.custom_api_uri }}
|
API_URI: ${{ steps.api_uri.outputs.custom_api_uri }}
|
||||||
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_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_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
|
||||||
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
|
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
|
||||||
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
|
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
|
||||||
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
||||||
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
with:
|
with:
|
||||||
command: npm run cy:run:critical
|
command: npm run cy:run:critical
|
||||||
wait-on: ${{ steps.base_URL.outputs.base_URL }}
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: cypress-videos
|
name: cypress-videos
|
||||||
|
|
|
@ -14,8 +14,7 @@ import {
|
||||||
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
|
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
|
||||||
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
|
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
|
||||||
import filterTests from "../../../support/filterTests";
|
import filterTests from "../../../support/filterTests";
|
||||||
import { getCurrencyAndAmountInString } from "../../../support/formatData/formatCurrencyAmount";
|
import { selectChannelInHeader } from "../../../support/pages/channelsPage";
|
||||||
import { enterHomePageChangeChannelAndReturn } from "../../../support/pages/channelsPage";
|
|
||||||
import {
|
import {
|
||||||
enterAndSelectShippings,
|
enterAndSelectShippings,
|
||||||
enterShippingZone
|
enterShippingZone
|
||||||
|
@ -25,22 +24,11 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
describe("As a staff user I want have different shipping method prices for each channel", () => {
|
describe("As a staff user I want have different shipping method prices for each channel", () => {
|
||||||
const startsWith = "ChannelShippingMethod";
|
const startsWith = "ChannelShippingMethod";
|
||||||
let defaultChannel;
|
let defaultChannel;
|
||||||
let plAddress;
|
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
shippingUtils.deleteShippingStartsWith(startsWith);
|
shippingUtils.deleteShippingStartsWith(startsWith);
|
||||||
channelsUtils.deleteChannelsStartsWith(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", () => {
|
it("should be able to display different price for each channel. TC: SALEOR_0805", () => {
|
||||||
|
@ -54,26 +42,26 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
let createdChannel;
|
let createdChannel;
|
||||||
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
|
||||||
createChannel({
|
createChannel({
|
||||||
name: shippingName,
|
name: shippingName,
|
||||||
currencyCode: createdChannelCurrency
|
currencyCode: createdChannelCurrency
|
||||||
})
|
}).then(channel => {
|
||||||
.then(channel => {
|
createdChannel = channel;
|
||||||
createdChannel = channel;
|
});
|
||||||
shippingUtils.createShipping({
|
|
||||||
channelId: defaultChannel.id,
|
shippingUtils
|
||||||
name: shippingName,
|
.createShippingWithDefaultChannel(shippingName, defaultChannelPrice)
|
||||||
address: plAddress,
|
|
||||||
price: defaultChannelPrice
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
shippingMethod: shippingMethodResp,
|
shippingMethod: shippingMethodResp,
|
||||||
shippingZone: shippingZoneResp
|
shippingZone: shippingZoneResp,
|
||||||
|
defaultChannel: defaultChannelResp
|
||||||
}) => {
|
}) => {
|
||||||
shippingZone = shippingZoneResp;
|
shippingZone = shippingZoneResp;
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
|
defaultChannel = defaultChannelResp;
|
||||||
|
|
||||||
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
|
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
|
||||||
() => {
|
() => {
|
||||||
addChannelToShippingMethod(
|
addChannelToShippingMethod(
|
||||||
|
@ -91,7 +79,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
ONE_PERMISSION_USERS.shipping
|
ONE_PERMISSION_USERS.shipping
|
||||||
);
|
);
|
||||||
enterAndSelectShippings(shippingZone.id, enterShippingZone);
|
enterAndSelectShippings(shippingZone.id, enterShippingZone);
|
||||||
enterHomePageChangeChannelAndReturn(defaultChannel.name);
|
selectChannelInHeader(defaultChannel.name);
|
||||||
cy.waitForProgressBarToNotBeVisible()
|
cy.waitForProgressBarToNotBeVisible()
|
||||||
.get(SHARED_ELEMENTS.skeleton)
|
.get(SHARED_ELEMENTS.skeleton)
|
||||||
.should("not.exist")
|
.should("not.exist")
|
||||||
|
@ -99,13 +87,14 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
||||||
)
|
)
|
||||||
.then(text => {
|
.then(text => {
|
||||||
const expectedValue = getCurrencyAndAmountInString(
|
const value = defaultChannelPrice
|
||||||
defaultChannelPrice,
|
.toFixed(2)
|
||||||
defaultChannel.currencyCode
|
.toString()
|
||||||
);
|
.split(".");
|
||||||
expect(text).to.eq(expectedValue);
|
const valueRegex = new RegExp(value.join("(.|,)"));
|
||||||
|
expect(text).to.match(valueRegex);
|
||||||
enterHomePageChangeChannelAndReturn(createdChannel.name);
|
expect(text).to.includes(defaultChannel.currencyCode);
|
||||||
|
selectChannelInHeader(createdChannel.name);
|
||||||
cy.waitForProgressBarToNotBeVisible()
|
cy.waitForProgressBarToNotBeVisible()
|
||||||
.get(SHARED_ELEMENTS.skeleton)
|
.get(SHARED_ELEMENTS.skeleton)
|
||||||
.should("not.exist");
|
.should("not.exist");
|
||||||
|
@ -116,11 +105,13 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.then(text => {
|
.then(text => {
|
||||||
const expectedValue = getCurrencyAndAmountInString(
|
const value = createdChannelPrice
|
||||||
createdChannelPrice,
|
.toFixed(2)
|
||||||
createdChannelCurrency
|
.toString()
|
||||||
);
|
.split(".");
|
||||||
expect(text).to.be.eq(expectedValue);
|
const valueRegex = new RegExp(value.join("(.|,)"));
|
||||||
|
expect(text).to.match(valueRegex);
|
||||||
|
expect(text).to.includes(createdChannelCurrency);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,3 +82,26 @@ export function deleteShippingStartsWith(startsWith) {
|
||||||
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
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue