fix failing tests (#1200)

* fix failing tests

* skip test for variant

* skip failing test

* uncomment tests for fixed bugs

* fix test.yaml
This commit is contained in:
Karolina Rakoczy 2021-07-05 15:05:13 +02:00 committed by GitHub
parent b22831ba25
commit 12e9cf0472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 17 deletions

View file

@ -87,7 +87,6 @@ jobs:
echo "::set-output name=custom_api_uri::$(echo $pull_request_body | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1)"
- name: Cypress run
if: ${{ steps.api_uri.outputs.custom_api_uri}} != 'https://qa.staging.saleor.cloud/graphql/'
uses: cypress-io/github-action@v2
env:
API_URI: ${{ steps.api_uri.outputs.custom_api_uri || secrets.API_URI }}
@ -103,8 +102,30 @@ jobs:
wait-on: http://localhost:9000/
wait-on-timeout: 120
spec: cypress/integration/allEnv/**/*.js
- uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-videos
path: cypress/videos
- name: Cypress run
cypress-run-staged:
if: github.event.pull_request.head.repo.full_name == 'mirumee/saleor-dashboard'
runs-on: ubuntu-16.04
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get custom API_URI
id: api_uri
# Search for API_URI in PR description
env:
pull_request_body: ${{ github.event.pull_request.body }}
prefix: API_URI=
pattern: (http|https)://[a-zA-Z0-9.-]+/graphql/?
run: |
echo "::set-output name=custom_api_uri::$(echo $pull_request_body | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1)"
- name: Cypress run staged only
if: ${{ steps.api_uri.outputs.custom_api_uri}} == 'https://qa.staging.saleor.cloud/graphql/'
uses: cypress-io/github-action@v2
env:
@ -121,6 +142,7 @@ jobs:
start: npx local-web-server --spa index.html
wait-on: http://localhost:9000/
wait-on-timeout: 120
spec: cypress/integration/stagedOnly/**/*.js
- uses: actions/upload-artifact@v1
if: always()
with:

View file

@ -26,7 +26,7 @@ export function getOrdersWithStatus(status, channelSlug) {
}
export function getProductsOutOfStock(channelSlug) {
const query = `query{
products(filter: { stockAvailability: OUT_OF_STOCK, channel:"${channelSlug}" }){
products(filter: { stockAvailability: OUT_OF_STOCK} channel:"${channelSlug}" ){
totalCount
}
}`;

View file

@ -25,7 +25,15 @@ export const PRODUCTS_LIST = {
collection: '[data-test="filterGroupActive"][data-test-id="collections"]',
productType:
'[data-test="filterGroupActive"][data-test-id="productType"]',
stock: '[data-test="filterGroupActive"][data-test-id="stock"]'
stock: '[data-test="filterGroupActive"][data-test-id="stock"]',
channel: '[data-test="filterGroupActive"][data-test-id="channel"]'
},
filterField: {
category: '[data-test="filter-field"][data-test-id="categories"]',
collection: '[data-test="filter-field"][data-test-id="collections"]',
productType: '[data-test="filter-field"][data-test-id="productType"]',
stock: '[data-test="filter-field"][data-test-id="stock"]',
channel: '[data-test="filter-field"][data-test-id="channel"]'
},
filterBySearchInput: '[data-test*="filterField"][data-test*="Input"]'
},

View file

@ -5,3 +5,6 @@ export const SHARED_ELEMENTS = {
table: 'table[class*="Table"]',
confirmationMsg: "[data-test='notification-success']"
};
export const getElementByDataTestId = dataTestId =>
`[data-test-id=${dataTestId}]`;

View file

@ -5,7 +5,7 @@ import {
getPermissionGroup
} from "../../../apiRequests/PermissionGroup.js";
import { getStaffMembersStartsWith } from "../../../apiRequests/StaffMembers";
import { USER_WITHOUT_NAME } from "../../../Data/users";
import { TEST_ADMIN_USER } from "../../../Data/users.js";
import { PERMISSION_GROUP_DETAILS } from "../../../elements/permissionGroup/permissionGroupDetails";
import { PERMISSION_GROUP_LIST } from "../../../elements/permissionGroup/permissionGroupsList";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
@ -60,7 +60,7 @@ describe("Permissions groups", () => {
it("should delete permission group", () => {
const permissionName = `${startsWith}${faker.datatype.number()}`;
let staffMember;
getStaffMembersStartsWith(USER_WITHOUT_NAME.email)
getStaffMembersStartsWith(TEST_ADMIN_USER.email)
.its("body.data.staffUsers.edges")
.then(staffMemberResp => {
staffMember = staffMemberResp[0].node;
@ -95,8 +95,11 @@ describe("Permissions groups", () => {
.get(PERMISSION_GROUP_DETAILS.assignMemberButton)
.click()
.get(PERMISSION_GROUP_DETAILS.searchField)
.type(USER_WITHOUT_NAME.email)
.get(PERMISSION_GROUP_DETAILS.userRow)
.type(TEST_ADMIN_USER.email);
cy.contains(
PERMISSION_GROUP_DETAILS.userRow,
`${TEST_ADMIN_USER.name} ${TEST_ADMIN_USER.lastName}`
)
.should("have.length", 1)
.find(BUTTON_SELECTORS.checkbox)
.click()
@ -110,14 +113,14 @@ describe("Permissions groups", () => {
})
.then(resp => {
expect(resp.users).to.have.length(1);
expect(resp.users[0].email).to.be.eq(USER_WITHOUT_NAME.email);
expect(resp.users[0].email).to.be.eq(TEST_ADMIN_USER.email);
});
});
it("should remove user from permission group", () => {
const permissionName = `${startsWith}${faker.datatype.number()}`;
let staffMember;
getStaffMembersStartsWith(USER_WITHOUT_NAME.email)
getStaffMembersStartsWith(TEST_ADMIN_USER.email)
.its("body.data.staffUsers.edges")
.then(staffMemberResp => {
staffMember = staffMemberResp[0].node;

View file

@ -99,6 +99,8 @@ describe("Orders", () => {
});
it("should create order with selected channel", () => {
// Remove login as admin after fixing SALEOR-3154
cy.clearSessionData().loginUserViaRequest();
cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder)
.click();

View file

@ -3,7 +3,11 @@ import faker from "faker";
import { createCollection } from "../../../../apiRequests/Collections";
import { updateProduct } from "../../../../apiRequests/Product";
import { PRODUCTS_LIST } from "../../../../elements/catalog/products/products-list";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import {
checkFilterOption,
selectChannel,
selectFilterBy,
selectFilterOption,
selectProductsOutOfStock
} from "../../../../steps/catalog/products/productsListSteps";
@ -20,7 +24,7 @@ import {
deleteShippingStartsWith
} from "../../../../utils/shippingUtils";
describe("Products", () => {
describe("Filtering products", () => {
const startsWith = "CyFilterProducts-";
const name = `${startsWith}${faker.datatype.number()}`;
const stockQuantity = 747;
@ -87,6 +91,7 @@ describe("Products", () => {
const filterProductsBy = ["category", "collection", "productType"];
filterProductsBy.forEach(filterBy => {
it(`should filter products by ${filterBy}`, () => {
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
selectFilterOption(filterBy, name);
cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => {
expect(product).to.includes(name);
@ -106,7 +111,8 @@ describe("Products", () => {
categoryId: category.id,
price
});
selectChannelInHeader(channel.name);
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
selectChannel(channel.slug);
selectProductsOutOfStock();
cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => {
expect(product).to.includes(productOutOfStock);

View file

@ -4,7 +4,7 @@ import { urlList } from "../../../../url/urlList";
import { expectProductsSortedBy } from "../../../../utils/products/productsListUtils";
describe("Sorting products", () => {
const sortByList = ["name", "type", "price"];
const sortByList = ["name", "type"];
sortByList.forEach(sortBy => {
it(`Sorting by ${sortBy}`, () => {
cy.clearSessionData()

View file

@ -1,6 +1,9 @@
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import {
getElementByDataTestId,
SHARED_ELEMENTS
} from "../../../elements/shared/sharedElements";
export function isNumberOfProductsSameAsInSelectResultsOnPage() {
let numberOfResults;
@ -36,7 +39,8 @@ export function getDisplayedColumnArray(columnName) {
}
export function selectFilterOption(filter, optionName) {
selectFilterBy(filter)
.get(PRODUCTS_LIST.filters.filterBySearchInput)
.get(PRODUCTS_LIST.filters.filterField[filter])
.find(PRODUCTS_LIST.filters.filterBySearchInput)
.type(optionName);
cy.contains(PRODUCTS_LIST.filters.filterOption, optionName)
.find(BUTTON_SELECTORS.checkbox)
@ -44,18 +48,25 @@ export function selectFilterOption(filter, optionName) {
submitFilters();
}
export function selectProductsOutOfStock() {
selectFilterBy("stock")
cy.get(PRODUCTS_LIST.filters.filterBy.stock)
.click()
.get(PRODUCTS_LIST.filters.productsOutOfStockOption)
.click();
submitFilters();
}
function selectFilterBy(filter) {
export function selectFilterBy(filter) {
return cy
.get(PRODUCTS_LIST.showFiltersButton)
.click()
.get(PRODUCTS_LIST.filters.filterBy[filter])
.click();
}
export function selectChannel(channelSlug) {
selectFilterBy("channel");
cy.get(getElementByDataTestId(channelSlug)).click();
}
function submitFilters() {
cy.get(BUTTON_SELECTORS.submit)
.click()