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

Code improvement

https://youtrack.weseek.co.jp/issue/GW-7740
- Adjust selector name in spec.ts
- Move tag operations spec to 20-basic-features
- Adjust screenshot prefix name
- Remove unused spec.ts
mudana 3 лет назад
Родитель
Сommit
49d7d8d14a

+ 1 - 1
.github/workflows/reusable-app-prod.yml

@@ -180,7 +180,7 @@ jobs:
       fail-fast: false
       fail-fast: false
       matrix:
       matrix:
         # List string expressions that is comma separated ids of tests in "test/cypress/integration"
         # List string expressions that is comma separated ids of tests in "test/cypress/integration"
-        spec-group: ['10', '20', '21', '30', '40', '60','70']
+        spec-group: ['10', '20', '21', '30', '40', '60']
 
 
     services:
     services:
       mongodb:
       mongodb:

+ 164 - 0
packages/app/test/cypress/integration/20-basic-features/use-tools.spec.ts

@@ -141,3 +141,167 @@ context('Page Accessories Modal', () => {
   });
   });
 
 
 });
 });
+
+context('Tag Oprations', () =>{
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+  });
+
+  it('Successfully add new tag', () => {
+    const ssPrefix = 'tag-operations-add-new-tag-'
+    const tag = 'we';
+    cy.visit('/');
+    cy.screenshot(`${ssPrefix}click-plus-button`, {capture: 'viewport'});
+
+    cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
+    cy.get('#edit-tag-modal').should('be.visible');
+    cy.screenshot(`${ssPrefix}edit-tag-input`, {capture: 'viewport'});
+
+    cy.get('#edit-tag-modal').within(() => {
+      cy.get('.rbt-input-main').type(tag, {force: true});
+      cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
+      cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
+      cy.screenshot(`${ssPrefix}type-tag-name`, {capture: 'viewport'});
+    });
+
+    cy.get('#edit-tag-modal').within(() => {
+      cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
+      cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
+      cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
+      cy.screenshot(`${ssPrefix}insert-tag-name`, {capture: 'viewport'});
+    });
+
+    cy.get('#edit-tag-modal').within(() => {
+      cy.get('div.modal-footer > button').click();
+    });
+
+    cy.get('.grw-taglabels-container > form > a').contains(tag).should('exist');
+
+    cy.screenshot(`${ssPrefix}click-done`, {capture: 'viewport'});
+
+  });
+
+  it('Successfully duplicate page by generated tag', () => {
+    const ssPrefix = 'tag-operations-page-duplicate-';
+    const tag = 'we';
+    const newPageName = 'our';
+    cy.visit('/');
+    cy.get('.grw-taglabels-container > form > a').contains(tag).click();
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
+
+    cy.getByTestid('open-page-item-control-btn').first().click();
+    cy.screenshot(`${ssPrefix}click-three-dots-menu`, {capture: 'viewport'});
+
+    cy.getByTestid('open-page-duplicate-modal-btn').first().click({force: true});
+    cy.getByTestid('page-duplicate-modal').should('be.visible');
+    cy.getByTestid('page-duplicate-modal').within(() => {
+      cy.get('.rbt-input-main').type(newPageName, {force: true});
+    });
+    cy.screenshot(`${ssPrefix}duplicate-page`, {capture: 'viewport'});
+
+    cy.getByTestid('page-duplicate-modal').within(() => {
+      cy.get('.modal-footer > button.btn').click();
+    });
+    cy.visit(`/${newPageName}`);
+    cy.get('#wiki').should('not.be.empty');
+    cy.screenshot(`${ssPrefix}duplicated-page`, {capture: 'viewport'});
+  });
+
+  it('Successfully rename page from generated tag', () => {
+    const ssPrefix = 'tag-operations-page-rename-';
+    const tag = 'we';
+    const oldPageName = '/our';
+    const newPageName = '/ourus';
+
+    cy.visit('/');
+    cy.get('.grw-taglabels-container > form > a').contains(tag).click();
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
+
+    cy.getByTestid('search-result-list').within(() => {
+      cy.get('.list-group-item').each(($row) => {
+        if($row.find('a').text() === oldPageName){
+          cy.wrap($row).within(() => {
+            cy.getByTestid('open-page-item-control-btn').click();
+          });
+        }
+      });
+    });
+    cy.screenshot(`${ssPrefix}-click-three-dots-menu`, {capture: 'viewport'});
+
+    cy.getByTestid('search-result-list').within(() => {
+      cy.get('.list-group-item').each(($row) => {
+        if($row.find('a').text() === oldPageName){
+          cy.wrap($row).within(() => {
+            cy.getByTestid('open-page-move-rename-modal-btn').click();
+          });
+        }
+      });
+    });
+
+    cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
+      cy.get('.rbt-input-main').clear({force: true})
+      cy.get('.rbt-input-main').click().focused().type(newPageName, {force: true})
+      .should('have.value', newPageName);
+    });
+    cy.screenshot(`${ssPrefix}insert-new-page-name`, {capture: 'viewport'});
+
+    cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
+      cy.get('.modal-footer > button').click();
+    });
+
+    cy.visit(`/${newPageName}`);
+    cy.screenshot(`${ssPrefix}new-page-name-applied`, {capture: 'viewport'});
+  });
+
+  it('Successfully order pages with tag', () => {
+    const ssPrefix = 'tag-operations-tag-order-';
+    const tag = 'we';
+
+    cy.visit('/');
+    cy.get('.grw-taglabels-container > form > a').contains(tag).click();
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
+
+    cy.get('.grw-search-page-nav').within(() => {
+      cy.get('button.dropdown-toggle').first().click({force: true});
+      cy.get('.dropdown-menu-right').should('be.visible');
+      cy.get('.dropdown-menu-right > button:nth-child(1)').click({force: true});
+    });
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}by-relevance`);
+
+    cy.get('.grw-search-page-nav').within(() => {
+      cy.get('button.dropdown-toggle').first().click({force: true});
+      cy.get('.dropdown-menu-right').should('be.visible');
+      cy.get('.dropdown-menu-right > button:nth-child(2)').click({force: true});
+    });
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}by-creation-date`);
+
+    cy.get('.grw-search-page-nav').within(() => {
+      cy.get('button.dropdown-toggle').first().click({force: true});
+      cy.get('.dropdown-menu-right').should('be.visible');
+      cy.get('.dropdown-menu-right > button:nth-child(3)').click({force: true});
+    });
+    cy.getByTestid('search-result-base').should('be.visible');
+    cy.getByTestid('search-result-list').should('be.visible');
+    cy.getByTestid('search-result-content').should('be.visible');
+    cy.screenshot(`${ssPrefix}by-last-update-date`);
+  });
+});

+ 0 - 55
packages/app/test/cypress/integration/70-tag/add-tag.spec.ts

@@ -1,55 +0,0 @@
-/* eslint-disable cypress/no-unnecessary-waiting */
-context('Add Tag', () => {
-  const ssPrefix = 'add-tag-';
-
-  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;
-    });
-  });
-
-  beforeEach(() => {
-    if (connectSid != null) {
-      cy.setCookie('connect.sid', connectSid);
-    }
-  });
-
-  it('Add Tag', () => {
-    const tag = 'we';
-    cy.visit('/');
-    cy.screenshot(`${ssPrefix}click-plus-button`, {capture: 'viewport'});
-
-    cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
-    cy.wait(1000);
-
-    cy.screenshot(`${ssPrefix}edit-tag-input`, {capture: 'viewport'});
-
-    cy.get('#edit-tag-modal').within(() => {
-      cy.get('.rbt-input-main').type(tag, {force: true});
-    });
-    cy.wait(1000);
-    cy.screenshot(`${ssPrefix}type-tag-name`, {capture: 'viewport'});
-
-    cy.get('#edit-tag-modal').then(($item) => {
-      if($item.find('#rbt-menu-item-0 > a').length > 0){
-        cy.get('#rbt-menu-item-0 > a').click({force: true});
-        cy.wait(1000);
-        cy.screenshot(`${ssPrefix}insert-tag-name`, {capture: 'viewport'});
-      }
-    });
-
-
-    cy.get('#edit-tag-modal').within(() => {
-      cy.get('div.modal-footer > button').click();
-    });
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}click-done`, {capture: 'viewport'});
-  });
-
-});

+ 0 - 35
packages/app/test/cypress/integration/70-tag/duplicate-page.spec.ts

@@ -1,35 +0,0 @@
-/* eslint-disable cypress/no-unnecessary-waiting */
-context('Duplicate page by generated tag', () => {
-  const ssPrefix = 'duplicate-page-';
-
-  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;
-    });
-  });
-
-  beforeEach(() => {
-    if (connectSid != null) {
-      cy.setCookie('connect.sid', connectSid);
-    }
-  });
-
-  it('Duplicate page by generated tag', () => {
-    const tag = 'we';
-    cy.visit('/');
-    cy.screenshot(`${ssPrefix}visit-home`, {capture: 'viewport'});
-
-    cy.get('#grw-subnav-container').within(()=>{
-      cy.get('a[href*="/_search?q=tag"]').contains(tag).click()
-    });
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
-  });
-
-});

+ 0 - 87
packages/app/test/cypress/integration/70-tag/rename-page.spec.ts

@@ -1,87 +0,0 @@
-/* eslint-disable cypress/no-unnecessary-waiting */
-context('Rename page from generated tag', () => {
-  const ssPrefix = 'rename-page-';
-
-  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;
-    });
-  });
-
-  beforeEach(() => {
-    if (connectSid != null) {
-      cy.setCookie('connect.sid', connectSid);
-    }
-  });
-
-  it('Rename page from generated tag', () => {
-    const tag = 'we';
-    const oldPageName = '/our';
-    const newPageName = '/ourus';
-
-    // Visit home
-    cy.visit('/');
-    cy.screenshot(`${ssPrefix}visit-home`, {capture: 'viewport'});
-
-    // Click tag that contain "we"
-    cy.get('#grw-subnav-container').within(()=>{
-      cy.get('a[href*="/_search?q=tag"]').contains(tag).click()
-    });
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
-
-    cy.getByTestid('search-result-list').should('be.visible');
-
-    // Click three dot menu on item that contain /our
-    cy.getByTestid('search-result-list').within(() => {
-      cy.get('.list-group-item').each(($row) => {
-        if($row.find('a').text() === oldPageName){
-          cy.wrap($row).within(() => {
-            cy.getByTestid('open-page-item-control-btn').click();
-          })
-        }
-      })
-    })
-    cy.screenshot(`${ssPrefix}click-three-dots-menu`, {capture: 'viewport'});
-
-    cy.getByTestid('search-result-list').within(() => {
-      cy.get('.list-group-item').each(($row) => {
-        if($row.find('a').text() === oldPageName){
-          cy.wrap($row).within(() => {
-            cy.getByTestid('move-page').click({force: true});
-            cy.wait(1500);
-          });
-        }
-      });
-    });
-
-    // Rename page
-    cy.get('.grw-rename-page').should('be.visible');
-    cy.get('.grw-rename-page').within(() => {
-      cy.getByTestid('new-page-name-input').clear({force: true})
-      cy.getByTestid('new-page-name-input').click().focused().type(newPageName, {force: true})
-      .should('have.value', newPageName);
-
-    });
-    cy.screenshot(`${ssPrefix}insert-new-page-name`, {capture: 'viewport'});
-
-    // Submit new name
-    cy.get('.grw-rename-page').within(() => {
-      cy.getByTestid('new-page-name-input').click({force: true});
-      cy.getByTestid('rename-page-button').click({force: true})
-      cy.wait(1500);
-    });
-    cy.screenshot(`${ssPrefix}new-page-name-applied`, {capture: 'viewport'});
-
-    //Visit /ourus
-    cy.visit(newPageName);
-    cy.screenshot(`${ssPrefix}visit-ourus-page`, {capture: 'viewport'});
-  });
-
-});

+ 0 - 66
packages/app/test/cypress/integration/70-tag/tag-order.spec.ts

@@ -1,66 +0,0 @@
-/* eslint-disable cypress/no-unnecessary-waiting */
-context('Tag order', () => {
-  const ssPrefix = 'tag-order-';
-
-  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;
-    });
-  });
-
-  beforeEach(() => {
-    if (connectSid != null) {
-      cy.setCookie('connect.sid', connectSid);
-    }
-  });
-
-  it('Tag order', () => {
-    const tag = 'we';
-
-    // Visit home
-    cy.visit('/');
-    cy.screenshot(`${ssPrefix}visit-home`, {capture: 'viewport'});
-
-    // Click tag that contain "we"
-     cy.get('#grw-subnav-container').within(()=>{
-      cy.get('a[href*="/_search?q=tag"]').contains(tag).click();
-    });
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}click-tag-name`, {capture: 'viewport'});
-
-
-    // Order by relevance
-    cy.get('.grw-search-page-nav').within(() => {
-      cy.get('.search-sort-option-btn').click({force: true});
-      cy.get('.dropdown-menu-right').should('be.visible');
-      cy.get('.dropdown-menu-right > button:nth-child(1)').click({force: true});
-      cy.wait(1000);
-    });
-    cy.screenshot(`${ssPrefix}order-by-relevance`);
-
-    // Order by creation date
-     cy.get('.grw-search-page-nav').within(() => {
-      cy.get('.search-sort-option-btn').click({force: true});
-      cy.get('.dropdown-menu-right').should('be.visible');
-      cy.get('.dropdown-menu-right > button:nth-child(2)').click({force: true});
-      cy.wait(1000);
-    });
-    cy.screenshot(`${ssPrefix}order-by-creation-date`);
-
-     // Order by last update date
-     cy.get('.grw-search-page-nav').within(() => {
-      cy.get('.search-sort-option-btn').click({force: true});
-      cy.get('.dropdown-menu-right').should('be.visible');
-      cy.get('.dropdown-menu-right > button:nth-child(3)').click({force: true});
-      cy.wait(1000);
-    });
-    cy.screenshot(`${ssPrefix}order-by-last-update-date`);
-  });
-
-});