Add reports to tests (#1898)

* add reporter, fix tests

* remove unused import

* get functions duration

* merge

* update snaps
This commit is contained in:
Karolina Rakoczy 2022-03-03 11:25:27 +01:00 committed by GitHub
parent 66705e7f3e
commit 4d02eb60c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1075 additions and 144 deletions

1
.gitignore vendored
View file

@ -42,6 +42,7 @@ cypress/videos
webpack-bundle.json webpack-bundle.json
/templates/templated_email/compiled/* /templates/templated_email/compiled/*
!/templates/templated_email/compiled/.gitkeep !/templates/templated_email/compiled/.gitkeep
cypress/reports
# Exported results file # Exported results file
django-queries-results.html django-queries-results.html

View file

@ -6,8 +6,5 @@
"defaultCommandTimeout": 15000, "defaultCommandTimeout": 15000,
"requestTimeout": 15000, "requestTimeout": 15000,
"viewportWidth": 1400, "viewportWidth": 1400,
"viewportHeight": 660, "viewportHeight": 660
"retries": { }
"runMode": 2
}
}

View file

@ -2,4 +2,4 @@ export const CATEGORIES_LIST = {
addCategoryButton: '[data-test-id="create-category"]' addCategoryButton: '[data-test-id="create-category"]'
}; };
export const categoryRow = categoryId => `[data-test-id="${categoryId}"]`; export const categoryRow = categoryId => `[data-test-id*="${categoryId}"]`;

View file

@ -8,6 +8,7 @@ export const BUTTON_SELECTORS = {
selectOption: "[data-test-id*='select-option']", selectOption: "[data-test-id*='select-option']",
notSelectedOption: ":not([aria-selected])", notSelectedOption: ":not([aria-selected])",
deleteButton: '[data-test="button-bar-delete"]', deleteButton: '[data-test="button-bar-delete"]',
confirmDeleteButton: '[data-test-id="confirm-delete"]',
expandIcon: '[data-test-id="expand-icon"]', expandIcon: '[data-test-id="expand-icon"]',
nextPaginationButton: '[data-test="button-pagination-next"]', nextPaginationButton: '[data-test="button-pagination-next"]',
deleteIcon: '[data-test-id="delete-icon"]', deleteIcon: '[data-test-id="delete-icon"]',

View file

@ -12,7 +12,6 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { categoryDetailsUrl, urlList } from "../../fixtures/urlList"; import { categoryDetailsUrl, urlList } from "../../fixtures/urlList";
import { getCategory } from "../../support/api/requests/Category"; import { getCategory } from "../../support/api/requests/Category";
import { createCategory as createCategoryRequest } from "../../support/api/requests/Category";
import { deleteCategoriesStartsWith } from "../../support/api/utils/catalog/categoryUtils"; import { deleteCategoriesStartsWith } from "../../support/api/utils/catalog/categoryUtils";
import * as channelsUtils from "../../support/api/utils/channelsUtils"; import * as channelsUtils from "../../support/api/utils/channelsUtils";
import * as productsUtils from "../../support/api/utils/products/productsUtils"; import * as productsUtils from "../../support/api/utils/products/productsUtils";
@ -148,7 +147,7 @@ filterTests({ definedTags: ["all"] }, () => {
it("should be able to delete category. TC: SALEOR_0206", () => { it("should be able to delete category. TC: SALEOR_0206", () => {
const categoryName = `${startsWith}${faker.datatype.number()}`; const categoryName = `${startsWith}${faker.datatype.number()}`;
createCategoryRequest({ name: categoryName }).then(categoryResp => { createCategory({ name: categoryName }).then(categoryResp => {
cy.visit(categoryDetailsUrl(categoryResp.id)) cy.visit(categoryDetailsUrl(categoryResp.id))
.get(BUTTON_SELECTORS.deleteButton) .get(BUTTON_SELECTORS.deleteButton)
.click() .click()
@ -164,7 +163,7 @@ filterTests({ definedTags: ["all"] }, () => {
const categoryName = `${startsWith}${faker.datatype.number()}`; const categoryName = `${startsWith}${faker.datatype.number()}`;
const updatedName = `${startsWith}updatedCategory`; const updatedName = `${startsWith}updatedCategory`;
createCategoryRequest({ name: categoryName }) createCategory({ name: categoryName })
.then(categoryResp => { .then(categoryResp => {
cy.visitAndWaitForProgressBarToDisappear( cy.visitAndWaitForProgressBarToDisappear(
categoryDetailsUrl(categoryResp.id) categoryDetailsUrl(categoryResp.id)
@ -186,10 +185,10 @@ filterTests({ definedTags: ["all"] }, () => {
let firstCategory; let firstCategory;
let secondCategory; let secondCategory;
createCategoryRequest({ name: firstCategoryName }).then(categoryResp => { createCategory({ name: firstCategoryName }).then(categoryResp => {
firstCategory = categoryResp; firstCategory = categoryResp;
}); });
createCategoryRequest({ name: secondCategoryName }).then(categoryResp => { createCategory({ name: secondCategoryName }).then(categoryResp => {
secondCategory = categoryResp; secondCategory = categoryResp;
cy.visit(urlList.categories) cy.visit(urlList.categories)
.searchInTable(startsWith) .searchInTable(startsWith)
@ -216,7 +215,7 @@ filterTests({ definedTags: ["all"] }, () => {
let subCategory; let subCategory;
let mainCategory; let mainCategory;
createCategoryRequest({ name: mainCategoryName }) createCategory({ name: mainCategoryName })
.then(categoryResp => { .then(categoryResp => {
mainCategory = categoryResp; mainCategory = categoryResp;
createCategoryRequest({ createCategoryRequest({

View file

@ -20,7 +20,7 @@ import filterTests from "../../../support/filterTests";
import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage"; import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage";
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => { filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
describe("Create attribute with type", () => { describe("Create variant with variant selection attribute", () => {
const startsWith = "VarSel"; const startsWith = "VarSel";
const attributesTypes = [ const attributesTypes = [
@ -39,7 +39,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
getDefaultChannel().then(defaultChannel => (channel = defaultChannel)); getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
createCategory(startsWith).then( createCategory({ name: startsWith }).then(
categoryResp => (category = categoryResp) categoryResp => (category = categoryResp)
); );
}); });

View file

@ -18,7 +18,7 @@ import { deleteProductsStartsWith } from "../../../support/api/utils/products/pr
import filterTests from "../../../support/filterTests"; import filterTests from "../../../support/filterTests";
filterTests({ definedTags: ["all"] }, () => { filterTests({ definedTags: ["all"] }, () => {
describe("As an admin I want to manage product types", () => { describe("As an admin I want to manage attributes in product types", () => {
const startsWith = "productType"; const startsWith = "productType";
let category; let category;
let channel; let channel;
@ -28,7 +28,7 @@ filterTests({ definedTags: ["all"] }, () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
createAttribute({ name: startsWith }).then(resp => (attribute = resp)); createAttribute({ name: startsWith }).then(resp => (attribute = resp));
createCategory(startsWith).then(resp => (category = resp)); createCategory({ name: startsWith }).then(resp => (category = resp));
getDefaultChannel().then(resp => (channel = resp)); getDefaultChannel().then(resp => (channel = resp));
}); });

View file

@ -31,7 +31,7 @@ filterTests({ definedTags: ["all"] }, () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
createAttribute({ name: startsWith }).then(resp => (attribute = resp)); createAttribute({ name: startsWith }).then(resp => (attribute = resp));
createCategory(startsWith).then(resp => (category = resp)); createCategory({ name: startsWith }).then(resp => (category = resp));
getDefaultChannel().then(resp => (channel = resp)); getDefaultChannel().then(resp => (channel = resp));
}); });
@ -49,8 +49,7 @@ filterTests({ definedTags: ["all"] }, () => {
.get(BUTTON_SELECTORS.deleteButton) .get(BUTTON_SELECTORS.deleteButton)
.click() .click()
.addAliasToGraphRequest("ProductTypeDelete") .addAliasToGraphRequest("ProductTypeDelete")
.get(SHARED_ELEMENTS.warningDialog) .get(BUTTON_SELECTORS.confirmDeleteButton)
.find(BUTTON_SELECTORS.deleteButton)
.click() .click()
.waitForRequestAndCheckIfNoErrors("@ProductTypeDelete"); .waitForRequestAndCheckIfNoErrors("@ProductTypeDelete");
getProductType(productType.id).should("be.null"); getProductType(productType.id).should("be.null");
@ -78,13 +77,11 @@ filterTests({ definedTags: ["all"] }, () => {
.get(BUTTON_SELECTORS.deleteButton) .get(BUTTON_SELECTORS.deleteButton)
.click() .click()
.addAliasToGraphRequest("ProductTypeDelete") .addAliasToGraphRequest("ProductTypeDelete")
.get(SHARED_ELEMENTS.warningDialog) .get(BUTTON_SELECTORS.confirmDeleteButton)
.find(BUTTON_SELECTORS.deleteButton)
.should("not.be.enabled") .should("not.be.enabled")
.get(BUTTON_SELECTORS.deleteAssignedItemsConsentCheckbox) .get(BUTTON_SELECTORS.deleteAssignedItemsConsentCheckbox)
.click() .click()
.get(SHARED_ELEMENTS.warningDialog) .get(BUTTON_SELECTORS.confirmDeleteButton)
.find(BUTTON_SELECTORS.deleteButton)
.click() .click()
.waitForRequestAndCheckIfNoErrors("@ProductTypeDelete"); .waitForRequestAndCheckIfNoErrors("@ProductTypeDelete");
getProductType(productType.id).should("be.null"); getProductType(productType.id).should("be.null");

View file

@ -22,6 +22,7 @@ const graphql = require("graphql-request");
module.exports = async (on, config) => { module.exports = async (on, config) => {
// make env variables visible for cypress // make env variables visible for cypress
require("cypress-mochawesome-reporter/plugin")(on);
config.env.API_URI = process.env.API_URI; config.env.API_URI = process.env.API_URI;
config.env.APP_MOUNT_URI = process.env.APP_MOUNT_URI; config.env.APP_MOUNT_URI = process.env.APP_MOUNT_URI;
config.env.mailHogUrl = process.env.CYPRESS_MAILHOG; config.env.mailHogUrl = process.env.CYPRESS_MAILHOG;

View file

@ -13,6 +13,10 @@ import "./customCommands/sharedElementsOperations/tables";
import "./customCommands/sharedElementsOperations/deleteElement"; import "./customCommands/sharedElementsOperations/deleteElement";
import "cypress-mailhog"; import "cypress-mailhog";
import "cypress-file-upload"; import "cypress-file-upload";
import "cypress-mochawesome-reporter/register";
import { commandTimings } from "cypress-timings";
commandTimings();
import { urlList } from "../fixtures/urlList"; import { urlList } from "../fixtures/urlList";

View file

@ -56,8 +56,10 @@ export function updateCollection({ name, description }) {
export function assignProductsToCollection(productName) { export function assignProductsToCollection(productName) {
cy.get(COLLECTION_SELECTORS.addProductButton) cy.get(COLLECTION_SELECTORS.addProductButton)
.click() .click()
.addAliasToGraphRequest("SearchProducts")
.get(ASSIGN_ELEMENTS_SELECTORS.searchInput) .get(ASSIGN_ELEMENTS_SELECTORS.searchInput)
.type(productName); .type(productName)
.waitForRequestAndCheckIfNoErrors("@SearchProducts");
cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, productName) cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, productName)
.find(ASSIGN_ELEMENTS_SELECTORS.checkbox) .find(ASSIGN_ELEMENTS_SELECTORS.checkbox)
.click(); .click();

View file

@ -3,6 +3,7 @@ import { PRODUCT_DETAILS } from "../../../../elements/catalog/products/product-d
import { VARIANTS_SELECTORS } from "../../../../elements/catalog/products/variants-selectors"; import { VARIANTS_SELECTORS } from "../../../../elements/catalog/products/variants-selectors";
import { AVAILABLE_CHANNELS_FORM } from "../../../../elements/channels/available-channels-form"; import { AVAILABLE_CHANNELS_FORM } from "../../../../elements/channels/available-channels-form";
import { BUTTON_SELECTORS } from "../../../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import { formatDate } from "../../../formatData/formatDate"; import { formatDate } from "../../../formatData/formatDate";
import { selectChannelVariantInDetailsPage } from "../../channelsPage"; import { selectChannelVariantInDetailsPage } from "../../channelsPage";
import { fillUpPriceList } from "./priceListComponent"; import { fillUpPriceList } from "./priceListComponent";
@ -62,9 +63,10 @@ export function createVariant({
}) { }) {
cy.get(PRODUCT_DETAILS.addVariantsButton).click(); cy.get(PRODUCT_DETAILS.addVariantsButton).click();
fillUpVariantDetails({ attributeName, sku, warehouseName, quantity }); fillUpVariantDetails({ attributeName, sku, warehouseName, quantity });
cy.get(BUTTON_SELECTORS.back);
cy.get(VARIANTS_SELECTORS.saveButton) cy.get(VARIANTS_SELECTORS.saveButton)
.click() .click()
.get(VARIANTS_SELECTORS.skuInput)
.should("be.enabled")
.get(BUTTON_SELECTORS.back) .get(BUTTON_SELECTORS.back)
.click(); .click();
selectChannelForVariantAndFillUpPrices({ selectChannelForVariantAndFillUpPrices({
@ -152,6 +154,8 @@ export function selectChannelForVariantAndFillUpPrices({
.get(VARIANTS_SELECTORS.saveButton) .get(VARIANTS_SELECTORS.saveButton)
.click() .click()
.waitForRequestAndCheckIfNoErrors("@ProductVariantChannelListingUpdate") .waitForRequestAndCheckIfNoErrors("@ProductVariantChannelListingUpdate")
.get(PRICE_LIST.priceInput)
.should("be.enabled")
.get(BUTTON_SELECTORS.back) .get(BUTTON_SELECTORS.back)
.click() .click()
.waitForProgressBarToNotBeVisible() .waitForProgressBarToNotBeVisible()

1142
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,7 @@
"crc-32": "^1.2.0", "crc-32": "^1.2.0",
"currency-codes": "^2.1.0", "currency-codes": "^2.1.0",
"cypress-mailhog": "^1.3.0", "cypress-mailhog": "^1.3.0",
"cypress-mochawesome-reporter": "^2.3.0",
"downshift": "^6.1.7", "downshift": "^6.1.7",
"editorjs-inline-tool": "^0.4.0", "editorjs-inline-tool": "^0.4.0",
"editorjs-undo": "^0.1.4", "editorjs-undo": "^0.1.4",
@ -51,6 +52,7 @@
"hotkeys-js": "^3.8.1", "hotkeys-js": "^3.8.1",
"is-url": "^1.2.4", "is-url": "^1.2.4",
"jss": "^9.8.7", "jss": "^9.8.7",
"junit-report-merger": "^3.0.5",
"keycode": "^2.2.0", "keycode": "^2.2.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"moment-timezone": "^0.5.32", "moment-timezone": "^0.5.32",
@ -140,6 +142,8 @@
"cross-env": "^6.0.3", "cross-env": "^6.0.3",
"cypress": "^9.2.1", "cypress": "^9.2.1",
"cypress-file-upload": "^5.0.8", "cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.5.0",
"cypress-timings": "^1.0.0",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5", "enzyme-adapter-react-16": "^1.15.5",
@ -162,6 +166,10 @@
"jest-localstorage-mock": "^2.4.3", "jest-localstorage-mock": "^2.4.3",
"jscodeshift": "^0.13.0", "jscodeshift": "^0.13.0",
"lint-staged": "^10.5.1", "lint-staged": "^10.5.1",
"mocha-junit-reporter": "^2.0.2",
"mochawesome": "^7.0.1",
"mochawesome-merge": "^4.2.1",
"mochawesome-report-generator": "^6.0.1",
"mock-apollo-client": "^0.4.0", "mock-apollo-client": "^0.4.0",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"react-intl-translations-manager": "^5.0.3", "react-intl-translations-manager": "^5.0.3",
@ -253,6 +261,9 @@
"start": "npm run generate-fragment-types && webpack-dev-server -d", "start": "npm run generate-fragment-types && webpack-dev-server -d",
"storybook": "start-storybook -p 3000 -c src/storybook/", "storybook": "start-storybook -p 3000 -c src/storybook/",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:run:report": "cypress run --env tags=all --reporter cypress-mochawesome-reporter --reporter-options reportDir='cypress/reports',overwrite=true,charts=true",
"cy:combine:reports": "npx mochawesome-merge 'cypress/results/*.json' > mochawesome.json",
"cy:run:merge": "npx marge mochawesome.json",
"cy:run:dashboard": "cypress run --record --key 1fe833f5-fca4-4454-ac55-943815b91c6c", "cy:run:dashboard": "cypress run --record --key 1fe833f5-fca4-4454-ac55-943815b91c6c",
"cy:run:record": "npm run cy:run -- --record", "cy:run:record": "npm run cy:run -- --record",
"cy:open": "cypress open", "cy:open": "cypress open",

View file

@ -20,11 +20,13 @@ interface DeleteButtonProps {
onClick: () => void; onClick: () => void;
label?: string | React.ReactNode; label?: string | React.ReactNode;
disabled?: boolean; disabled?: boolean;
testId?: string;
} }
const DeleteButton: React.FC<DeleteButtonProps> = ({ const DeleteButton: React.FC<DeleteButtonProps> = ({
onClick, onClick,
label, label,
testId,
disabled = false disabled = false
}) => { }) => {
const classes = useStyles({}); const classes = useStyles({});
@ -35,7 +37,7 @@ const DeleteButton: React.FC<DeleteButtonProps> = ({
variant="primary" variant="primary"
onClick={onClick} onClick={onClick}
className={classes.button} className={classes.button}
data-test-id="button-bar-delete" data-test-id={testId ? "confirm-delete" : "button-bar-delete"}
disabled={disabled} disabled={disabled}
> >
{label || intl.formatMessage(buttonMessages.delete)} {label || intl.formatMessage(buttonMessages.delete)}

View file

@ -72,7 +72,11 @@ const TypeDeleteWarningDialogContent: React.FC<TypeDeleteWarningDialogContentPro
<HorizontalSpacer spacing={3} /> <HorizontalSpacer spacing={3} />
</> </>
)} )}
<DeleteButton onClick={onDelete} disabled={isDisbled} /> <DeleteButton
onClick={onDelete}
disabled={isDisbled}
testId="confirm-delete"
/>
</div> </div>
</CardContent> </CardContent>
); );