MOBILE-3947 core: Fix compile HTML

main
Pau Ferrer Ocaña 2023-12-15 16:06:48 +01:00
parent 19ab818683
commit e875cc6306
4 changed files with 22 additions and 34 deletions

View File

@ -26,7 +26,6 @@ Feature: Users can manage entries in database activities
| data1 | text | URL | URL link | | data1 | text | URL | URL link |
| data1 | text | Description | Link description | | data1 | text | Description | Link description |
@ionic7_failure
Scenario: Create entry Scenario: Create entry
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
Then I should find "No entries yet" in the app Then I should find "No entries yet" in the app
@ -38,7 +37,6 @@ Feature: Users can manage entries in database activities
Then I should find "https://moodle.org/" in the app Then I should find "https://moodle.org/" in the app
And I should find "Moodle community site" in the app And I should find "Moodle community site" in the app
@ionic7_failure
Scenario: Browse entry Scenario: Browse entry
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
@ -72,7 +70,6 @@ Feature: Users can manage entries in database activities
And I should find "Moodle community site" in the app And I should find "Moodle community site" in the app
And I should find "Moodle Cloud" in the app And I should find "Moodle Cloud" in the app
@ionic7_failure
Scenario: Students can not edit or delete other user's entries from list and single view in the app Scenario: Students can not edit or delete other user's entries from list and single view in the app
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app And I press "Add entries" in the app
@ -88,7 +85,6 @@ Feature: Users can manage entries in database activities
And "Edit" "link" should not exist And "Edit" "link" should not exist
And "Delete" "link" should not exist And "Delete" "link" should not exist
@ionic7_failure
Scenario: Delete entry (student) & Update entry (student) Scenario: Delete entry (student) & Update entry (student)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app And I press "Add entries" in the app
@ -148,7 +144,6 @@ Feature: Users can manage entries in database activities
And I should not find "Moodle Cloud" in the app And I should not find "Moodle Cloud" in the app
And I should find "No entries yet" in the app And I should find "No entries yet" in the app
@ionic7_failure
Scenario: Delete entry (teacher) & Update entry (teacher) Scenario: Delete entry (teacher) & Update entry (teacher)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app And I press "Add entries" in the app
@ -212,7 +207,6 @@ Feature: Users can manage entries in database activities
And I press "Delete" in the app And I press "Delete" in the app
And I should not find "Moodle Cloud" in the app And I should not find "Moodle Cloud" in the app
@ionic7_failure
Scenario: Handle number 0 correctly when creating entries Scenario: Handle number 0 correctly when creating entries
Given the following "activities" exist: Given the following "activities" exist:
| activity | name | intro | course | idnumber | | activity | name | intro | course | idnumber |

View File

@ -26,7 +26,6 @@ Feature: Users can store entries in database activities when offline and sync wh
| data1 | text | URL | URL link | | data1 | text | URL | URL link |
| data1 | text | Description | Link description | | data1 | text | Description | Link description |
@ionic7_failure
Scenario: Create entry (offline) Scenario: Create entry (offline)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I switch network connection to offline And I switch network connection to offline
@ -46,7 +45,6 @@ Feature: Users can store entries in database activities when offline and sync wh
And I should find "Moodle community site" in the app And I should find "Moodle community site" in the app
And I should not find "This Database has offline data to be synchronised" in the app And I should not find "This Database has offline data to be synchronised" in the app
@ionic7_failure
Scenario: Update entry (offline) & Delete entry (offline) Scenario: Update entry (offline) & Delete entry (offline)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I should find "No entries yet" in the app And I should find "No entries yet" in the app
@ -97,7 +95,6 @@ Feature: Users can store entries in database activities when offline and sync wh
And I should not find "Moodle Cloud" in the app And I should not find "Moodle Cloud" in the app
And I should not find "This Database has offline data to be synchronised" in the app And I should not find "This Database has offline data to be synchronised" in the app
@ionic7_failure
Scenario: Students can undo deleting entries to a database in the app while offline Scenario: Students can undo deleting entries to a database in the app while offline
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I should find "No entries yet" in the app And I should find "No entries yet" in the app

View File

@ -26,7 +26,6 @@ Feature: Test basic usage of comments in app
| database | type | name | description | | database | type | name | description |
| data1 | text | Test field name | Test field description | | data1 | text | Test field name | Test field description |
@ionic7_failure
Scenario: Add comments & Delete comments (database) Scenario: Add comments & Delete comments (database)
# Create database entry and comment as a teacher # Create database entry and comment as a teacher
Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app
@ -65,7 +64,6 @@ Feature: Test basic usage of comments in app
When I press the back button in the app When I press the back button in the app
Then I should find "Comments (1)" in the app Then I should find "Comments (1)" in the app
@ionic7_failure
Scenario: Add comments offline & Delete comments offline & Sync comments (database) Scenario: Add comments offline & Delete comments offline & Sync comments (database)
Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app
And I press "Add entries" in the app And I press "Add entries" in the app

View File

@ -114,42 +114,41 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
* @inheritdoc * @inheritdoc
*/ */
async ngOnChanges(changes: Record<string, SimpleChange>): Promise<void> { async ngOnChanges(changes: Record<string, SimpleChange>): Promise<void> {
if (!this.container) { // Only compile if text/javascript has changed or the forceCompile flag has been set to true.
if (this.text === undefined ||
!(changes.text || changes.javascript || (changes.forceCompile && CoreUtils.isTrueOrOne(this.forceCompile)))) {
return; return;
} }
// Only compile if text/javascript has changed or the forceCompile flag has been set to true. // Create a new component and a new module.
if (this.text !== undefined && (changes.text || changes.javascript || this.creatingComponent = true;
(changes.forceCompile && CoreUtils.isTrueOrOne(this.forceCompile)))) { this.compiling.emit(true);
// Create a new component and a new module. try {
this.creatingComponent = true; const componentClass = await this.getComponentClass();
this.compiling.emit(true);
try { // Destroy previous components.
const componentClass = await this.getComponentClass(); this.componentRef?.destroy();
// Destroy previous components. // Create the component.
this.componentRef?.destroy(); if (this.container) {
// Create the component.
this.componentRef = await CoreCompile.createAndCompileComponent( this.componentRef = await CoreCompile.createAndCompileComponent(
this.text, this.text,
componentClass, componentClass,
this.container, this.container,
this.extraImports, this.extraImports,
); );
this.componentRef && this.created.emit(this.componentRef.instance);
this.loaded = true;
} catch (error) {
CoreDomUtils.showErrorModal(error);
this.loaded = true;
} finally {
this.creatingComponent = false;
this.compiling.emit(false);
} }
this.componentRef && this.created.emit(this.componentRef.instance);
this.loaded = true;
} catch (error) {
CoreDomUtils.showErrorModal(error);
this.loaded = true;
} finally {
this.creatingComponent = false;
this.compiling.emit(false);
} }
} }