Commit 6278cb77 authored by Marcelo Rivera's avatar Marcelo Rivera
Browse files

Merge remote-tracking branch 'upstream/master' into...

Merge remote-tracking branch 'upstream/master' into sprint/GiddyGiraffe.feat.ability-for-channels-to-self-declare-nsfw
parents 57de27eb 5a986430
Loading
Loading
Loading
Loading
+101 −11
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ services:
stages:
stages:
  - test
  - test
  - build
  - build
  - prepare
  - deploy
  - deploy


test:
test:
@@ -15,7 +16,24 @@ test:
    - npm install # Should be cached...
    - npm install # Should be cached...
    - npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
    - npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI


build:
build:review:
  stage: build
  script:
    - npm install # TODO: Why is this needed?
    - npm run postinstall
    - npm install -g gulp-cli
    - gulp build.sass && gulp build.sass ##weird build needs to be run twice for now
    - sh build/base-locale.sh dist
  artifacts:
    name: "$CI_COMMIT_REF_SLUG"
    paths:
      - dist
  except:
    refs:
      - master
      - test/gitlab-ci

build:production:en:
  stage: build
  stage: build
  script:
  script:
    - npm install # TODO: Why is this needed?
    - npm install # TODO: Why is this needed?
@@ -23,30 +41,102 @@ build:
    - npm install -g gulp-cli
    - npm install -g gulp-cli
    - gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en && gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en ##weird build needs to be run twice for now
    - gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en && gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en ##weird build needs to be run twice for now
    - sh build/base-locale.sh dist https://cdn-assets.minds.com/front/dist
    - sh build/base-locale.sh dist https://cdn-assets.minds.com/front/dist
  artifacts:
    name: "$CI_COMMIT_REF_SLUG"
    paths:
      - dist/en
  only:
    refs:
      - master
      - test/gitlab-ci

build:production:i18n:
  stage: build
  script:
    - npm install # TODO: Why is this needed?
    - npm run postinstall
    - npm install -g gulp-cli
    - gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en && gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en ##weird build needs to be run twice for now
    - sh build/i18n-locales-all.sh dist https://cdn-assets.minds.com/front/dist
    - sh build/i18n-locales-all.sh dist https://cdn-assets.minds.com/front/dist
  cache:
  artifacts:
    name: "$CI_COMMIT_REF_SLUG"
    paths:
    paths:
      - dist
      - dist/vi
    policy: push
  only:
  only:
    refs:
    refs:
      - master
      - master
      - test/gitlab-ci
      - test/gitlab-ci


deploy:
prepare:
  stage: prepare
  image: minds/ci:latest
  script:
    - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} 
    - docker build -t $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF -f containers/front-init/Dockerfile dist/.
    - docker push $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF
  dependencies:
    - build:review
  except:
    refs:
      - master
      - test/gitlab-ci

deploy:review:
  stage: deploy
  stage: deploy
  image: minds/helm-eks:latest
  script:
    - aws eks update-kubeconfig --name=sandbox
    - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git
    - "helm upgrade \
        --install \
        --reuse-values \
        --set frontInit.image.repository=$CI_REGISTRY_IMAGE/front-init \
        --set frontInit.image.tag=$CI_BUILD_REF \
        --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \
        --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG--elasticsearch \
        --wait \
        $CI_BUILD_REF_SLUG \
        ./helm-charts/minds"
  environment:
    name: review/$CI_COMMIT_REF_NAME
    url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
    on_stop: deploy:review:stop
  except: 
    refs:
      - master
      - test/gitlab-ci

deploy:review:stop:
  stage: deploy
  image: minds/helm-eks:latest
  script:
    - aws eks update-kubeconfig --name=sandbox
    - helm del --purge $CI_BUILD_REF_SLUG
  environment:
    name: review/$CI_COMMIT_REF_NAME
    url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
    action: stop
  variables:
    GIT_STRATEGY: none
  when: manual
  except: 
    refs:
      - master
      - test/gitlab-ci


deploy:production:
  stage: deploy
  image: minds/ci:latest
  script:
  script:
    - apk add --no-cache python py-pip
    - pip install awscli
    - aws s3 sync dist $REPOSITORY_URL
    - aws s3 sync dist $REPOSITORY_URL
    - aws ecs update-service --service=$SERVICE --force-new-deployment --region us-east-1 --cluster=$CLUSTER
    - aws ecs update-service --service=$SERVICE --force-new-deployment --region us-east-1 --cluster=$CLUSTER
  cache:
    paths:
      - dist
    policy: pull
  only:
  only:
    refs:
    refs:
      - master
      - master
      - test/gitlab-ci
      - test/gitlab-ci
  dependencies:
    - build:production:en
    - build:production:i18n
  environment:
  environment:
    name: production
    name: production
+6 −0
Original line number Original line Diff line number Diff line
FROM alpine:edge

COPY . dist

## Hack to make initial laguage load
COPY en/index.php dist/index.php
 No newline at end of file
+125 −0
Original line number Original line Diff line number Diff line
context('Discovery', () => {
  beforeEach(() => {
    cy.login(true);
    cy.location('pathname').should('eq', `/newsfeed/subscriptions`);
  });
  
  it('should allow a user to post on the discovery page', () => {
    cy.visit('/newsfeed/global/top');
    cy.post("test!!");
  });

  it('should be able to filter by hot', () => {
    cy.visit('/newsfeed/global/top');
    cy.get('.m-sort-selector--algorithm-dropdown ul > li:nth-child(1)')
      .click()
      .should('have.css', 'color', 'rgb(70, 144, 223)'); // selected color
    cy.url().should('include', '/hot');

  });

  it('should be able to filter by top', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--algorithm-dropdown ul > li:nth-child(2)')
      .click()
      .should('have.css', 'color', 'rgb(70, 144, 223)'); // selected color
    cy.url().should('include', '/top');
  }); 

  it('should be able to filter by time in the top feed', () => {
    cy.visit('/newsfeed/global/top');

    cy.get('.m-sort-selector--period-dropdown').click();
    cy.get('.m-sort-selector--period-dropdown ul > li:nth-child(5)').click();
    cy.url().should('include', '=1y');


    cy.get('.m-sort-selector--period-dropdown').click();
    cy.get('.m-sort-selector--period-dropdown ul > li:nth-child(4)').click();
    cy.url().should('include', '=30d');

    cy.get('.m-sort-selector--period-dropdown').click();
    cy.get('.m-sort-selector--period-dropdown ul > li:nth-child(3)').click();
    cy.url().should('include', '=7d');

    cy.get('.m-sort-selector--period-dropdown').click();
    cy.get('.m-sort-selector--period-dropdown ul > li:nth-child(2)').click();
    cy.url().should('include', '=24h');

    cy.get('.m-sort-selector--period-dropdown').click();
    cy.get('.m-sort-selector--period-dropdown ul > li:nth-child(1)').click();
    cy.url().should('include', '=12h');
  });

  it('should filter by latest', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--algorithm-dropdown ul > li:nth-child(3)')
      .click()
      .should('have.css', 'color', 'rgb(70, 144, 223)'); // selected color

    cy.get('.m-newsfeed__entity .m-owner-block a > span:nth-child(1)');
    cy.url().should('include', '/latest');
  }); 

  it('should filter by image', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(2)').click();
    cy.url().should('include', '=images');
  }); 
  
  it('should filter by video', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(3)').click();
    cy.url().should('include', '=videos');
  }); 
  
  it('should filter by blog', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(4)').click();
    cy.url().should('include', '=blog');
  }); 
  
  it('should filter by channels', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(5)').click();
    cy.url().should('include', '=channels');
  }); 
  
  it('should filter by groups', () => {
    cy.visit('/newsfeed/global/hot');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(6)').click();
    cy.url().should('include', '=groups');
  }); 

  it('should filter by all', () => {
    cy.visit('/newsfeed/global/top?type=images');
    cy.get('.m-sort-selector--custom-type-dropdown').click();
    cy.get('.m-sort-selector--custom-type-dropdown ul > li:nth-child(1)').click();
    cy.url().should('not.include', '=images');
  });

  it('should allow the user to toggle nsfw', () => {
    cy.visit('/newsfeed/global/top?type=images');
    cy.get('m-topbar--navigation--options').click();
    cy.get('m-topbar--navigation--options label > span').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(1)').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(2)').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(3)').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(4)').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(5)').click();
    cy.get('m-topbar--navigation--options ul > m-nsfw-selector ul > li:nth-child(6)').click();
  });  

  it('should allow the user to filter by a single hashtag', () => {
    cy.get('.m-hashtagsSidebarSelector__list > ul > li:nth-child(1) .m-hashtagsSidebarSelectorList__visibility > i').click();
  });

  it('should allow the user to turn off single hashtag filter and view all posts', () => {
    cy.get('.m-hashtagsSidebarSelector__list > ul > li:nth-child(1) .m-hashtagsSidebarSelectorList__visibility > i').click();
  })
})
 No newline at end of file
+137 −0
Original line number Original line Diff line number Diff line
context('Groups', () => {
  beforeEach(() => {
    cy.login(true);
  })

  it('should create and edit a group', () => {

    cy.get('m-group--sidebar-markers li:first-child').contains('New group').click();

    cy.location('pathname').should('eq', '/groups/create');

    // add a banner
    cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg');

    // add a name
    cy.get('.m-group-info-name > input').type('test');
    // add a description
    cy.get('.m-group-info-brief-description > textarea').type('This is a test');

    // click on hashtags dropdown
    cy.get('m-hashtags-selector .m-dropdown--label-container').click();
    // select #ART
    cy.get('m-hashtags-selector  m-dropdown m-form-tags-input > div:nth-child(1) > span').contains('#art').click();
    // type in another hashtag manually
    cy.get('m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click();
    // click away
    cy.get('m-hashtags-selector .minds-bg-overlay').click();

    cy.get('.m-groups-save > button').contains('Create').click();

    cy.wait(1000);

    cy.get('.m-groupInfo__name').contains('test');
    cy.get('.m-groupInfo__description').contains('This is a test');

    // open settings button
    cy.get('minds-groups-settings-button > button').click();

    cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Edit').click();

    // edit name
    cy.get('.m-groupInfo__name input').type(' group');

    // edit description
    cy.get('.m-groupInfo__description textarea').type(' group');

    // open settings button
    cy.get('minds-groups-settings-button > button').click();

    cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Save').click();

    cy.get('.m-groupInfo__name').contains('test group');
    cy.get('.m-groupInfo__description').contains('This is a test group');
  })

  it('should be able to toggle conversation and comment on it', () => {
    cy.get('m-group--sidebar-markers li:nth-child(2)').contains('test group').click();

    cy.wait(1000);

    // toggle the conversation
    cy.get('.m-groupGrid__right').should('be.visible');
    cy.get('.m-groupGrid__toggleBtn').click();
    cy.get('.m-groupGrid__right').should('not.be.visible');
    cy.get('.m-groupGrid__toggleBtn').click();

    // comment
    cy.get('minds-groups-profile-conversation m-comments__tree minds-textarea .m-editor').type('lvl 1 comment');
    cy.get('minds-groups-profile-conversation m-comments__tree a.m-post-button').click();

    cy.wait(500);

    // comment should appear on the list
    cy.get('minds-groups-profile-conversation m-comments__tree > m-comments__thread .m-commentBubble__message').contains('lvl 1 comment');

    // reply to the comment
    cy.get('minds-groups-profile-conversation m-comments__tree > m-comments__thread m-comment .m-clickable').contains('Reply').click();
    cy.get('minds-groups-profile-conversation m-comments__tree > m-comments__thread m-comment minds-textarea .m-editor').type('lvl 2 comment');
    cy.get('minds-groups-profile-conversation m-comments__tree > m-comments__thread m-comment a.m-post-button').click();


    // reply should appear
    cy.get('minds-groups-profile-conversation m-comments__tree > m-comments__thread m-comment m-comments__thread m-comment .m-commentBubble__message').contains('lvl 2 comment');

    cy.on('window:confirm', (str) => {
      return true;
    });
  })

  it('should post an activity inside the group and record the view when scrolling', () => {
    cy.get('m-group--sidebar-markers li:nth-child(2)').contains('test group').click();

    cy.wait(1000);

    cy.server();
    cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view");

    cy.get('minds-newsfeed-poster textarea').type('This is a post');

    cy.get('.m-posterActionBar__PostButton').click();

    cy.wait(500);

    // the activity should show that it was posted in this group
    cy.get('.minds-list minds-activity .body a:nth-child(2)').contains('(test group)');

    cy.get('.minds-list minds-activity .m-mature-message-content').contains('This is a post');

    // create the post
    cy.get('minds-newsfeed-poster textarea').type('This is a post that will record a view');

    cy.get('.m-posterActionBar__PostButton').click();

    cy.wait(200);

    cy.scrollTo(0, '20px');

    cy.wait('@view', { requestTimeout: 2000 }).then((xhr) => {
      expect(xhr.status).to.equal(200);
      expect(xhr.response.body).to.deep.equal({ status: 'success' });
    });
  });

  it('should delete a group', () => {
    cy.get('m-group--sidebar-markers li:nth-child(2)').contains('test group').click();

    cy.wait(1000);

    // cleanup
    cy.get('minds-groups-settings-button > button').click();
    cy.get('minds-groups-settings-button ul.minds-dropdown-menu > li:nth-child(8)').contains('Delete Group').click();
    cy.get('minds-groups-settings-button m-modal .mdl-button--raised').contains('Confirm').click();

    cy.location('pathname').should('eq', '/groups/member');
  })

})
+6 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ Cypress.Commands.add('uploadFile', (selector, fileName, type = '') => {
  cy.get(selector).then((subject) => {
  cy.get(selector).then((subject) => {
    cy.fixture(fileName, 'base64').then((content) => {
    cy.fixture(fileName, 'base64').then((content) => {
      const el = subject[0];
      const el = subject[0];
      const blob = b64toBlob(content, type);
      const blob = cy.visit('/newsfeed/global/top');b64toBlob(content, type);
      cy.window().then((win) => {
      cy.window().then((win) => {
        const testFile = new win.File([blob], fileName, { type });
        const testFile = new win.File([blob], fileName, { type });
        const dataTransfer = new DataTransfer();
        const dataTransfer = new DataTransfer();
@@ -52,6 +52,11 @@ Cypress.Commands.add('uploadFile', (selector, fileName, type = '') => {
  cy.get(selector).trigger('change', { force: true });
  cy.get(selector).trigger('change', { force: true });
});
});


Cypress.Commands.add('post', (message) => {
  cy.get('mwl-text-input-autocomplete-container textarea').type(message);
  cy.get('.m-posterActionBar__PostButton').click();
});

function b64toBlob(b64Data, contentType, sliceSize = 512) {
function b64toBlob(b64Data, contentType, sliceSize = 512) {
  const byteCharacters = atob(b64Data);
  const byteCharacters = atob(b64Data);
  const byteArrays = [];
  const byteArrays = [];
Loading