<commit_before>asynctest(
  'Flow Keying Test',
 
  [
    'ephox.agar.api.FocusTools',
    'ephox.agar.api.Keyboard',
    'ephox.agar.api.Keys',
    'ephox.agar.api.Step',
    'ephox.alloy.api.GuiFactory',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.test.GuiSetup',
    'ephox.alloy.test.NavigationUtils',
    'ephox.compass.Arr'
  ],
 
  function (FocusTools, Keyboard, Keys, Step, GuiFactory, EventHandler, GuiSetup, NavigationUtils, Arr) {
    var success = arguments[arguments.length - 2];
    var failure = arguments[arguments.length - 1];

    GuiSetup.setup(function (store, doc, body) {
      var item = function (classes) {
        return {
          uiType: 'custom',
          dom: {
            tag: 'span',
            styles: {
              display: 'inline-block',
              width: '20px',
              height: '20px',
              margin: '2px',
              border: '1px solid ' + (Arr.contains(classes, 'stay') ? 'blue' : 'yellow')
            },
            classes: classes
          },
          events: {
            'alloy.execute': EventHandler.nu({
              run: store.adder('item.execute: ' + classes.join(','))
            })
          },
          focusing: true
        };
      };

      return GuiFactory.build({
        uiType: 'custom',
        dom: {
          tag: 'div',
          classes: [ 'flow-keying-test'],
          styles: {
            background: 'white',
            width: '200px',
            height: '200px'
          }
        },
        uid: 'custom-uid',
        keying: {
          mode: 'flow',
          selector: '.stay'
        },
        components: [
          item([ 'stay', 'one' ]),
          item([ 'stay', 'two' ]),
          item([ 'skip', 'three' ]),
          item([ 'skip', 'four' ]),
          item([ 'stay', 'five' ])
        ]
      });

    }, function (doc, body, gui, component, store) {

      var targets = {
        one: { label: 'one', selector: '.one' },
        two: { label: 'two', selector: '.two' },
        five: { label: 'five', selector: '.five' }
      };

      return [
        FocusTools.sSetFocus('Initial focus', gui.element(), '.one'),
        NavigationUtils.sequence(
          doc,
          Keys.right(),
          {},
          [
            targets.two,
            targets.five,
            targets.one,
            targets.two,
            targets.five,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.left(),
          {  },
          [
            targets.five,
            targets.two,
            targets.one,
            targets.five,
            targets.two,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.up(),
          {  },
          [
            targets.five,
            targets.two,
            targets.one,
            targets.five,
            targets.two,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.down(),
          {  },
          [
            targets.two,
            targets.five,
            targets.one,
            targets.two,
            targets.five,
            targets.one
          ]
        ),

        // Test execute
        Keyboard.sKeydown(doc, Keys.enter(), {})
      ];<commit_msg>VAN-42: check result of execute<commit_after>asynctest(
  'Flow Keying Test',
 
  [
    'ephox.agar.api.FocusTools',
    'ephox.agar.api.Keyboard',
    'ephox.agar.api.Keys',
    'ephox.agar.api.Step',
    'ephox.alloy.api.GuiFactory',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.test.GuiSetup',
    'ephox.alloy.test.NavigationUtils',
    'ephox.compass.Arr'
  ],
 
  function (FocusTools, Keyboard, Keys, Step, GuiFactory, EventHandler, GuiSetup, NavigationUtils, Arr) {
    var success = arguments[arguments.length - 2];
    var failure = arguments[arguments.length - 1];

    GuiSetup.setup(function (store, doc, body) {
      var item = function (classes, name) {
        return {
          uiType: 'custom',
          dom: {
            tag: 'span',
            styles: {
              display: 'inline-block',
              width: '20px',
              height: '20px',
              margin: '2px',
              border: '1px solid ' + (Arr.contains(classes, 'stay') ? 'blue' : 'yellow')
            },
            classes: classes
          },
          events: {
            'alloy.execute': EventHandler.nu({
              run: store.adder('item.execute: ' + name)
            })
          },
          focusing: true
        };
      };

      return GuiFactory.build({
        uiType: 'custom',
        dom: {
          tag: 'div',
          classes: [ 'flow-keying-test'],
          styles: {
            background: 'white',
            width: '200px',
            height: '200px'
          }
        },
        uid: 'custom-uid',
        keying: {
          mode: 'flow',
          selector: '.stay'
        },
        components: [
          item([ 'stay', 'one' ], 'one'),
          item([ 'stay', 'two' ], 'two'),
          item([ 'skip', 'three' ], 'three'),
          item([ 'skip', 'four' ], 'four'),
          item([ 'stay', 'five' ], 'five')
        ]
      });

    }, function (doc, body, gui, component, store) {

      var targets = {
        one: { label: 'one', selector: '.one' },
        two: { label: 'two', selector: '.two' },
        five: { label: 'five', selector: '.five' }
      };

      return [
        FocusTools.sSetFocus('Initial focus', gui.element(), '.one'),
        NavigationUtils.sequence(
          doc,
          Keys.right(),
          {},
          [
            targets.two,
            targets.five,
            targets.one,
            targets.two,
            targets.five,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.left(),
          {  },
          [
            targets.five,
            targets.two,
            targets.one,
            targets.five,
            targets.two,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.up(),
          {  },
          [
            targets.five,
            targets.two,
            targets.one,
            targets.five,
            targets.two,
            targets.one
          ]
        ),
        NavigationUtils.sequence(
          doc,
          Keys.down(),
          {  },
          [
            targets.two,
            targets.five,
            targets.one,
            targets.two,
            targets.five,
            targets.one
          ]
        ),

        // Test execute
        Keyboard.sKeydown(doc, Keys.enter(), {}),
        store.sAssertEq('Check that execute has fired on the right target', [ 'item.execute: one' ])
      ];
{'fraction_non_alphanumeric': 0.14045600701549255, 'fraction_numerical': 0.0043846828412744815, 'mean_word_length': 1.2554383651944627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2972425', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1958, 'n_words': 377}