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

add cypress test for share link

Yuki Takei 3 лет назад
Родитель
Сommit
d1732cfaa5

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

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

+ 1 - 0
packages/app/src/components/ShareLink/ShareLink.tsx

@@ -64,6 +64,7 @@ const ShareLink = (): JSX.Element => {
           className="btn btn-outline-secondary d-block mx-auto px-5"
           type="button"
           onClick={toggleShareLinkFormHandler}
+          data-testid="btn-sharelink-toggleform"
         >
           {isOpenShareLinkForm ? t('Close') : t('New')}
         </button>

+ 1 - 1
packages/app/src/components/ShareLink/ShareLinkForm.tsx

@@ -199,7 +199,7 @@ export const ShareLinkForm: FC<Props> = (props: Props) => {
             />
           </div>
         </div>
-        <button type="button" className="btn btn-primary d-block mx-auto px-5" onClick={handleIssueShareLink}>
+        <button type="button" className="btn btn-primary d-block mx-auto px-5" onClick={handleIssueShareLink} data-testid="btn-sharelink-issue">
           {t('share_links.Issue')}
         </button>
       </div>

+ 59 - 0
packages/app/test/cypress/integration/22-sharelink/22-sharelink--access-to-sharelink.spec.ts

@@ -0,0 +1,59 @@
+context('Access to sharelink by guest', () => {
+  const ssPrefix = 'access-to-sharelink-by-guest-';
+
+  let createdSharelinkId: string;
+
+  it('Prepare sharelink', () => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    cy.visit('/Sandbox/Bootstrap4');
+
+    // open dropdown
+    cy.waitUntil(() => {
+      // do
+      cy.getByTestid('grw-contextual-sub-nav').should('be.visible').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').first().as('btn').click();
+      });
+      // wait until
+      return cy.get('body').within(() => {
+        return Cypress.$('.dropdown-menu.show').is(':visible');
+      });
+    });
+
+    // open modal
+    cy.get('.dropdown-menu.show').should('be.visible').within(() => {
+      cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click({force: true});
+    });
+    cy.waitUntilSpinnerDisappear();
+    cy.getByTestid('page-accessories-modal').should('be.visible');
+    cy.getByTestid('share-link-management').should('be.visible');
+
+    // create share link
+    cy.getByTestid('share-link-management').within(() => {
+      cy.getByTestid('btn-sharelink-toggleform').should('be.visible').click();
+      cy.getByTestid('btn-sharelink-issue').should('be.visible').click();
+
+      // store id
+      cy.get('tbody > tr > td > div > span').first().then((elem) => {
+        createdSharelinkId = elem.text();
+      });
+    });
+
+    cy.getByTestid('page-accessories-modal').within(() => { cy.screenshot(`${ssPrefix}-sharelink-created`) });
+  });
+
+  it('The sharelink page is successfully loaded', () => {
+    cy.visit(`/share/${createdSharelinkId}`);
+
+    cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
+    cy.get('.wiki').should('be.visible');
+
+    cy.waitUntilSkeletonDisappear();
+    cy.screenshot(`${ssPrefix}-access-to-sharelink`);
+  });
+
+});
+
+