index.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export const getChakraUINotification = () => {
  2. return cy.get(".chakra-alert");
  3. };
  4. export const getChakraUIToast = () => {
  5. return cy.get(".chakra-toast");
  6. };
  7. export const getChakraUIFormItemError = ({
  8. id,
  9. type = "text",
  10. }: IGetChakraUIFormItemErrorParams) => {
  11. if (type === "text") {
  12. return cy.get(`#${id}`).siblings(".chakra-form__error-message");
  13. }
  14. if (type === "select") {
  15. return cy
  16. .get(`#${id}`)
  17. .parent()
  18. .parent()
  19. .find(".chakra-form__error-message");
  20. }
  21. // type === "text"
  22. return cy.get(`#${id}`).siblings(".chakra-form__error-message");
  23. };
  24. export const getChakraUIPopoverDeleteButton = () => {
  25. return cy.get(".chakra-popover__body button").contains(/delete/gi);
  26. };
  27. export const getChakraUILoadingOverlay = () => {
  28. return cy.get(".chakra-spinner");
  29. };
  30. export const fillChakraUIForm = () => {
  31. cy.fixture("mock-post").then((mockPost) => {
  32. cy.get("#title").clear().type(mockPost.title);
  33. cy.get("#status").select(mockPost.status.toLowerCase());
  34. cy.get("#categoryId").select(2);
  35. cy.get("#content").clear().type(mockPost.content);
  36. });
  37. };