<commit_before>import commonFeatures from './common';
import PersonalInformationFormatter from '../../src/lib/personal-information-formatter-service';
import CommunicationMethodsFormatter from '../../src/lib/communication-methods-formatter';
const { buildResponse, FeatureTestStates, setupChatbot, QuickReplies } = commonFeatures;

const SESSION = 'COMMUNICATION_METHODS_TESTER';

describe('Communication methods tests', function() {
  describe(
    'As a registered user I want to provide my acceptable methods of communication with quick replies',
    function() {
      before(function() {
        setupChatbot(this, 'COMMUNICATION_METHODS_TESTS');
      });

      it(
        'should ask for my Skype username when I choose Skype as a communication method',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Skype'))
            .to.eventually.become([
              buildResponse('@REQUEST_SKYPE_NAME'),
            ]);
        }
      );

      it(
        'should ask if the user wants to add more methods',
        function() {
          return expect(
              this.bot.receive(SESSION, 'nickname'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    SKYPE: 'nickname'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it('should give me options of communications methods when I say Lisää',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Lisää'))
            .to.eventually.become([
              buildResponse('@REQUEST_COMMUNICATION_METHOD',
                CommunicationMethodsFormatter
                .getCommunicationMethods({})),
            ]);
        }
      );

      it(
        'should ask for my phone number when I choose phone as a communication method',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Puhelin'))
            .to.eventually.become([
              buildResponse('@REQUEST_PHONE_NUMBER')
            ]);
        }
      );

      it(
        'should go back to asking for more communication methods after adding one',
        function() {
          return expect(
              this.bot.receive(SESSION, '040404'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    SKYPE: 'nickname',
                    PHONE: '040404'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it(
        'should go to removing when user wants it to',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Poista'))
            .to.eventually.become([
              buildResponse('@REQUEST_COMMUNICATION_METHOD_DELETE', [{
                'title': 'Skype',
                'payload': 'SKYPE',
              }, {
                'title': 'Puhelin',
                'payload': 'PHONE',
              }, {
                'title': 'Palaa',
                'payload': '@RETURN',
              }]),
            ]);
        }
      );

      it(
        'should go back to asking when a communication method is removed',
        function() {
          return expect(
              this.bot.receive(SESSION, 'SKYPE'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    PHONE: '040404'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it(
        'should go to profile',
        function() {
          return expect(
            this.bot.receive(SESSION, 'Profiiliin'))
            .to.eventually.become([
              buildResponse(
                PersonalInformationFormatter.formatFromTemplate(
                  '@DISPLAY_PROFILE', FeatureTestStates['COMMUNICATION_METHODS_TESTS']['sessions'][SESSION]),
                PersonalInformationFormatter.getPersonalInformationbuttons(
                  {})),
            ]);
        }
      );
    }
  );<commit_msg>name change tested<commit_after>import commonFeatures from './common';
import PersonalInformationFormatter from '../../src/lib/personal-information-formatter-service';
import CommunicationMethodsFormatter from '../../src/lib/communication-methods-formatter';
const { buildResponse, FeatureTestStates, setupChatbot, QuickReplies } = commonFeatures;

const SESSION = 'COMMUNICATION_METHODS_TESTER';

describe('Communication methods tests', function() {
  describe(
    'As a registered user I want to provide my acceptable methods of communication with quick replies',
    function() {
      before(function() {
        setupChatbot(this, 'COMMUNICATION_METHODS_TESTS');
      });

      it(
        'should ask for my Skype username when I choose Skype as a communication method',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Skype'))
            .to.eventually.become([
              buildResponse('@REQUEST_SKYPE_NAME'),
            ]);
        }
      );

      it(
        'should ask if the user wants to add more methods',
        function() {
          return expect(
              this.bot.receive(SESSION, 'nickname'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    SKYPE: 'nickname'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it('should give me options of communications methods when I say Lisää',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Lisää'))
            .to.eventually.become([
              buildResponse('@REQUEST_COMMUNICATION_METHOD',
                CommunicationMethodsFormatter
                .getCommunicationMethods({})),
            ]);
        }
      );

      it(
        'should ask for my phone number when I choose phone as a communication method',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Puhelin'))
            .to.eventually.become([
              buildResponse('@REQUEST_PHONE_NUMBER')
            ]);
        }
      );

      it(
        'should go back to asking for more communication methods after adding one',
        function() {
          return expect(
              this.bot.receive(SESSION, '040404'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    SKYPE: 'nickname',
                    PHONE: '040404'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it(
        'should go to removing when user wants it to',
        function() {
          return expect(
              this.bot.receive(SESSION, 'Poista'))
            .to.eventually.become([
              buildResponse('@REQUEST_COMMUNICATION_METHOD_DELETE', [{
                'title': 'Skype',
                'payload': 'SKYPE',
              }, {
                'title': 'Puhelin',
                'payload': 'PHONE',
              }, {
                'title': 'Palaa',
                'payload': '@RETURN',
              }]),
            ]);
        }
      );

      it(
        'should go back to asking when a communication method is removed',
        function() {
          return expect(
              this.bot.receive(SESSION, 'SKYPE'))
            .to.eventually.become([
              buildResponse(PersonalInformationFormatter.formatFromTemplate(
                '@CONFIRM_COMMUNICATION_METHODS', {
                  communicationMethods: {
                    PHONE: '040404'
                  }
                })),
              buildResponse('@PROVIDE_OTHER_COMMUNICATION_METHODS', [{
                'title': 'Lisää',
                'payload': '@EDIT',
              }, {
                'title': 'Poista',
                'payload': '@DELETE',
              }, {
                'title': 'Profiiliin',
                'payload': '@TO_PROFILE',
              }]),
            ]);
        }
      );

      it(
        'should go to profile',
        function() {
          return expect(
            this.bot.receive(SESSION, 'Profiiliin'))
            .to.eventually.become([
              buildResponse(
                PersonalInformationFormatter.formatFromTemplate(
                  '@DISPLAY_PROFILE', FeatureTestStates['COMMUNICATION_METHODS_TESTS']['sessions'][SESSION]),
                PersonalInformationFormatter.getPersonalInformationbuttons(
                  {})),
            ]);
        }
      );

      it('should allow changing name', function() {
          return expect(this.bot.receive(SESSION, '<NAME>'))
            .to.eventually.become([
              buildResponse('@REQUEST_NAME'),
            ]);
          }
      );

      it('should not accept too long name', function() {
        return expect(this.bot.receive(SESSION, Array(51).fill('a').join('')))
          .to.eventually.become([
            buildResponse('@TOO_LONG_NAME'),
            buildResponse('@REQUEST_NAME'),
          ]);
        }
      );

      it('should accept not too long name', function() {
        return expect(this.bot.receive(SESSION, Array(50).fill('a').join('')))
          to.eventually.become([
            buildResponse(
              PersonalInformationFormatter.formatFromTemplate(
                '@DISPLAY_PROFILE', FeatureTestStates['COMMUNICATION_METHODS_TESTS']['sessions'][SESSION]),
              PersonalInformationFormatter.getPersonalInformationbuttons({})),
          ]);
        }
      );
  });
{'fraction_non_alphanumeric': 0.11724953539449232, 'fraction_numerical': 0.0033789491468153403, 'mean_word_length': 1.4987336428872942, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6873505', 'n_tokens_mistral': 3045, 'n_tokens_neox': 2870, 'n_words': 571}