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

Merge pull request #5640 from weseek/imprv/vrt-efficiency

support: Improve VRT efficiency
Yuki Takei 4 лет назад
Родитель
Сommit
2c773485ba

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

@@ -185,7 +185,7 @@ jobs:
       fail-fast: false
       matrix:
         # List string expressions that is comma separated ids of tests in "test/cypress/integration"
-        spec-group: ['1', '2', '3']
+        spec-group: ['1', '2', '3', '4']
 
     services:
       mongodb:

+ 0 - 34
packages/app/test/cypress/integration/2-basic-features/access-to-me-page.spec.ts

@@ -1,34 +0,0 @@
-context('Access to /me page', () => {
-  const ssPrefix = 'access-to-me-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;
-    });
-    // collapse sidebar
-    cy.collapseSidebar(true);
-  });
-
-  beforeEach(() => {
-    if (connectSid != null) {
-      cy.setCookie('connect.sid', connectSid);
-    }
-  });
-
-  it('/me is successfully loaded', () => {
-    cy.visit('/me', {  });
-    cy.screenshot(`${ssPrefix}-me`);
-  });
-
-  it('Draft page is successfully shown', () => {
-    cy.visit('/me/drafts');
-    cy.screenshot(`${ssPrefix}-draft-page`);
-  });
-
-});

+ 61 - 12
packages/app/test/cypress/integration/2-basic-features/access-to-page.spec.ts

@@ -2,26 +2,15 @@
 context('Access to page', () => {
   const ssPrefix = 'access-to-page-';
 
-  let connectSid: string | undefined;
-
-  before(() => {
+  beforeEach(() => {
     // 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('/Sandbox is successfully loaded', () => {
     cy.visit('/Sandbox', {  });
     cy.screenshot(`${ssPrefix}-sandbox`);
@@ -50,3 +39,63 @@ context('Access to page', () => {
   });
 
 });
+
+
+context('Access to /me page', () => {
+  const ssPrefix = 'access-to-me-page-';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    // collapse sidebar
+    cy.collapseSidebar(true);
+  });
+
+  it('/me is successfully loaded', () => {
+    cy.visit('/me', {  });
+    cy.screenshot(`${ssPrefix}-me`);
+  });
+
+  it('Draft page is successfully shown', () => {
+    cy.visit('/me/drafts');
+    cy.screenshot(`${ssPrefix}-draft-page`);
+  });
+
+});
+
+
+
+context('Access to special pages', () => {
+  const ssPrefix = 'access-to-special-pages-';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    // collapse sidebar
+    cy.collapseSidebar(true);
+  });
+
+  it('/trash is successfully loaded', () => {
+    cy.visit('/trash', {  });
+    cy.getByTestid('trash-page-list').should('be.visible');
+    cy.screenshot(`${ssPrefix}-trash`);
+  });
+
+  it('/tags is successfully loaded', () => {
+    cy.visit('/tags');
+
+    // open sidebar
+    cy.collapseSidebar(false);
+    // select tags
+    cy.getByTestid('grw-sidebar-nav-primary-tags').click();
+    cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
+
+    cy.getByTestid('tags-page').should('be.visible');
+    cy.screenshot(`${ssPrefix}-tags`);
+  });
+
+});

+ 0 - 44
packages/app/test/cypress/integration/2-basic-features/access-to-special-page.spec.ts

@@ -1,44 +0,0 @@
-
-context('Access to special pages', () => {
-  const ssPrefix = 'access-to-special-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('/trash is successfully loaded', () => {
-    cy.visit('/trash', {  });
-    cy.getByTestid('trash-page-list').should('be.visible');
-    cy.screenshot(`${ssPrefix}-trash`);
-  });
-
-  it('/tags is successfully loaded', () => {
-    cy.visit('/tags');
-
-    // open sidebar
-    cy.collapseSidebar(false);
-    // select tags
-    cy.getByTestid('grw-sidebar-nav-primary-tags').click();
-    cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
-
-    cy.getByTestid('tags-page').should('be.visible');
-    cy.screenshot(`${ssPrefix}-tags`);
-  });
-
-});

+ 0 - 37
packages/app/test/cypress/integration/2-basic-features/open-page-create-modal.spec.ts

@@ -1,37 +0,0 @@
-context('Open PageCreateModal', () => {
-
-  const ssPrefix = 'open-page-create-modal-';
-
-  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("PageCreateModal is shown successfully", () => {
-    cy.getByTestid('newPageBtn').click();
-
-    cy.getByTestid('page-create-modal').should('be.visible').screenshot(`${ssPrefix}-open`);
-
-    cy.getByTestid('row-create-page-under-below').find('input.form-control').clear().type('/new-page');
-    cy.getByTestid('btn-create-page-under-below').click();
-
-    cy.getByTestid('page-editor').should('be.visible');
-    cy.screenshot(`${ssPrefix}-create-clicked`, {capture: 'viewport'});
-  });
-
-});

+ 0 - 36
packages/app/test/cypress/integration/2-basic-features/open-page-delete-modal.spec.ts

@@ -1,36 +0,0 @@
-context('Open Page Delete Modal', () => {
-
-  const ssPrefix = 'access-to-page-delete-modal-';
-
-  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('PageDeleteModal is shown successfully', () => {
-     cy.visit('/Sandbox/Bootstrap4', {  });
-     cy.get('#grw-subnav-container').within(() => {
-       cy.getByTestid('open-page-item-control-btn').click();
-       cy.getByTestid('open-page-delete-modal-btn').click();
-    });
-
-     cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-open-bootstrap4`);
-  });
-
-});
-

+ 0 - 34
packages/app/test/cypress/integration/2-basic-features/open-page-duplicate-modal.spec.ts

@@ -1,34 +0,0 @@
-context('Open Page Duplicate Modal', () => {
-
-  const ssPrefix = 'access-to-page-duplicate-modal-';
-
-  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('PageDuplicateModal is shown successfully', () => {
-     cy.visit('/Sandbox/Bootstrap4', {  });
-     cy.get('#grw-subnav-container').within(() => {
-       cy.getByTestid('open-page-item-control-btn').click();
-       cy.getByTestid('open-page-duplicate-modal-btn').click();
-    });
-     cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-open-bootstrap4`);
-  });
-
-});

+ 0 - 35
packages/app/test/cypress/integration/2-basic-features/open-page-move-rename-modal.spec.ts

@@ -1,35 +0,0 @@
-context('Open Page Move Rename Modal', () => {
-
-  const ssPrefix = 'access-to-page-move-rename-modal';
-
-  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('PageMoveRenameModal is shown successfully', () => {
-     cy.visit('/Sandbox/Bootstrap4', {  });
-     cy.get('#grw-subnav-container').within(() => {
-       cy.getByTestid('open-page-item-control-btn').click();
-       cy.getByTestid('open-page-move-rename-modal-btn').click();
-    });
-
-     cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-open-bootstrap4`);
-  });
-
-});

+ 0 - 61
packages/app/test/cypress/integration/2-basic-features/open-presentation-modal.spec.ts

@@ -1,61 +0,0 @@
-context('Open presentation modal', () => {
-
-  const ssPrefix = 'access-to-presentation-modal-';
-
-  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('PresentationModal for "/" is shown successfully', () => {
-    cy.visit('/');
-
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-      cy.getByTestid('open-presentation-modal-btn').click({force: true});
-    });
-
-    // eslint-disable-next-line cypress/no-unnecessary-waiting
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}-opne-top`);
-  });
-
-  it('PresentationModal for "/Sandbox/Bootstrap4" is shown successfully', () => {
-    cy.visit('/Sandbox/Bootstrap4');
-
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-      cy.getByTestid('open-presentation-modal-btn').click({force: true});
-    });
-
-    // eslint-disable-next-line cypress/no-unnecessary-waiting
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}-open-bootstrap4`);
-  });
-
-  it('PresentationModal for /Sandbox/Bootstrap4#Cards" is shown successfully', () => {
-    cy.visit('/Sandbox/Bootstrap4#Cards');
-
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-      cy.getByTestid('open-presentation-modal-btn').click({force: true});
-    });
-
-    // eslint-disable-next-line cypress/no-unnecessary-waiting
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}-open-bootstrap4-with-ancker-link`);
-  });
-});

+ 0 - 31
packages/app/test/cypress/integration/2-basic-features/switch-sidebar-contents.spec.ts

@@ -1,31 +0,0 @@
-context('Access to page', () => {
-  const ssPrefix = 'switch-sidebar-content';
-
-  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('PageTree is successfully shown', () => {
-    cy.visit('/');
-    cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
-    cy.screenshot(`${ssPrefix}-pagetree-before-load`, { capture: 'viewport' });
-    // eslint-disable-next-line cypress/no-unnecessary-waiting
-    cy.wait(1500);
-    cy.screenshot(`${ssPrefix}-pagetree-after-load`, { capture: 'viewport' });
-  });
-
-});

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

@@ -0,0 +1,121 @@
+context('Switch Sidebar content', () => {
+  const ssPrefix = 'switch-sidebar-content';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+  });
+
+  it('PageTree is successfully shown', () => {
+    cy.visit('/page');
+    cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
+    cy.screenshot(`${ssPrefix}-pagetree-before-load`, { capture: 'viewport' });
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(1500);
+    cy.screenshot(`${ssPrefix}-pagetree-after-load`, { capture: 'viewport' });
+  });
+
+});
+
+
+context('Modal for page operation', () => {
+
+  const ssPrefix = 'modal-for-page-operation-';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+  });
+
+  it("PageCreateModal is shown successfully", () => {
+    cy.visit('/me');
+
+    cy.getByTestid('newPageBtn').click();
+
+    cy.getByTestid('page-create-modal').should('be.visible').screenshot(`${ssPrefix}-open`);
+
+    cy.getByTestid('row-create-page-under-below').find('input.form-control').clear().type('/new-page');
+    cy.getByTestid('btn-create-page-under-below').click();
+
+    cy.getByTestid('page-editor').should('be.visible');
+    cy.screenshot(`${ssPrefix}-create-clicked`, {capture: 'viewport'});
+  });
+
+  it('PageDeleteModal is shown successfully', () => {
+    cy.visit('/Sandbox/Bootstrap4');
+
+     cy.get('#grw-subnav-container').within(() => {
+       cy.getByTestid('open-page-item-control-btn').click();
+       cy.getByTestid('open-page-delete-modal-btn').click();
+    });
+
+     cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
+  });
+
+  it('PageDuplicateModal is shown successfully', () => {
+    cy.visit('/Sandbox/Bootstrap4', {  });
+
+    cy.get('#grw-subnav-container').within(() => {
+      cy.getByTestid('open-page-item-control-btn').click();
+      cy.getByTestid('open-page-duplicate-modal-btn').click();
+    });
+
+    cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
+  });
+
+  it('PageMoveRenameModal is shown successfully', () => {
+    cy.visit('/Sandbox/Bootstrap4', {  });
+
+    cy.get('#grw-subnav-container').within(() => {
+      cy.getByTestid('open-page-item-control-btn').click();
+      cy.getByTestid('open-page-move-rename-modal-btn').click();
+    });
+
+    cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
+  });
+
+});
+
+
+context('Open presentation modal', () => {
+
+  const ssPrefix = 'access-to-presentation-modal-';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+  });
+
+  it('PresentationModal for "/" is shown successfully', () => {
+    cy.visit('/');
+
+    cy.get('#grw-subnav-container').within(() => {
+      cy.getByTestid('open-page-item-control-btn').click({force: true});
+      cy.getByTestid('open-presentation-modal-btn').click({force: true});
+    });
+
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(1500);
+    cy.screenshot(`${ssPrefix}-open-top`);
+  });
+
+  it('PresentationModal for "/Sandbox/Bootstrap4" is shown successfully', () => {
+    cy.visit('/Sandbox/Bootstrap4');
+
+    cy.get('#grw-subnav-container').within(() => {
+      cy.getByTestid('open-page-item-control-btn').click({force: true});
+      cy.getByTestid('open-presentation-modal-btn').click({force: true});
+    });
+
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(1500);
+    cy.screenshot(`${ssPrefix}-open-bootstrap4`);
+  });
+
+});

+ 0 - 32
packages/app/test/cypress/integration/3-search/access-to-private-legacy-pages-directly.spec.ts

@@ -1,32 +0,0 @@
-context('Access to legacy private pages directly', () => {
-  const ssPrefix = 'access-to-legacy-private-pages-directly-';
-
-  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('/_private-legacy-pages is successfully loaded', () => {
-    cy.visit('/_private-legacy-pages');
-
-    cy.getByTestid('search-result-base').should('be.visible');
-
-    cy.screenshot(`${ssPrefix}-shown`);
-  });
-
-});

+ 26 - 13
packages/app/test/cypress/integration/3-search/access-to-result-page-directly.spec.ts → packages/app/test/cypress/integration/3-search/search.spec.ts

@@ -1,26 +1,15 @@
-context('Access to search result page directly', () => {
+context('Access to search result page', () => {
   const ssPrefix = 'access-to-result-page-directly-';
 
-  let connectSid: string | undefined;
-
-  before(() => {
+  beforeEach(() => {
     // 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 with "q" param is successfully loaded', () => {
     cy.visit('/_search', { qs: { q: 'labels alerts cards blocks' } });
 
@@ -53,3 +42,27 @@ context('Access to search result page directly', () => {
   });
 
 });
+
+
+
+context('Access to legacy private pages', () => {
+  const ssPrefix = 'access-to-legacy-private-pages-directly-';
+
+  beforeEach(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    // collapse sidebar
+    cy.collapseSidebar(true);
+  });
+
+  it('/_private-legacy-pages is successfully loaded', () => {
+    cy.visit('/_private-legacy-pages');
+
+    cy.getByTestid('search-result-base').should('be.visible');
+
+    cy.screenshot(`${ssPrefix}-shown`);
+  });
+
+});

+ 1 - 13
packages/app/test/cypress/integration/2-basic-features/access-to-admin-page.spec.ts → packages/app/test/cypress/integration/4-admin/access-to-admin-page.spec.ts

@@ -15,25 +15,13 @@ const adminMenues = [
 context('Access to Admin page', () => {
   const ssPrefix = 'access-to-admin-page-';
 
-  let connectSid: string | undefined;
-
-  before(() => {
+  beforeEach(() => {
     // 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('/admin is successfully loaded', () => {
     cy.visit('/admin');
     cy.getByTestid('admin-home').should('be.visible');

+ 11 - 3
packages/app/test/cypress/support/commands.ts

@@ -31,18 +31,24 @@ Cypress.Commands.add('getByTestid', (selector, options?) => {
 
 Cypress.Commands.add('login', (username, password) => {
   cy.session(username, () => {
-    cy.visit('/login');
+    cy.visit('/page-to-return-after-login');
     cy.getByTestid('tiUsernameForLogin').type(username);
     cy.getByTestid('tiPasswordForLogin').type(password);
     cy.getByTestid('btnSubmitForLogin').click();
   });
 });
 
+let isSidebarCollapsed: boolean | undefined;
+
 Cypress.Commands.add('collapseSidebar', (isCollapsed) => {
-  const isGrowiPage = Cypress.$('body.growi').length > 0;
 
+  if (isSidebarCollapsed === isCollapsed) {
+    return;
+  }
+
+  const isGrowiPage = Cypress.$('body.growi').length > 0;
   if (!isGrowiPage) {
-    cy.visit('/');
+    cy.visit('/page-to-toggle-sidebar-collapsed');
   }
 
   cy.getByTestid('grw-contextual-navigation-sub').then(($contents) => {
@@ -56,4 +62,6 @@ Cypress.Commands.add('collapseSidebar', (isCollapsed) => {
       cy.wait(1500);
     }
   });
+
+  isSidebarCollapsed = isCollapsed;
 });