parent
aa2031eac3
commit
fc1c367eaf
13 changed files with 77 additions and 4 deletions
43
cypress/e2e/demo/demoDashboard.js
Normal file
43
cypress/e2e/demo/demoDashboard.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/// <reference types="cypress"/>
|
||||||
|
/// <reference types="../../support"/>
|
||||||
|
import {
|
||||||
|
BUTTON_SELECTORS,
|
||||||
|
HOMEPAGE_SELECTORS,
|
||||||
|
SHARED_ELEMENTS,
|
||||||
|
} from "../../elements";
|
||||||
|
import { orderDraftCreateDemoResponse, urlList } from "../../fixtures";
|
||||||
|
import { ordersOperationsHelpers } from "../../support/pages";
|
||||||
|
|
||||||
|
describe("Dashboard demo site tests", () => {
|
||||||
|
it("should be able to log in via UI", { tags: ["@demo-dashboard"] }, () => {
|
||||||
|
cy.addAliasToGraphRequest("Home")
|
||||||
|
.visit("/")
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.should("be.visible")
|
||||||
|
.click()
|
||||||
|
.waitForRequestAndCheckIfNoErrors("@Home");
|
||||||
|
cy.get(SHARED_ELEMENTS.notificationMessage).should("have.length", 1);
|
||||||
|
cy.get(HOMEPAGE_SELECTORS.welcomeMessage).should("be.visible");
|
||||||
|
cy.get(SHARED_ELEMENTS.notificationMessage).should("not.exist");
|
||||||
|
});
|
||||||
|
it(
|
||||||
|
"should not be able to create new order",
|
||||||
|
{ tags: ["@demo-dashboard"] },
|
||||||
|
() => {
|
||||||
|
cy.addAliasToGraphRequest("OrderList");
|
||||||
|
cy.loginUserViaRequest().then(() => {
|
||||||
|
cy.visit(`${urlList.orders}`).waitForRequestAndCheckIfNoErrors(
|
||||||
|
"@OrderList",
|
||||||
|
);
|
||||||
|
ordersOperationsHelpers.pickAndSelectChannelOnCreateOrderFormByIndex(1);
|
||||||
|
cy.addAliasToGraphRequest("OrderDraftCreate")
|
||||||
|
.clickSubmitButton()
|
||||||
|
.waitForRequestAndErrorMessage(
|
||||||
|
"@OrderDraftCreate",
|
||||||
|
orderDraftCreateDemoResponse,
|
||||||
|
);
|
||||||
|
cy.get(SHARED_ELEMENTS.notificationMessage).should("exist");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { CHANNEL_FORM_SELECTORS } from "./channel-form-selectors";
|
||||||
import { CHANNELS_SELECTORS } from "./channels-selectors";
|
import { CHANNELS_SELECTORS } from "./channels-selectors";
|
||||||
|
|
||||||
export { CHANNELS_SELECTORS };
|
export { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS };
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
PRODUCT_DETAILS,
|
PRODUCT_DETAILS,
|
||||||
PRODUCTS_LIST,
|
PRODUCTS_LIST,
|
||||||
} from "./catalog";
|
} from "./catalog";
|
||||||
import { CHANNELS_SELECTORS } from "./channels";
|
import { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS } from "./channels";
|
||||||
import { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
|
import { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
|
||||||
import {
|
import {
|
||||||
CUSTOMER_DETAILS_SELECTORS,
|
CUSTOMER_DETAILS_SELECTORS,
|
||||||
|
@ -53,6 +53,7 @@ export {
|
||||||
BUTTON_SELECTORS,
|
BUTTON_SELECTORS,
|
||||||
CATEGORIES_LIST_SELECTORS,
|
CATEGORIES_LIST_SELECTORS,
|
||||||
CATEGORY_DETAILS_SELECTORS,
|
CATEGORY_DETAILS_SELECTORS,
|
||||||
|
CHANNEL_FORM_SELECTORS,
|
||||||
CHANNELS_SELECTORS,
|
CHANNELS_SELECTORS,
|
||||||
COLLECTION_SELECTORS,
|
COLLECTION_SELECTORS,
|
||||||
CONFIGURATION_SELECTORS,
|
CONFIGURATION_SELECTORS,
|
||||||
|
|
|
@ -10,6 +10,7 @@ export const SHARED_ELEMENTS = {
|
||||||
notificationSuccess:
|
notificationSuccess:
|
||||||
'[data-test-id="notification"][data-test-type="success"]',
|
'[data-test-id="notification"][data-test-type="success"]',
|
||||||
notificationFailure: '[data-test-id="notification"][data-test-type="error"]',
|
notificationFailure: '[data-test-id="notification"][data-test-type="error"]',
|
||||||
|
notificationMessage: '[data-test-id="notification-message"]',
|
||||||
dialog: '[role="dialog"]',
|
dialog: '[role="dialog"]',
|
||||||
searchInput: '[data-test-id="search-input"]',
|
searchInput: '[data-test-id="search-input"]',
|
||||||
selectOption: '[data-test-id*="select-field-option"]',
|
selectOption: '[data-test-id*="select-field-option"]',
|
||||||
|
|
1
cypress/fixtures/errors/demo/orderDratCreate.js
Normal file
1
cypress/fixtures/errors/demo/orderDratCreate.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const orderDraftCreateDemoResponse = "API runs in read-only mode!";
|
|
@ -1,3 +1,5 @@
|
||||||
import { bodyMockHomePage } from "./bodyMocks";
|
import { bodyMockHomePage } from "./bodyMocks";
|
||||||
|
import { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
|
||||||
|
import { urlList } from "./urlList";
|
||||||
|
|
||||||
export { bodyMockHomePage };
|
export { bodyMockHomePage, orderDraftCreateDemoResponse, urlList };
|
||||||
|
|
|
@ -27,6 +27,12 @@ Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Cypress.Commands.add("waitForRequestAndErrorMessage", (alias, error) => {
|
||||||
|
cy.wait(alias).then(resp => {
|
||||||
|
expect(resp.response.body.errors[0].message).to.contains(error);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("checkIfDataAreNotNull", data => {
|
Cypress.Commands.add("checkIfDataAreNotNull", data => {
|
||||||
expect(data, "Created data should not be null").to.be.not.null;
|
expect(data, "Created data should not be null").to.be.not.null;
|
||||||
|
|
|
@ -17,6 +17,9 @@ Cypress.Commands.add("clickNextPagePaginationButton", () =>
|
||||||
Cypress.Commands.add("clickPrevPagePaginationButton", () =>
|
Cypress.Commands.add("clickPrevPagePaginationButton", () =>
|
||||||
cy.get(PAGINATION.previousPagePaginationButton),
|
cy.get(PAGINATION.previousPagePaginationButton),
|
||||||
);
|
);
|
||||||
|
Cypress.Commands.add("clickSubmitButton", () =>
|
||||||
|
cy.get(BUTTON_SELECTORS.submit).click(),
|
||||||
|
);
|
||||||
|
|
||||||
Cypress.Commands.add("createNewOption", (selectSelector, newOption) => {
|
Cypress.Commands.add("createNewOption", (selectSelector, newOption) => {
|
||||||
cy.get(selectSelector).type(newOption);
|
cy.get(selectSelector).type(newOption);
|
||||||
|
|
|
@ -31,7 +31,6 @@ Cypress.Commands.add(
|
||||||
const mutation = `mutation TokenAuth{
|
const mutation = `mutation TokenAuth{
|
||||||
tokenCreate(email: "${user.email}", password: "${user.password}") {
|
tokenCreate(email: "${user.email}", password: "${user.password}") {
|
||||||
token
|
token
|
||||||
csrfToken
|
|
||||||
refreshToken
|
refreshToken
|
||||||
errors: errors {
|
errors: errors {
|
||||||
code
|
code
|
||||||
|
|
|
@ -48,6 +48,7 @@ Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
"addAliasToGraphRequestAndUseMockedResponseBody",
|
"addAliasToGraphRequestAndUseMockedResponseBody",
|
||||||
(operationName, bodyMock) => {
|
(operationName, bodyMock) => {
|
||||||
|
|
3
cypress/support/pages/index.js
Normal file
3
cypress/support/pages/index.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import * as ordersOperationsHelpers from "./ordersOperations";
|
||||||
|
|
||||||
|
export { ordersOperationsHelpers };
|
11
cypress/support/pages/ordersOperations.js
Normal file
11
cypress/support/pages/ordersOperations.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { CHANNEL_FORM_SELECTORS, ORDERS_SELECTORS } from "../../elements";
|
||||||
|
|
||||||
|
export function pickAndSelectChannelOnCreateOrderFormByIndex(index) {
|
||||||
|
cy.get(ORDERS_SELECTORS.createOrderButton)
|
||||||
|
.click()
|
||||||
|
.get(CHANNEL_FORM_SELECTORS.channelSelect)
|
||||||
|
.click()
|
||||||
|
.get(CHANNEL_FORM_SELECTORS.channelOption)
|
||||||
|
.eq(index)
|
||||||
|
.click();
|
||||||
|
}
|
|
@ -304,6 +304,7 @@
|
||||||
"cy:run:allEnv:parallel": "cypress run --record --env grepTags=@allEnv --parallel",
|
"cy:run:allEnv:parallel": "cypress run --record --env grepTags=@allEnv --parallel",
|
||||||
"cy:run:stable:parallel": "cypress run --record --env grepTags=@critical --parallel --tag Stable",
|
"cy:run:stable:parallel": "cypress run --record --env grepTags=@critical --parallel --tag Stable",
|
||||||
"cy:percy": "CYPRESS_demoTests=true percy exec -- npm run cy:run",
|
"cy:percy": "CYPRESS_demoTests=true percy exec -- npm run cy:run",
|
||||||
|
"cy:run:demo": "CYPRESS_demoTests=true npm run cy:run",
|
||||||
"test": "jest src/",
|
"test": "jest src/",
|
||||||
"test:watch": "jest --watch src/",
|
"test:watch": "jest --watch src/",
|
||||||
"lint": "eslint \"src/**/*.@(tsx|ts|jsx|js)\" --fix",
|
"lint": "eslint \"src/**/*.@(tsx|ts|jsx|js)\" --fix",
|
||||||
|
|
Loading…
Reference in a new issue