Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming exercises: Provide theia clone information on redirect #10344

Open
wants to merge 114 commits into
base: develop
Choose a base branch
from

Conversation

iyannsch
Copy link
Contributor

@iyannsch iyannsch commented Feb 16, 2025

Deploy to TS9 for @Theia profile

Use the artemis_admin credentials for login.

Important

The following failing server-tests are not due to the code in this PR but also fail on develop

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I translated all newly inserted strings into English and German.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

The Theia User-Flow aims to integrate seamlessly into the existing Artemis exercise flow. When users click on the Open Online IDE button, we want to require as few clicks as possible before the exercise can be worked. In #8723, we defined that no further login should be required - at least for working with the repository.
In separate repositories, I already implemented the Theia LandingPage which can accept the git clone token for the user and instantly spawn a new session with the repo cloned using the token.

Fixes #9357

Description

This PR clears up the UI, moving the Open in Online IDE button into the existing <Code> button. Catering to the required data-sharing, the user's clone token, the user's exercise repo, and the configured Theia Settings are passed to the Landing Page.

Steps for Testing

Prerequisites:

  • 1 Instructor
  1. Create a ProgrammingExercise with enabled online IDE and selected online IDE image. You might want to choose Java17 for simplicity.
  2. Open the exercise in the student view.
  3. Verify that the Code button contains the Open Online IDE button.
  4. Verify that on-click a new tab opens and contains the correct parameters as query params (in the URL)
  • appDef should match your selected Image
  • gitUri should match your clone URL and the git token
  • artemisToken should be existent but you don't have to verify that

Here, you can see a screenshot highlighting the relevant parts.
Bildschirmfoto 2024-10-04 um 14 46 58
As the Theia deployment is connected correctly now, you might need to take a look at your path parameters to verify them

Exam Mode Testing

Make sure that none of that functionality is visible in the Exam Mode.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
app/shared/components/code-button 93%

Summary by CodeRabbit

  • New Features

    • Added functionality to retrieve Theia configuration details for programming exercises.
    • Introduced secure tool token generation for external authentication.
    • Expanded API capabilities for retrieving streamlined build configurations for programming exercises.
  • UI Changes

    • Removed the option to start the online IDE from the programming exercises interface.
    • Added a button for launching the online IDE based on Theia configuration.

iyannsch and others added 30 commits September 23, 2024 18:17
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 16, 2025
@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 16, 2025 19:02 Inactive
@helios-aet helios-aet bot temporarily deployed to artemis-test4.artemis.cit.tum.de February 16, 2025 19:37 Inactive
Copy link

@HanyangXu0508 HanyangXu0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on server 4 and no such button exists.
image

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
…ovide-theia-clone-information-on-redirect' into feature/programming-exercises/provide-theia-clone-information-on-redirect
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a small comment otherwise code LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (1)

475-520: Consider splitting the test and using more specific assertions.

The test effectively verifies the form submission, but could be improved:

  1. Split into separate tests for form structure and data validation.
  2. Use toHaveBeenCalledOnce() consistently instead of mixing with toHaveBeenCalled().

Apply this diff to improve the test:

-        expect(documentAppendChildSpy).toHaveBeenCalledOnce();
+        expect(documentAppendChildSpy).toHaveBeenCalledExactlyOnceWith(form);

Consider splitting into two tests:

it('should create form with correct structure', async () => {
  // Test form method, action, and target
});

it('should include correct data in form inputs', async () => {
  // Test input values
});
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a2f72f and 2df48e6.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/shared/code-button.component.spec.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

  • src/test/javascript/spec/component/shared/code-button.component.spec.ts
🧠 Learnings (1)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (1)
Learnt from: iyannsch
PR: ls1intum/Artemis#10344
File: src/test/javascript/spec/component/shared/code-button.component.spec.ts:0-0
Timestamp: 2025-02-16T16:00:38.131Z
Learning: In test cases, prefer removing unnecessary type assertions over adding mock properties that aren't relevant to what's being tested. This keeps tests focused and reduces maintenance burden.
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-tests-selected
  • GitHub Check: client-style
  • GitHub Check: server-style
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (2)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (2)

21-23: LGTM! Clean service setup.

The new imports and service injection follow Angular testing best practices.

Also applies to: 32-32, 102-102


389-473: LGTM! Well-structured test cases for Theia visibility.

The test cases effectively cover various scenarios for Theia button visibility using parameterized testing. Good practices include:

  • Clear test descriptions
  • Comprehensive coverage of edge cases
  • Proper mocking of dependencies

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
@iyannsch iyannsch requested review from Mtze and magaupp February 18, 2025 10:15
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/main/webapp/app/shared/components/code-button/code-button.component.ts (2)

466-519: 🛠️ Refactor suggestion

Enhance security and modernize the Online IDE launch.

The implementation needs improvements in security and modern practices:

  1. Replace deprecated toPromise() with firstValueFrom
  2. Use POST method to avoid exposing sensitive data in URL
  3. Simplify URL construction
  4. Add error handling
 async startOnlineIDE() {
-    const artemisToken: string = (await this.accountService.getToolToken('SCORPIO').toPromise()) ?? '';
+    try {
+        const artemisToken = await firstValueFrom(this.accountService.getToolToken('SCORPIO')) ?? '';
+        const artemisUrl = new URL(window.location.href).origin;
 
-    let artemisUrl: string = '';
-    if (window.location.protocol) {
-        artemisUrl += window.location.protocol + '//';
-    }
-    if (window.location.host) {
-        artemisUrl += window.location.host;
-    }
-
-    const prevAuthMech = this.selectedAuthenticationMechanism;
-    this.selectedAuthenticationMechanism = RepositoryAuthenticationMethod.Token;
+        const prevAuthMech = this.selectedAuthenticationMechanism;
+        this.selectedAuthenticationMechanism = RepositoryAuthenticationMethod.Token;
 
-    const data = {
-        appDef: this.exercise()?.buildConfig?.theiaImage ?? '',
-        gitUri: this.getHttpOrSshRepositoryUri(false),
-        gitUser: this.user.name,
-        gitMail: this.user.email,
-        artemisToken: artemisToken,
-        artemisUrl: artemisUrl,
-    };
+        const data = {
+            appDef: this.exercise()?.buildConfig?.theiaImage ?? '',
+            gitUri: this.getHttpOrSshRepositoryUri(false),
+            gitUser: this.user.name,
+            gitMail: this.user.email,
+            artemisToken,
+            artemisUrl,
+        };
 
-    this.selectedAuthenticationMechanism = prevAuthMech;
+        this.selectedAuthenticationMechanism = prevAuthMech;
 
-    const newWindow = window.open('', '_blank');
-    if (!newWindow) {
-        return;
-    }
+        const newWindow = window.open('', '_blank');
+        if (!newWindow) {
+            throw new Error('Failed to open new window. Please check your popup blocker settings.');
+        }
 
-    newWindow.name = 'Theia-IDE';
+        newWindow.name = 'Theia-IDE';
 
-    const form = document.createElement('form');
-    form.method = 'GET';
-    form.action = this.theiaPortalURL;
+        const form = document.createElement('form');
+        form.method = 'POST';  // Use POST to avoid exposing sensitive data in URL
+        form.action = this.theiaPortalURL;
+        form.target = newWindow.name;
 
-    form.target = newWindow.name;
+        // Create input fields for form data
+        Object.entries(data).forEach(([key, value]) => {
+            const hiddenField = document.createElement('input');
+            hiddenField.type = 'hidden';
+            hiddenField.name = key;
+            hiddenField.value = value ?? '';
+            form.appendChild(hiddenField);
+        });
 
-    // Loop over data element and create input fields
-    for (const key in data) {
-        if (Object.hasOwn(data, key)) {
-            const hiddenField = document.createElement('input');
-            hiddenField.type = 'hidden';
-            hiddenField.name = key;
-            const descriptor = Object.getOwnPropertyDescriptor(data, key);
-            hiddenField.value = descriptor ? descriptor.value : '';
-            form.appendChild(hiddenField);
-        }
+        document.body.appendChild(form);
+        form.submit();
+        document.body.removeChild(form);
+    } catch (error) {
+        console.error('Failed to start online IDE:', error);
+        this.alertService.error('artemisApp.exerciseActions.startOnlineIdeError');
     }
-
-    document.body.appendChild(form);
-    form.submit();
-    document.body.removeChild(form);
 }

445-464: 🛠️ Refactor suggestion

Improve type safety and error handling in Theia initialization.

The initialization logic needs improvements in type safety and error handling:

  1. Replace @ts-expect-error comments with proper type guards
  2. Add error handling for the HTTP request
 private initTheia(profileInfo: ProfileInfo) {
-    if (profileInfo.activeProfiles?.includes(PROFILE_THEIA) && this.exercise()) {
-        // @ts-expect-error (The exercise is not undefined here)
-        this.programmingExerciseService.getTheiaConfig(this.exercise().id!).subscribe((theiaConfig) => {
-            // Merge the theiaConfig (containing the theiaImage) into the buildConfig
-            // @ts-expect-error (The exercise is not undefined here)
-            this.exercise().buildConfig = { ...this.exercise()?.buildConfig, ...theiaConfig };
-
-            // Set variables now, sanitize later on
-            this.theiaPortalURL = profileInfo.theiaPortalURL ?? '';
-
-            // Verify that all conditions are met
-            // @ts-expect-error (The exercise is not undefined here)
-            if (this.theiaPortalURL !== '' && this.exercise().allowOnlineIde && this.exercise().buildConfig?.theiaImage) {
-                this.theiaEnabled = true;
-            }
-        });
+    const exercise = this.exercise();
+    if (!profileInfo.activeProfiles?.includes(PROFILE_THEIA) || !exercise?.id) {
+        return;
+    }
+
+    this.programmingExerciseService.getTheiaConfig(exercise.id).subscribe({
+        next: (theiaConfig) => {
+            exercise.buildConfig = { ...exercise.buildConfig, ...theiaConfig };
+            this.theiaPortalURL = profileInfo.theiaPortalURL ?? '';
+
+            this.theiaEnabled = Boolean(
+                this.theiaPortalURL &&
+                exercise.allowOnlineIde &&
+                exercise.buildConfig?.theiaImage
+            );
+        },
+        error: (error) => {
+            console.error('Failed to fetch Theia config:', error);
+            this.theiaEnabled = false;
+            this.alertService.error('artemisApp.exerciseActions.theiaConfigError');
+        }
+    });
     }
🧹 Nitpick comments (2)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (2)

22-22: Remove unused import.

The ProgrammingExerciseBuildConfig import is not used in the code.

-import { ProgrammingExerciseBuildConfig } from 'app/entities/programming/programming-exercise-build.config';
🧰 Tools
🪛 GitHub Check: client-tests-selected

[failure] 22-22:
'ProgrammingExerciseBuildConfig' is declared but its value is never read.

🪛 GitHub Check: client-tests

[failure] 22-22:
'ProgrammingExerciseBuildConfig' is declared but its value is never read.


476-521: Enhance form submission test assertions.

Consider using toHaveBeenCalledExactlyOnceWith for more precise assertions on form inputs.

-        expect(documentAppendChildSpy).toHaveBeenCalledOnce();
+        expect(documentAppendChildSpy).toHaveBeenCalledExactlyOnceWith(expect.any(HTMLFormElement));

-        expect(formSubmitSpy).toHaveBeenCalledOnce();
+        expect(formSubmitSpy).toHaveBeenCalledExactlyOnceWith();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2df48e6 and 69a685f.

📒 Files selected for processing (7)
  • src/main/java/de/tum/cit/aet/artemis/programming/dto/ProgrammingExerciseTheiaConfigDTO.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (6 hunks)
  • src/main/webapp/app/entities/programming/programming-exercise-theia.config.ts (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/services/programming-exercise.service.ts (2 hunks)
  • src/main/webapp/app/shared/components/code-button/code-button.component.ts (7 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResourceTest.java (1 hunks)
  • src/test/javascript/spec/component/shared/code-button.component.spec.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/webapp/app/exercises/programming/manage/services/programming-exercise.service.ts
  • src/test/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResourceTest.java
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
🧰 Additional context used
📓 Path-based instructions (3)
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

  • src/main/webapp/app/entities/programming/programming-exercise-theia.config.ts
  • src/main/webapp/app/shared/components/code-button/code-button.component.ts
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/programming/dto/ProgrammingExerciseTheiaConfigDTO.java
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

  • src/test/javascript/spec/component/shared/code-button.component.spec.ts
🧠 Learnings (1)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (1)
Learnt from: iyannsch
PR: ls1intum/Artemis#10344
File: src/test/javascript/spec/component/shared/code-button.component.spec.ts:0-0
Timestamp: 2025-02-16T16:00:38.131Z
Learning: In test cases, prefer removing unnecessary type assertions over adding mock properties that aren't relevant to what's being tested. This keeps tests focused and reduces maintenance burden.
🪛 GitHub Check: client-tests-selected
src/test/javascript/spec/component/shared/code-button.component.spec.ts

[failure] 22-22:
'ProgrammingExerciseBuildConfig' is declared but its value is never read.

🪛 GitHub Check: client-tests
src/test/javascript/spec/component/shared/code-button.component.spec.ts

[failure] 22-22:
'ProgrammingExerciseBuildConfig' is declared but its value is never read.

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-style
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (4)
src/main/webapp/app/entities/programming/programming-exercise-theia.config.ts (1)

1-3: LGTM! Well-structured configuration class.

The class follows TypeScript naming conventions and properly marks the theiaImage property as optional.

src/main/java/de/tum/cit/aet/artemis/programming/dto/ProgrammingExerciseTheiaConfigDTO.java (1)

5-7: LGTM! Well-designed DTO record.

The record is immutable and uses @JsonInclude to ensure clean JSON output by excluding empty values.

src/test/javascript/spec/component/shared/code-button.component.spec.ts (1)

390-474: LGTM! Well-structured test cases for Theia button visibility.

The parameterized tests effectively cover various scenarios for Theia button visibility using descriptive test cases.

src/main/webapp/app/shared/components/code-button/code-button.component.ts (1)

13-13: LGTM!

The new imports are correctly organized and necessary for the Theia IDE integration.

Also applies to: 16-16, 33-33

@@ -66,6 +67,7 @@ export class CodeButtonComponent implements OnInit {
private localStorage = inject(LocalStorageService);
private participationService = inject(ParticipationService);
private ideSettingsService = inject(IdeSettingsService);
private programmingExerciseSerice = inject(ProgrammingExerciseService);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in service name.

The service variable name has a typo: programmingExerciseSerice should be programmingExerciseService.

-    private programmingExerciseSerice = inject(ProgrammingExerciseService);
+    private programmingExerciseService = inject(ProgrammingExerciseService);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private programmingExerciseSerice = inject(ProgrammingExerciseService);
private programmingExerciseService = inject(ProgrammingExerciseService);

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (2)

475-520: Enhance form submission test with additional assertions.

While the test covers the basic form submission flow, consider adding assertions for:

  • The appDef input field value
  • The gitToken input field value
  • Form cleanup after submission

Apply this enhancement:

 const gitUriTest = Array.from(inputs).find((input) => input.name === 'gitUri');
 expect(gitUriTest).toBeDefined();
 expect(gitUriTest!.value).toBe(data.gitUri);
+
+const appDefTest = Array.from(inputs).find((input) => input.name === 'appDef');
+expect(appDefTest).toBeDefined();
+expect(appDefTest!.value).toBe(data.appDef);
+
+const gitTokenTest = Array.from(inputs).find((input) => input.name === 'gitToken');
+expect(gitTokenTest).toBeDefined();
+expect(gitTokenTest!.value).toBe(data.gitToken);
+
+expect(documentRemoveChildSpy).toHaveBeenCalledWith(form);

489-490: Use more specific assertion for tool token retrieval.

Replace toHaveBeenCalledOnce() with toHaveBeenCalledExactlyOnceWith() for more precise test coverage.

Apply this enhancement:

-expect(getToolTokenSpy).toHaveBeenCalledOnce();
+expect(getToolTokenSpy).toHaveBeenCalledExactlyOnceWith();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69a685f and bfaa82a.

📒 Files selected for processing (2)
  • src/test/javascript/spec/component/shared/code-button.component.spec.ts (4 hunks)
  • src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise.service.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise.service.ts
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

  • src/test/javascript/spec/component/shared/code-button.component.spec.ts
🧠 Learnings (1)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (1)
Learnt from: iyannsch
PR: ls1intum/Artemis#10344
File: src/test/javascript/spec/component/shared/code-button.component.spec.ts:0-0
Timestamp: 2025-02-16T16:00:38.131Z
Learning: In test cases, prefer removing unnecessary type assertions over adding mock properties that aren't relevant to what's being tested. This keeps tests focused and reduces maintenance burden.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests-selected
  • GitHub Check: client-style
  • GitHub Check: client-tests
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (3)
src/test/javascript/spec/component/shared/code-button.component.spec.ts (3)

20-23: LGTM! Well-organized imports.

The new imports are correctly organized and specifically target the required Theia-related functionality.


32-32: LGTM! Proper service injection setup.

The ProgrammingExerciseService is correctly injected using TestBed.

Also applies to: 102-102


389-473: LGTM! Comprehensive test cases for Theia visibility.

The parameterized test cases effectively cover various scenarios for Theia button visibility:

  • Profile activation
  • Theia configuration
  • Online IDE activation
  • URL configuration

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, two small change requests though

Comment on lines +447 to +449
// Theia requires the Build Config of the programming exercise to be set
// @ts-expect-error (The exercise is not undefined here)
this.programmingExerciseSerice.getTheiaConfig(this.exercise().id!).subscribe((theiaConfig) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use an exlamation mark instead of the ts-expect-error annotation here?

Suggested change
// Theia requires the Build Config of the programming exercise to be set
// @ts-expect-error (The exercise is not undefined here)
this.programmingExerciseSerice.getTheiaConfig(this.exercise().id!).subscribe((theiaConfig) => {
this.programmingExerciseSerice.getTheiaConfig(this.exercise()!.id!).subscribe((theiaConfig) => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid exlamation mark fully and add a if check before? Would prefer that :D

Comment on lines +450 to +452
// Merge the theiaConfig (containing the theiaImage) into the buildConfig
// @ts-expect-error (The exercise is not undefined here)
this.exercise().buildConfig = { ...this.exercise()?.buildConfig, ...theiaConfig };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here probably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. programming Pull requests that affect the corresponding module server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

Programming exercises: Provide clone information for Theia Sessions
5 participants