Skip to content

Commit

Permalink
Rebased with core version
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchi committed Aug 14, 2024
1 parent f4d0cd5 commit 28e0480
Show file tree
Hide file tree
Showing 9 changed files with 638 additions and 101 deletions.
55 changes: 32 additions & 23 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:12
image: postgres:13
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand All @@ -34,15 +34,15 @@ jobs:
# and database to use:
matrix:
include:
- php: '8.0'
- php: '8.1'
moodle-branch: 'MOODLE_401_STABLE'
database: mariadb
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: pgsql
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -56,7 +56,7 @@ jobs:

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand All @@ -70,47 +70,56 @@ jobs:
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ always() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcs --max-warnings 0

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpdoc --max-warnings 0

- name: Validating
if: ${{ always() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ always() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ always() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci mustache

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt -t shifter --max-lint-warnings 0
if: ${{ !cancelled() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpunit --fail-on-warning

- name: Behat features
if: ${{ always() }}
id: behat
if: ${{ !cancelled() }}
run: moodle-plugin-ci behat --profile chrome

- name: Upload Behat Faildump
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ join(matrix.*, ', ') }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
if-no-files-found: ignore

- name: Mark cancelled jobs as failed.
if: ${{ cancelled() }}
run: exit 1
2 changes: 2 additions & 0 deletions lang/en/atto_linkadv.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
$string['pluginname'] = 'LinkAdv';
$string['privacy:metadata'] = 'The atto_linkadv plugin does not store any personal data.';

$string['texttodisplay'] = 'Text to display';

$string['unlink'] = 'Unlink';
3 changes: 2 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ function atto_linkadv_strings_for_js() {
'enterurl',
'browserepositories',
'openinnewwindow',
'texttodisplay',
'enterid',
'enterclass',
'link',
'advanced'
'advanced',
], 'atto_linkadv');
}
103 changes: 95 additions & 8 deletions tests/behat/link.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@editor @editor_atto @atto @atto_linkadv @_file_upload
Feature: Add links to Atto
Feature: Add advlinks to Atto
To write rich text - I need to add links.
Background:
Given I log in as "admin"
Expand All @@ -22,17 +22,15 @@ Feature: Add links to Atto

@javascript
Scenario: Insert links
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private file" exists:
| user | admin |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
When I open my profile in edit mode
And I set the field "Description" to "Super cool"
And I select the text in the "Description" Atto editor
And I click on "LinkAdv" "button"
Then the field "Text to display" matches value "Super cool"
And I click on "Browse repositories..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
And I click on "moodle-logo.png" "link"
Expand All @@ -43,4 +41,93 @@ Feature: Add links to Atto
And I set the field "Text editor" to "Plain text area"
And I press "Save changes"
And I click on "Edit profile" "link" in the "region-main" "region"
Then I should see "Super cool</a>"
And I should see "Super cool</a>"

@javascript
Scenario: Insert a link without providing text to display
Given I log in as "admin"
When I open my profile in edit mode
And I click on "LinkAdv" "button"
And I set the field "Enter a URL" to "https://moodle.org/"
Then the field "Text to display" matches value "https://moodle.org/"
And I click on "Create link" "button"
And I should see "https://moodle.org/"
And I click on "LinkAdv" "button"
And the field "Text to display" matches value "https://moodle.org/"
And the field "Enter a URL" matches value "https://moodle.org/"
And I click on "Close" "button" in the "Create link" "dialogue"
And I click on "Show more buttons" "button"
And I click on "HTML" "button"
And I should see "https://moodle.org/</a>"

@javascript
Scenario: Insert a link with providing text to display
Given I log in as "admin"
When I open my profile in edit mode
And I click on "LinkAdv" "button"
And I set the field "Text to display" to "Moodle - Open-source learning platform"
And I set the field "Enter a URL" to "https://moodle.org/"
And I click on "Create link" "button"
Then I should see "Moodle - Open-source learning platform"
And I click on "LinkAdv" "button"
And the field "Text to display" matches value "Moodle - Open-source learning platform"
And the field "Enter a URL" matches value "https://moodle.org/"
And I click on "Close" "button" in the "Create link" "dialogue"
And I click on "Show more buttons" "button"
And I click on "HTML" "button"
And I should see "Moodle - Open-source learning platform</a>"
And I should not see "https://moodle.org/</a>"

@javascript
Scenario: Edit a link that already had a custom text to display
Given I log in as "admin"
And I follow "Preferences" in the user menu
And I follow "Editor preferences"
And I set the field "Text editor" to "Plain text area"
And I press "Save changes"
And I click on "Edit profile" "link" in the "region-main" "region"
And I set the field "Description" to "<a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a>"
And I click on "Update profile" "button"
And I follow "Preferences" in the user menu
And I follow "Editor preferences"
And I set the field "Text editor" to "Atto HTML editor"
And I press "Save changes"
When I click on "Edit profile" "link" in the "region-main" "region"
Then I should see "Moodle - Open-source learning platform"
And I click on "LinkAdv" "button"
And the field "Text to display" matches value "Moodle - Open-source learning platform"
And the field "Enter a URL" matches value "https://moodle.org/"

@javascript
Scenario: Insert a link for an image
Given the following "user private file" exists:
| user | admin |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I log in as "admin"
And I open my profile in edit mode
And I click on "Insert or edit image" "button"
And I click on "Browse repositories..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
And I click on "moodle-logo.png" "link"
And I click on "Select this file" "button"
And I set the field "Describe this image for someone who cannot see it" to "It's the Moodle"
And I press "Save image"
And I select the text in the "Description" Atto editor
And I press the right key
And I press the shift left key
And I click on "LinkAdv" "button"
And I set the field "Enter a URL" to "https://moodle.org/"
And I set the field "Text to display" to "Moodle - Open-source learning platform"
And I click on "Create link" "button"
When I click on "Show more buttons" "button"
And I click on "HTML" "button"
Then I should see "<a href=\"https://moodle.org/\" title=\"Moodle - Open-source learning platform\"><img"
And I click on "HTML" "button"
And I select the text in the "Description" Atto editor
And I press the shift left key
And I click on "Insert or edit image" "button"
And the field "Describe this image for someone who cannot see it" matches value "It's the Moodle"
And I click on "Close" "button" in the "Image properties" "dialogue"
And I click on "LinkAdv" "button"
And the field "Text to display" matches value "Moodle - Open-source learning platform"
And the field "Enter a URL" matches value "https://moodle.org/"
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023050400;
$plugin->version = 2023050401;
$plugin->requires = 2022041900;
$plugin->component = 'atto_linkadv';
$plugin->release = '4.1.0';
Expand Down
Loading

0 comments on commit 28e0480

Please sign in to comment.