Skip to content

Commit

Permalink
MOBILE-4173 core: Add behat to test embedded PDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Jan 31, 2024
1 parent 327fe01 commit 22a8f0d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
Binary file added local_moodleappbehat/fixtures/dummy.pdf
Binary file not shown.
51 changes: 46 additions & 5 deletions src/tests/behat/open_files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ Feature: It opens files properly.
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And the following "activities" exist:

@lms_from3.10
Scenario: Open a file
Given the following "activities" exist:
| activity | name | intro | display | course | defaultfilename |
| resource | Test TXT | Test TXT description | 5 | C1 | A txt.txt |
| resource | Test RTF | Test RTF description | 5 | C1 | A rtf.rtf |
| resource | Test DOC | Test DOC description | 5 | C1 | A doc.doc |
And the following config values are set as admin:
| filetypeexclusionlist | rtf,doc | tool_mobile |

@lms_from3.10
Scenario: Open a file
Given I entered the resource activity "Test TXT" on course "Course 1" as "student1" in the app
And I entered the resource activity "Test TXT" on course "Course 1" as "student1" in the app
When I press "Open" in the app
Then the app should have opened a browser tab with url "^blob:"

Expand Down Expand Up @@ -57,3 +57,44 @@ Feature: It opens files properly.
And I press "Test DOC" in the app
And I press "Open" in the app
Then I should find "This file may not work as expected on this device" in the app

Scenario: Open a PDF embedded using an iframe
# Using http://webserver directly because $WWWROOT cannot be used in generators or when creating the page manually.
Given the following "activities" exist:
| activity | idnumber | course | name | content |
| page | page1 | C1 | Page with embedded PDF | <iframe src="http://webserver/local/moodleappbehat/fixtures/dummy.pdf" width="100%" height="500"></iframe> |
| page | page2 | C1 | Page with embedded web | <iframe src="https://moodle.org" width="100%" height="500" data-open-external="true"></iframe> |
And the following config values are set as admin:
| custommenuitems | PDF item\|http://webserver/local/moodleappbehat/fixtures/dummy.pdf\|embedded | tool_mobile |
And I entered the course "Course 1" as "student1" in the app

When I press "Page with embedded PDF" in the app
And I press "Open PDF file" in the app
Then the app should have opened a browser tab with url "dummy.pdf"

When I close the browser tab opened by the app
And I press the back button in the app
And I press "Page with embedded web" in the app
And I press "Open in browser" in the app
And I press "OK" in the app
Then the app should have opened a browser tab with url "moodle.org"

When I close the browser tab opened by the app
And I switch network connection to offline
And I press "Open in browser" in the app
Then I should find "There was a problem connecting to the site. Please check your connection and try again." in the app

When I press "OK" in the app
And I press the back button in the app
And I press "Page with embedded PDF" in the app
And I press "Open PDF file" in the app
Then the app should have opened a browser tab with url "^blob"

When I close the browser tab opened by the app
When I switch network connection to wifi
And I press the back button in the app
And I press the back button in the app
And I press "More" in the app
And I press "PDF item" in the app
And I press "Open PDF file" in the app
Then the app should have opened a browser tab with url "dummy.pdf"

0 comments on commit 22a8f0d

Please sign in to comment.