Просмотр исходного кода

add mutation for bookmark info and close toaster

Mudana-Grune 3 лет назад
Родитель
Сommit
e515a19295

+ 3 - 1
packages/app/src/components/PageList/PageListItemL.tsx

@@ -23,7 +23,7 @@ import {
   OnDuplicatedFunction, OnRenamedFunction, OnDeletedFunction, OnPutBackedFunction,
 } from '~/interfaces/ui';
 import LinkedPagePath from '~/models/linked-page-path';
-import { useSWRxCurrentUserBookmarks } from '~/stores/bookmark';
+import { useSWRBookmarkInfo, useSWRxCurrentUserBookmarks } from '~/stores/bookmark';
 import {
   usePageRenameModal, usePageDuplicateModal, usePageDeleteModal, usePutBackPageModal,
 } from '~/stores/modal';
@@ -89,6 +89,7 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
   const shouldFetch = isSelected && (pageData != null || pageMeta != null);
   const { data: pageInfo } = useSWRxPageInfo(shouldFetch ? pageData?._id : null);
   const { mutate: mutateCurrentUserBookmark } = useSWRxCurrentUserBookmarks();
+  const { mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageData?._id);
   const elasticSearchResult = isIPageSearchMeta(pageMeta) ? pageMeta.elasticSearchResult : null;
   const revisionShortBody = isIPageInfoForListing(pageMeta) ? pageMeta.revisionShortBody : null;
 
@@ -126,6 +127,7 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
     const bookmarkOperation = _newValue ? bookmark : unbookmark;
     await bookmarkOperation(_pageId);
     mutateCurrentUserBookmark();
+    mutateBookmarkInfo();
   };
 
   const duplicateMenuItemClickHandler = useCallback(() => {

+ 12 - 0
packages/app/test/cypress/integration/20-basic-features/20-basic-features--click-page-icons.spec.ts

@@ -96,6 +96,12 @@ context('Click page icons button', () => {
     cy.get('#bookmark-dropdown-btn').click({force: true});
     cy.get('#bookmark-dropdown-btn').should('have.class', 'active');
 
+    // Close toaster
+    cy.get('.Toastify__toast').should('be.visible').within(() => {
+      cy.get('.Toastify__close-button').should('be.visible').click();
+      cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+    });
+
     // position of the element is not fixed to be displayed, so the element is removed
     cy.get('body').then($body => {
       if ($body.find('[data-testid="bookmark-button-tooltip"]').length > 0) {
@@ -125,6 +131,12 @@ context('Click page icons button', () => {
     cy.get('.grw-bookmark-folder-menu-item').first().click({force: true});
     cy.get('#bookmark-dropdown-btn').should('not.have.class', 'active');
 
+    // Close toaster
+    cy.get('.Toastify__toast').should('be.visible').within(() => {
+      cy.get('.Toastify__close-button').should('be.visible').click();
+      cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+    });
+
     // position of the element is not fixed to be displayed, so the element is removed
     cy.get('body').then($body => {
       if ($body.find('[data-testid="bookmark-button-tooltip"]').length > 0) {