fixes staff members tests (#3678)
* fixes staff members tests * removing 'only' from suite
This commit is contained in:
parent
30ee7c1ff9
commit
b396c8e9a5
10 changed files with 79 additions and 41 deletions
|
@ -3,33 +3,36 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { LEFT_MENU_SELECTORS } from "../elements/account/left-menu/left-menu-selectors";
|
||||
import { LOGIN_SELECTORS } from "../elements/account/login-selectors";
|
||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
||||
import { INVITE_STAFF_MEMBER_FORM_SELECTORS } from "../elements/staffMembers/inviteStaffMemberForm";
|
||||
import { STAFF_MEMBER_DETAILS_SELECTORS } from "../elements/staffMembers/staffMemberDetails";
|
||||
import { STAFF_MEMBERS_LIST_SELECTORS } from "../elements/staffMembers/staffMembersList";
|
||||
import { urlList, userDetailsUrl } from "../fixtures/urlList";
|
||||
import { TEST_ADMIN_USER } from "../fixtures/users";
|
||||
import { activatePlugin, updatePlugin } from "../support/api/requests/Plugins";
|
||||
import {
|
||||
BUTTON_SELECTORS,
|
||||
HOMEPAGE_SELECTORS,
|
||||
INVITE_STAFF_MEMBER_FORM_SELECTORS,
|
||||
SHARED_ELEMENTS,
|
||||
STAFF_MEMBER_DETAILS_SELECTORS,
|
||||
STAFF_MEMBERS_LIST_SELECTORS,
|
||||
} from "../elements/";
|
||||
import { LOGIN_SELECTORS } from "../elements/account/login-selectors";
|
||||
import { MESSAGES, TEST_ADMIN_USER, urlList } from "../fixtures";
|
||||
import { userDetailsUrl } from "../fixtures/urlList";
|
||||
import {
|
||||
activatePlugin,
|
||||
deleteStaffMembersStartsWith,
|
||||
updatePlugin,
|
||||
updateStaffMember,
|
||||
} from "../support/api/requests/StaffMembers";
|
||||
} from "../support/api/requests/";
|
||||
import {
|
||||
getMailActivationLinkForUser,
|
||||
getMailActivationLinkForUserAndSubject,
|
||||
inviteStaffMemberWithFirstPermission,
|
||||
} from "../support/api/utils/users";
|
||||
import { expectWelcomeMessageIncludes } from "../support/pages/homePage";
|
||||
import { getDisplayedSelectors } from "../support/pages/permissionsPage";
|
||||
} from "../support/api/utils/";
|
||||
import {
|
||||
expectMainMenuAvailableSections,
|
||||
expectWelcomeMessageIncludes,
|
||||
fillUpOnlyUserDetails,
|
||||
fillUpSetPassword,
|
||||
fillUpUserDetailsAndAddFirstPermission,
|
||||
updateUserActiveFlag,
|
||||
} from "../support/pages/userPage";
|
||||
} from "../support/pages/";
|
||||
|
||||
describe("Staff members", () => {
|
||||
const startsWith = "StaffMembers";
|
||||
|
@ -43,7 +46,6 @@ describe("Staff members", () => {
|
|||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteStaffMembersStartsWith(startsWith);
|
||||
activatePlugin({ id: "mirumee.notifications.admin_email" });
|
||||
|
||||
inviteStaffMemberWithFirstPermission({ email })
|
||||
.then(({ user: userResp }) => {
|
||||
user = userResp;
|
||||
|
@ -63,7 +65,7 @@ describe("Staff members", () => {
|
|||
|
||||
it(
|
||||
"should be able to invite staff user. TC: SALEOR_3501",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
{ tags: ["@staffMembers", "@allEnv", "@critical"] },
|
||||
() => {
|
||||
const firstName = faker.name.firstName();
|
||||
const emailInvite = `${startsWith}${firstName}@example.com`;
|
||||
|
@ -102,7 +104,7 @@ describe("Staff members", () => {
|
|||
|
||||
it(
|
||||
"should activate user. TC: SALEOR_3503",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
{ tags: ["@staffMembers", "@allEnv", "@critical"] },
|
||||
() => {
|
||||
const serverStoredEmail = email.toLowerCase();
|
||||
|
||||
|
@ -133,18 +135,15 @@ describe("Staff members", () => {
|
|||
.loginUserViaRequest("auth", { email, password })
|
||||
.visit(urlList.homePage);
|
||||
expectWelcomeMessageIncludes(serverStoredEmail);
|
||||
getDisplayedSelectors().then(displayedSelectors => {
|
||||
expect(Object.values(displayedSelectors)).to.have.length(1);
|
||||
expect(Object.values(displayedSelectors)[0]).to.eq(
|
||||
LEFT_MENU_SELECTORS.home,
|
||||
);
|
||||
});
|
||||
expectMainMenuAvailableSections(1);
|
||||
cy.get(HOMEPAGE_SELECTORS.activity).should("not.exist");
|
||||
cy.get(HOMEPAGE_SELECTORS.topProducts).should("not.exist");
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should reset password. TC: SALEOR_3505",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
{ tags: ["@staffMembers", "@allEnv", "@critical"] },
|
||||
() => {
|
||||
const newPassword = faker.random.alphaNumeric(8);
|
||||
updatePlugin(
|
||||
|
@ -180,7 +179,7 @@ describe("Staff members", () => {
|
|||
|
||||
it(
|
||||
"should not be able to create staff member with not unique email. TC: SALEOR_3508",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
{ tags: ["@staffMembers", "@allEnv", "@critical"] },
|
||||
() => {
|
||||
const firstName = faker.name.firstName();
|
||||
const emailInvite = TEST_ADMIN_USER.email;
|
||||
|
@ -201,18 +200,14 @@ describe("Staff members", () => {
|
|||
"should not be able to update staff member with not unique email. TC: SALEOR_3509",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
() => {
|
||||
cy.addAliasToGraphRequest("StaffList");
|
||||
cy.visit(urlList.staffMembers)
|
||||
.expectSkeletonIsVisible()
|
||||
.waitForRequestAndCheckIfNoErrors("@StaffList")
|
||||
.get(SHARED_ELEMENTS.searchInput)
|
||||
.type(`${email} {enter}`);
|
||||
cy.waitForProgressBarToNotExist();
|
||||
cy.get(STAFF_MEMBERS_LIST_SELECTORS.staffAvatar)
|
||||
.first()
|
||||
.should("be.visible");
|
||||
cy.waitForProgressBarToNotExist()
|
||||
.get(STAFF_MEMBERS_LIST_SELECTORS.staffStatusText)
|
||||
.first()
|
||||
.should("be.visible")
|
||||
.type(`${email} {enter}`)
|
||||
.waitForRequestAndCheckIfNoErrors("@StaffList");
|
||||
cy.get(STAFF_MEMBERS_LIST_SELECTORS.usersEmails)
|
||||
.should("contain.text", email.toLowerCase())
|
||||
.click();
|
||||
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.staffEmail)
|
||||
.click()
|
||||
|
@ -221,6 +216,7 @@ describe("Staff members", () => {
|
|||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.confirmationErrorMessageShouldAppear();
|
||||
cy.contains(MESSAGES.invalidEmailAddress).should("be.visible");
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -276,7 +272,7 @@ describe("Staff members", () => {
|
|||
|
||||
it(
|
||||
"should create new user and successfully change password. TC: SALEOR_3510",
|
||||
{ tags: ["@staffMembers", "@allEnv"] },
|
||||
{ tags: ["@staffMembers", "@allEnv", "@critical"] },
|
||||
() => {
|
||||
const newPass = "newTestPass";
|
||||
const newLastName = faker.name.lastName();
|
||||
|
@ -300,6 +296,11 @@ describe("Staff members", () => {
|
|||
|
||||
cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
|
||||
cy.get(LOGIN_SELECTORS.accountSettings).click();
|
||||
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.changePasswordBtn).should(
|
||||
"be.visible",
|
||||
);
|
||||
// there is small bug which keep control panel opens and block any interaction via cypress - it does not affect real user - click on body can be removed when this pr is done https://github.com/saleor/saleor-dashboard/issues/3675
|
||||
cy.get(SHARED_ELEMENTS.body).click({ force: true });
|
||||
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.changePasswordBtn).click();
|
||||
cy.get(
|
||||
STAFF_MEMBER_DETAILS_SELECTORS.changePasswordModal.oldPassword,
|
||||
|
@ -307,13 +308,21 @@ describe("Staff members", () => {
|
|||
cy.get(
|
||||
STAFF_MEMBER_DETAILS_SELECTORS.changePasswordModal.newPassword,
|
||||
).type(newPass);
|
||||
cy.get(BUTTON_SELECTORS.submit).click().confirmationMessageShouldAppear();
|
||||
cy.addAliasToGraphRequest("ChangeUserPassword")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.confirmationMessageShouldAppear()
|
||||
.waitForRequestAndCheckIfNoErrors("@ChangeUserPassword");
|
||||
|
||||
cy.clearSessionData().loginUserViaRequest("auth", {
|
||||
email: newEmail,
|
||||
password: newPass,
|
||||
});
|
||||
cy.visit(urlList.staffMembers).expectSkeletonIsVisible();
|
||||
cy.visit(urlList.homePage)
|
||||
.get(HOMEPAGE_SELECTORS.welcomeMessage)
|
||||
.should("be.visible");
|
||||
cy.get(HOMEPAGE_SELECTORS.activity).should("be.visible");
|
||||
cy.get(HOMEPAGE_SELECTORS.topProducts).should("be.visible");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -18,6 +18,8 @@ export {
|
|||
CUSTOMER_DETAILS_SELECTORS,
|
||||
CUSTOMERS_LIST_SELECTORS,
|
||||
} from "./customer/";
|
||||
export { MENU as LEFT_MENU_SELECTORS } from "./account/left-menu/left-menu-selectors";
|
||||
|
||||
export { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
|
||||
export { HOMEPAGE_SELECTORS } from "./homePage/homePage-selectors";
|
||||
export { PAGINATION } from "./navigation";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export const SHARED_ELEMENTS = {
|
||||
body: "body",
|
||||
header: "[data-test-id='page-header']",
|
||||
progressBar: '[role="progressbar"]',
|
||||
circularProgress: '[class*="CircularProgress-circle"]',
|
||||
|
|
|
@ -2,4 +2,5 @@ export const STAFF_MEMBERS_LIST_SELECTORS = {
|
|||
inviteStaffMemberButton: '[data-test-id="invite-staff-member"]',
|
||||
staffStatusText: '[data-test-id="staffStatusText"]',
|
||||
staffAvatar: '[data-test-id="staffAvatar"]',
|
||||
usersEmails: '[data-test-id="user-mail"]',
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export { bodyMockHomePage } from "./bodyMocks";
|
||||
export { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
|
||||
export { urlList } from "./urlList";
|
||||
export { ONE_PERMISSION_USERS } from "./users";
|
||||
export { ONE_PERMISSION_USERS, TEST_ADMIN_USER } from "./users";
|
||||
export { MESSAGES } from "./messages";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export const MESSAGES = {
|
||||
noProductFound: "No products found",
|
||||
confirmProductsDeletion: "Are you sure you want to delete 2 products?",
|
||||
invalidEmailAddress: "Enter a valid email address.",
|
||||
};
|
||||
|
|
|
@ -3,3 +3,8 @@ export { createCustomer, deleteCustomersStartsWith } from "./Customer";
|
|||
export { createDraftOrder, getOrder } from "./Order";
|
||||
export { updateMetadata, updatePrivateMetadata } from "./Metadata";
|
||||
export { getProductMetadata } from "./storeFront/ProductDetails";
|
||||
export { activatePlugin, updatePlugin } from "./Plugins";
|
||||
export {
|
||||
deleteStaffMembersStartsWith,
|
||||
updateStaffMember,
|
||||
} from "./StaffMembers";
|
||||
|
|
|
@ -6,3 +6,8 @@ export {
|
|||
updateTaxConfigurationForChannel,
|
||||
} from "./taxesUtils";
|
||||
export * as productsUtils from "./products/productsUtils";
|
||||
export {
|
||||
getMailActivationLinkForUser,
|
||||
getMailActivationLinkForUserAndSubject,
|
||||
inviteStaffMemberWithFirstPermission,
|
||||
} from "./users";
|
||||
|
|
|
@ -1,2 +1,14 @@
|
|||
export * as ordersOperationsHelpers from "./ordersOperations";
|
||||
export * as transactionsOrderUtils from "./ordersTransactionUtils";
|
||||
export { expectWelcomeMessageIncludes } from "./homePage";
|
||||
export { getDisplayedSelectors } from "./permissionsPage";
|
||||
export {
|
||||
fillUpOnlyUserDetails,
|
||||
fillUpSetPassword,
|
||||
fillUpUserDetailsAndAddFirstPermission,
|
||||
updateUserActiveFlag,
|
||||
} from "./userPage";
|
||||
export {
|
||||
expectMainMenuAvailableSections,
|
||||
expectMainMenuSectionsToBeVisible,
|
||||
} from "./mainMenuPage";
|
||||
|
|
|
@ -143,7 +143,9 @@ const StaffList: React.FC<StaffListProps> = props => {
|
|||
</Box>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Text size="small">{staffMember?.email}</Text>
|
||||
<Text size="small" data-test-id="user-mail">
|
||||
{staffMember?.email}
|
||||
</Text>
|
||||
</TableCell>
|
||||
</TableRowLink>
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue