Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-57139

Enable eslint-plugin-promise to ensure promise best practices

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 3.4
    • 3.2
    • JavaScript
    • MOODLE_32_STABLE
    • MOODLE_34_STABLE
    • MDL-57139-master
    • Hide

      Messaging/notifications

      Notifications and messaging:

      • Create a course, make yourself a teacher of the course
      • Add an assignment to the course
      • Enable 'Notify graders about submissions setting
      • As a student submit the assignment
      • As the teacher, you should have a notification in the site header
      • Click the notificaitons icon
      • VERIFY: the notification is displayed in the notifications popover
      • VERIFY: you can click the popover and view the full notificaiton
      • VERIFY: the notifications are rendered correctly when visiting
        http://my.moodle/message/output/popup/notifications.php
      • On another user with no notifications..
      • VERIFY the popover displays no notifications fine.

      Messaging

      • Have a student and teacher message each other
      • VERIFY: the popover works and message is displayed
      • Go to a conversation, press the edit button
      • select some messages and then delete them
      • VERIFY: the messages selected are deleted and remain deleted after
      • refresh
      • Press edit again and select 'Delete all messages'
      • VERIFY: there is confirmation and it works correctly
      • Confirm and VERIFY: all messages in the conversation have been removed
      • Search for messages or contacts and verify the search works correclty

      assignment

      1. Enrol a few users in a course with an assignment
      2. User the user selector in top right and ensure it continues to work

      core/fragment

      1. Go to assignment grading interface, VERIFY: everything works and things dsplay

      Usertours

      1. Login as an admin.
      2. Go to Site administration / Appearance / User tours / Boost - course view.
      3. Reset the tour state by clicking on "force the tour to be displayed"
      4. Go to front page of course as teacher, verify tour displays as normal.

      Competencies

      1. Verify the competencies Behat tests pass.
      1. Import an existing competency framework (make sure you have two)
      2. Add a new competency framework
      3. Add competencies to the tree
      4. VERIFY: that the competency tree works
      5. Verify the selection in tree updates the I
      6. Add competency rule to a competency - competency_rule_points
      7. Add cross referenced competencies
      8. VERIFY: the competency picker works
      9. Browse around the competencies - ensure the description and cross-references competencies are displayed
      10. Insert some cross-references
      11. Ensure they are rendered
      12. Add another competency
      13. Change the parent in the form
      1. Add a learning plan template
      2. Choose 'Add competencies to the template'
      3. Switch between competency frameworks
      4. Choose a comptency and add it
      5. VERIFY: the competency gets added to the learnign plan template
      1. In learning plan templates edit menu, choose 'Create learning plans'
      2. Select some users from the user chooser and verify it selects users correctly
      3. Add multiple cohorts to the site
      4. In learning plan templates edit menu, choose 'Add cohorts to sync'
      5. Verify that the cohort selector works
      1. Go to user profile > Learning plans
      2. Add a new plan
      3. 'Click request review'
      4. VERIFY: the interface updates to say 'Waiting for review'
      5. (Repeat with some more actions)
      6. Add evidence of prior learning
      7. Link competencies
      8. VERIFY: the competency appears on page
      9. Click on the competency
      10. Verify the competency info comes up as a popup
      11. Request review start review/finish review
      12. Delete some evidence, verify confirmation is shown and evidence is removed
        # Complete learning plan, click competency
      1. Go to learning plan template, delete learning plan, confirm confirmation
      1. Go to Migrate frameworks
      2. VERIFY: you can select frameworks from the dropdown
      3. Import a competency framework from moodle.net
      4. Go the competency frameworks page
      5. Browse around the competencies - ensure the description and cross-references competencies are displayed
      6. Insert some cross-references
      7. Ensure they are rendered
      8. Edit a learning plan template
      9. Add competencies to learning plan template, verify the competency gets added to the page after it is selected
      10. Set a competency rule https://docs.moodle.org/32/en/Competency_frameworks#Setting_a_competency_rule
      11. VERIFY: the rule is reflected in the competency summary when saved

      mod_lti

      Tool registration

      1. Download and run ngrok

        ./ngrok http 80 --region=au

      2. Set your $CFG->wwwroot's base URL to the HTTP URL generated by ngrok.
      3. Click Add
      4. On the "IMS LTI Tool Provider: Tool registration emulator", click "Registration".
      5. Select all of the options under "Enabled capabilities".
      6. Select all of the options under "Tool services".
      7. Click "Register tool".
      8. On the confirmation page, click "Yes" to activate the tool.
        • Confirm that the external tool is successfully created and is set to "Active"

      Content-item

      1. Login as a teacher enrolled to a course
      2. Turn editing on.
      3. Create a new "External tool" activity.
      4. Enter Test tool under Activity name
      5. Select "Test tool provider" under "Preconfigured tool" (the test tool that was registered in the previous section).
      6. Click "Select content"
        • Confirm that a "Select content" dialogue shows up.
        • Confirm that the dialogue shows the contents from the "IMS LTI tool provider emulator".
      7. Check the "Request summary"
        • Confirm that it says "ContentItemSelectionRequest message request is valid".
      8. Click the dialogue's close button.
      9. Back on the "Adding a new External tool..." page, click again on the "Select content" button.
        • Confirm that the "Select content" dialogue shows up again and still renders the contents from the "IMS LTI tool provider emulator".
      10. Click "Content-Item".
      11. Under "Select a sample content item:", select "LTI launch - a link to launch this tool provider"
      12. Click "Return selection" at the bottom of the page.
        • Confirm that the dialogue closes.
        • Confirm that there are no error messages displayed.
        • Confirm that the "Successfully fetched tool configuration from the selected content." notification is displayed.
      13. Expand the "General section of the form by clicking "Show more..."
        • Confirm that the "Custom parameters" and "Icon URL" fields have been filled out

      My overview

      1. In a course with active dates
      2. Create an assignment (assignment 1) with a due date set to 11:30pm today
      3. Create an assignment (assignment 2) with a due date set to 11:30pm 2 days ago (making it overdue)
      4. Create a page activity with activity completion the due date set tomorrow
      5. Duplicate the page activity 20 times [sorry, it's to test paging]
      6. As student enrolled in course view the dashboard and verify the assignments show up in the timeline view

      Course page

      1. As a teacher In a course with format set to topics ..
      2. Repeat for each of the following topic menu items (hide topic, show topic, highlight topic, unhighlight)..
      3. VERIFY: that the menu item icon and name changes to opposite toggle (e.g. from hide to show)
      4. VERIFY: that the title changes on the icon (either with hover or viewing html)

      Survey

      1. Create a survey
      2. VERIFY: those surveys with radio buttons are only able to be submitted when all options are chosen. When missing a modal is displayed with an error.

      userdate amd module

      1. Run the attached test_userdate.php
      2. VERIFY: it generates two different date formats, one with just the date, one with a time
      Show
      Messaging/notifications Notifications and messaging: Create a course, make yourself a teacher of the course Add an assignment to the course Enable 'Notify graders about submissions setting As a student submit the assignment As the teacher, you should have a notification in the site header Click the notificaitons icon VERIFY: the notification is displayed in the notifications popover VERIFY: you can click the popover and view the full notificaiton VERIFY: the notifications are rendered correctly when visiting http://my.moodle/message/output/popup/notifications.php On another user with no notifications.. VERIFY the popover displays no notifications fine. Messaging Have a student and teacher message each other VERIFY: the popover works and message is displayed Go to a conversation, press the edit button select some messages and then delete them VERIFY: the messages selected are deleted and remain deleted after refresh Press edit again and select 'Delete all messages' VERIFY: there is confirmation and it works correctly Confirm and VERIFY: all messages in the conversation have been removed Search for messages or contacts and verify the search works correclty assignment Enrol a few users in a course with an assignment User the user selector in top right and ensure it continues to work core/fragment Go to assignment grading interface, VERIFY: everything works and things dsplay Usertours Login as an admin. Go to Site administration / Appearance / User tours / Boost - course view . Reset the tour state by clicking on " force the tour to be displayed " Go to front page of course as teacher, verify tour displays as normal. Competencies Verify the competencies Behat tests pass. Import an existing competency framework (make sure you have two) Add a new competency framework Add competencies to the tree VERIFY: that the competency tree works Verify the selection in tree updates the I Add competency rule to a competency - competency_rule_points Add cross referenced competencies VERIFY: the competency picker works Browse around the competencies - ensure the description and cross-references competencies are displayed Insert some cross-references Ensure they are rendered Add another competency Change the parent in the form Add a learning plan template Choose 'Add competencies to the template' Switch between competency frameworks Choose a comptency and add it VERIFY: the competency gets added to the learnign plan template In learning plan templates edit menu, choose 'Create learning plans' Select some users from the user chooser and verify it selects users correctly Add multiple cohorts to the site In learning plan templates edit menu, choose 'Add cohorts to sync' Verify that the cohort selector works Go to user profile > Learning plans Add a new plan 'Click request review' VERIFY: the interface updates to say 'Waiting for review' (Repeat with some more actions) Add evidence of prior learning Link competencies VERIFY: the competency appears on page Click on the competency Verify the competency info comes up as a popup Request review start review/finish review Delete some evidence, verify confirmation is shown and evidence is removed # Complete learning plan, click competency Go to learning plan template, delete learning plan, confirm confirmation Go to Migrate frameworks VERIFY: you can select frameworks from the dropdown Import a competency framework from moodle.net Go the competency frameworks page Browse around the competencies - ensure the description and cross-references competencies are displayed Insert some cross-references Ensure they are rendered Edit a learning plan template Add competencies to learning plan template, verify the competency gets added to the page after it is selected Set a competency rule https://docs.moodle.org/32/en/Competency_frameworks#Setting_a_competency_rule VERIFY: the rule is reflected in the competency summary when saved mod_lti Tool registration Download and run ngrok ./ngrok http 80 --region=au Set your $CFG->wwwroot 's base URL to the HTTP URL generated by ngrok. Click Add On the " IMS LTI Tool Provider: Tool registration emulator ", click " Registration ". Select all of the options under " Enabled capabilities ". Select all of the options under " Tool services ". Click " Register tool ". On the confirmation page, click " Yes " to activate the tool. Confirm that the external tool is successfully created and is set to " Active " Content-item Login as a teacher enrolled to a course Turn editing on. Create a new " External tool " activity. Enter Test tool under Activity name Select " Test tool provider " under " Preconfigured tool " (the test tool that was registered in the previous section). Click " Select content " Confirm that a " Select content " dialogue shows up. Confirm that the dialogue shows the contents from the " IMS LTI tool provider emulator ". Check the " Request summary " Confirm that it says " ContentItemSelectionRequest message request is valid ". Click the dialogue's close button. Back on the "Adding a new External tool..." page, click again on the " Select content " button. Confirm that the " Select content " dialogue shows up again and still renders the contents from the " IMS LTI tool provider emulator ". Click " Content-Item ". Under " Select a sample content item: ", select " LTI launch - a link to launch this tool provider " Click " Return selection " at the bottom of the page. Confirm that the dialogue closes. Confirm that there are no error messages displayed. Confirm that the " Successfully fetched tool configuration from the selected content. " notification is displayed. Expand the " General section of the form by clicking " Show more... " Confirm that the " Custom parameters " and " Icon URL " fields have been filled out My overview In a course with active dates Create an assignment (assignment 1) with a due date set to 11:30pm today Create an assignment (assignment 2) with a due date set to 11:30pm 2 days ago (making it overdue) Create a page activity with activity completion the due date set tomorrow Duplicate the page activity 20 times [sorry, it's to test paging] As student enrolled in course view the dashboard and verify the assignments show up in the timeline view Course page As a teacher In a course with format set to topics .. Repeat for each of the following topic menu items (hide topic, show topic, highlight topic, unhighlight).. VERIFY: that the menu item icon and name changes to opposite toggle (e.g. from hide to show) VERIFY: that the title changes on the icon (either with hover or viewing html) Survey Create a survey VERIFY: those surveys with radio buttons are only able to be submitted when all options are chosen. When missing a modal is displayed with an error. userdate amd module Run the attached test_userdate.php VERIFY: it generates two different date formats, one with just the date, one with a time

      I have discussed this with integrators as from my own experience the eslint-plugin-promise helped me fix some of my own misunderstandings of promises and I think it would be a useful addition to our ruleset.

      https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html gives a great bit of background of the use of the point lints.

      Also:
      http://taoofcode.net/promise-anti-patterns/
      https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns
      http://www.datchley.name/promise-patterns-anti-patterns/

      Rule: catch-or-return

      Ensure that each time a then() is applied to a promise, a catch() is applied as well. Exceptions are made if you are returning that promise.

      Valid

      myPromise.then(doSomething).catch(errors);
      myPromise.then(doSomething).then(doSomethingElse).catch(errors);
      function doSomethingElse() { return myPromise.then(doSomething) }
      

      Invalid:

      myPromise.then(doSomething);
      myPromise.then(doSomething, catchErrors); // catch() may be a little better
      function doSomethingElse() { myPromise.then(doSomething) }
      

      Rule: always-return

      Ensure that inside a then() you make sure to return a new promise or value. See http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html (rule #5) for more info on why that's a good idea.

      We also allow someone to throw inside a then() which is essentially the same as return Promise.reject().

      Valid

      myPromise.then((val) => val * 2));
      myPromise.then(function(val) { return val * 2; });
      myPromise.then(doSomething); // could be either
      myPromise.then((b) => { if (b) { return "yes" } else { return "no" } });
      

      Invalid:

      myPromise.then(function(val) {});
      myPromise.then(() => { doSomething(); });
      myPromise.then((b) => { if (b) { return "yes" } else { forgotToReturn(); } });
      

            poltawski Dan Poltawski
            poltawski Dan Poltawski
            Andrew Lyons Andrew Lyons
            Jun Pataleta Jun Pataleta
            Ankit Agarwal Ankit Agarwal
            Votes:
            6 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.