Преглед изворни кода

feat: Vrt search

https://youtrack.weseek.co.jp/issue/GW-7739
- Add data-testid props on page item control and global search component
- Create spec.ts for search current tree
I Komang Mudana пре 4 година
родитељ
комит
9910f3f058

+ 8 - 1
packages/app/src/components/Navbar/GlobalSearch.tsx

@@ -73,7 +73,13 @@ const GlobalSearch: FC<Props> = (props: Props) => {
     <div className={`form-group mb-0 d-print-none ${isSearchServiceReachable ? '' : 'has-error'}`}>
       <div className="input-group flex-nowrap">
         <div className={`input-group-prepend ${dropup ? 'dropup' : ''}`}>
-          <button className="btn btn-secondary dropdown-toggle py-0" type="button" data-toggle="dropdown" aria-haspopup="true">
+          <button
+            className="btn btn-secondary dropdown-toggle py-0"
+            type="button"
+            data-toggle="dropdown"
+            aria-haspopup="true"
+            data-testid="select-search-scope"
+          >
             {scopeLabel}
           </button>
           <div className="dropdown-menu">
@@ -88,6 +94,7 @@ const GlobalSearch: FC<Props> = (props: Props) => {
               { t('header_search_box.item_label.All pages') }
             </button>
             <button
+              data-tesid="search-current-tree"
               className="dropdown-item"
               type="button"
               onClick={() => {

+ 7 - 0
packages/app/test/cypress/integration/3-search/search-all-pages.spec.ts

@@ -52,6 +52,13 @@ context('Search all pages', () => {
 
     cy.getByTestid('open-page-item-control-btn').first().click();
     cy.screenshot(`${ssPrefix}click-three-dots-menu-search-with-tag`, {capture: 'viewport'});
+
+    /** TODO
+     * - Implement Add bookmark, move/rename , delete with tag
+     *
+    */
+
+
   })
 
 });

+ 70 - 0
packages/app/test/cypress/integration/3-search/search-current-tree.spec.ts

@@ -0,0 +1,70 @@
+context('Search all pages', () => {
+  const ssPrefix = 'search-all-pages-';
+
+  let connectSid: string | undefined;
+
+  before(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    cy.getCookie('connect.sid').then(cookie => {
+      connectSid = cookie?.value;
+    });
+    // collapse sidebar
+    cy.collapseSidebar(true);
+  });
+
+  beforeEach(() => {
+    if (connectSid != null) {
+      cy.setCookie('connect.sid', connectSid);
+    }
+  });
+
+  it(`Search by typing help and press ENTER`, () => {
+    const searchText = 'help';
+    cy.visit('/');
+    cy.getByTestid('select-search-scope').first().click({force: true});
+    cy.getByTestid('earch-current-tree').first().click({force: true});
+    cy.get('div.rbt-input-hint-container > input').click();
+    cy.screenshot(`${ssPrefix}search-input-focused`, { capture: 'viewport'});
+    cy.get('div.rbt-input-hint-container > input').type(`${searchText}`);
+    cy.screenshot(`${ssPrefix}insert-search-text`, { capture: 'viewport'});
+    cy.get('div.rbt-input-hint-container > input').type('{enter}');
+    cy.screenshot(`${ssPrefix}press-enter`, { capture: 'viewport'});
+
+    cy.getByTestid('search-result-list').should('be.visible');
+
+    cy.getByTestid('open-page-item-control-btn').first().click();
+    cy.screenshot(`${ssPrefix}click-three-dots-menu`, {capture: 'viewport'});
+  });
+
+
+  it(`Search by tag, ex: tag:help and press ENTER`, () => {
+    const searchText = `tag:help`;
+    cy.visit('/');
+
+    cy.getByTestid('select-search-scope').first().click({force: true});
+    cy.getByTestid('earch-current-tree').first().click({force: true});
+
+    cy.get('div.rbt-input-hint-container > input').click();
+    cy.get('div.rbt-input-hint-container > input').type(`${searchText}`);
+    cy.screenshot(`${ssPrefix}insert-search-text-with-tag`, { capture: 'viewport'});
+    cy.get('div.rbt-input-hint-container > input').type('{enter}');
+
+    cy.getByTestid('search-result-list').should('be.visible');
+
+    cy.screenshot(`${ssPrefix}search-with-tag-result`, {capture: 'viewport'});
+
+    cy.getByTestid('open-page-item-control-btn').first().click();
+    cy.screenshot(`${ssPrefix}click-three-dots-menu-search-with-tag`, {capture: 'viewport'});
+
+    /** TODO
+     * - Implement Add bookmark, move/rename , delete with tag
+     *
+    */
+
+
+  })
+
+});