Browse Source

fix all tests for tag operation

Yohei-Shiina 3 years ago
parent
commit
4881f8088b

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

@@ -229,9 +229,14 @@ context('Tag Oprations', () =>{
   it('Successfully add new tag', () => {
   it('Successfully add new tag', () => {
     const ssPrefix = 'tag-operations-add-new-tag-'
     const ssPrefix = 'tag-operations-add-new-tag-'
     const tag = 'we';
     const tag = 'we';
-    cy.visit('/');
+    cy.visit('/Sandbox');
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.get('.grw-skelton').should('exist');
+    cy.get('.grw-skelton').should('not.exist');
 
 
-    cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
+    cy.get('#edit-tags-btn-wrapper-for-tooltip').should('exist').within(()=>{
+      cy.get('a').should('exist').click();
+    });
     cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
     cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
 
 
     cy.get('#edit-tag-modal').within(() => {
     cy.get('#edit-tag-modal').within(() => {
@@ -264,43 +269,46 @@ context('Tag Oprations', () =>{
     const ssPrefix = 'tag-operations-page-duplicate-';
     const ssPrefix = 'tag-operations-page-duplicate-';
     const tag = 'we';
     const tag = 'we';
     const newPageName = 'our';
     const newPageName = 'our';
-    cy.visit('/');
+    cy.visit('/Sandbox');
+    cy.waitSkeletonDisappear();
+
     cy.get('.grw-taglabels-container > .grw-tag-labels > a', { timeout: 10000 }).contains(tag).click();
     cy.get('.grw-taglabels-container > .grw-tag-labels > a', { timeout: 10000 }).contains(tag).click();
     cy.getByTestid('search-result-base').should('be.visible');
     cy.getByTestid('search-result-base').should('be.visible');
     cy.getByTestid('search-result-list').should('be.visible');
     cy.getByTestid('search-result-list').should('be.visible');
     cy.getByTestid('search-result-content').should('be.visible');
     cy.getByTestid('search-result-content').should('be.visible');
     // cy.get('#wiki').should('be.visible');
     // cy.get('#wiki').should('be.visible');
     // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
     // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
-    cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
+    cy.getByTestid('page-list-item-L').eq(1).invoke('addClass', 'active');
     cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
     cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
 
 
-    cy.getByTestid('open-page-item-control-btn').first().click({force: true});
+    cy.getByTestid('open-page-item-control-btn').eq(1).click({force: true});
     // eslint-disable-next-line cypress/no-unnecessary-waiting
     // eslint-disable-next-line cypress/no-unnecessary-waiting
     cy.wait(1500); // for wait rendering pagelist info
     cy.wait(1500); // for wait rendering pagelist info
     cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
     cy.screenshot(`${ssPrefix}2-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.getByTestid('open-page-duplicate-modal-btn').eq(1).click({force: true});
+    cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
+      cy.get('.rbt-input-main').type(`-${newPageName}`, {force: true});
     }).screenshot(`${ssPrefix}3-duplicate-page`, {capture: 'viewport'});
     }).screenshot(`${ssPrefix}3-duplicate-page`, {capture: 'viewport'});
 
 
     cy.getByTestid('page-duplicate-modal').within(() => {
     cy.getByTestid('page-duplicate-modal').within(() => {
       cy.get('.modal-footer > button.btn').click();
       cy.get('.modal-footer > button.btn').click();
     });
     });
-    cy.visit(`/${newPageName}`);
-    // cy.getByTestid('wiki').should('exist');
+    cy.visit(`Sandbox-${newPageName}`);
+    cy.waitSkeletonDisappear();
     cy.screenshot(`${ssPrefix}4-duplicated-page`, {capture: 'viewport'});
     cy.screenshot(`${ssPrefix}4-duplicated-page`, {capture: 'viewport'});
   });
   });
 
 
   it('Successfully rename page from generated tag', () => {
   it('Successfully rename page from generated tag', () => {
     const ssPrefix = 'tag-operations-page-rename-';
     const ssPrefix = 'tag-operations-page-rename-';
     const tag = 'we';
     const tag = 'we';
-    const oldPageName = '/our';
-    const newPageName = '/ourus';
+    const oldPageName = '/Sandbox-our';
+    const newPageName = '/Sandbox-us';
 
 
-    cy.visit('/');
-    cy.get('.grw-taglabels-container > .grw-tag-labels > a', { timeout: 10000 }).contains(tag).click();
+    cy.visit('/Sandbox-our');
+    cy.waitSkeletonDisappear();
+    cy.get('.grw-tag-label').contains(tag).click();
+    cy.waitSkeletonDisappear();
     cy.getByTestid('search-result-base').should('be.visible');
     cy.getByTestid('search-result-base').should('be.visible');
     cy.getByTestid('search-result-list').should('be.visible');
     cy.getByTestid('search-result-list').should('be.visible');
     cy.getByTestid('search-result-content').should('be.visible');
     cy.getByTestid('search-result-content').should('be.visible');
@@ -313,10 +321,12 @@ context('Tag Oprations', () =>{
         if($row.find('a').text() === oldPageName){
         if($row.find('a').text() === oldPageName){
           cy.wrap($row).within(() => {
           cy.wrap($row).within(() => {
             cy.getByTestid('open-page-item-control-btn').first().click();
             cy.getByTestid('open-page-item-control-btn').first().click();
-            cy.getByTestid('page-item-control-menu').should('have.class', 'show').first().within(() => {
+            cy.getByTestid('page-item-control-menu').should('have.class', 'show').first().then(($el) => {
               // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
               // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
               cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
               cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
-              cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
+              cy.wrap($el).within(()=>{
+                cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
+              })
             })
             })
           });
           });
         }
         }
@@ -341,8 +351,10 @@ context('Tag Oprations', () =>{
       cy.get('.modal-footer > button').click();
       cy.get('.modal-footer > button').click();
     });
     });
 
 
-    cy.visit(`/${newPageName}`);
-    cy.getByTestid('grw-tag-labels').should('be.visible');
+    cy.visit(`${newPageName}`);
+    cy.waitSkeletonDisappear();
+
+    cy.getByTestid('grw-tag-labels').should('be.visible')
     cy.screenshot(`${ssPrefix}4-new-page-name-applied`, {capture: 'viewport'});
     cy.screenshot(`${ssPrefix}4-new-page-name-applied`, {capture: 'viewport'});
   });
   });