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

Communication: Change posting deletion logic to not abort when deconstructing a post #9882

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/main/webapp/app/shared/metis/posting.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ngOnDestroy(): void {
if (this.deleteTimer !== undefined) {
clearTimeout(this.deleteTimer);
this.deletePostingWithoutTimeout();
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the analysis of the test files and implementation, I can now generate the final response:

Additional test coverage needed for deletion scenarios

The current test coverage is insufficient for the deletion scenarios. While there are tests for the UI components and basic deletion functionality, the following scenarios are not covered:

  • The deletePostingWithoutTimeout method implementation is not tested
  • No tests for deletion during navigation (ngOnDestroy)
  • No tests for the timeout-based deletion scenario
  • No tests verifying the cleanup of delete intervals

Please add test cases for:

  1. posting.directive.spec.ts:
    • Test deletePostingWithoutTimeout for both regular posts and answer posts
    • Test cleanup of intervals in ngOnDestroy
    • Test the timeout-based deletion with proper interval cleanup
    • Test the deletion timer functionality
🔗 Analysis chain

Verify test coverage for the deletion scenarios.

While the implementation looks good, please ensure there are tests covering:

  1. Deletion during navigation away
  2. Deletion after timeout
  3. Both answer posts and regular posts

Let's check the test coverage:

Also applies to: 69-69, 132-138

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related test files and their content
fd "posting.directive.spec.ts" | xargs rg "deletePost|ngOnDestroy"

Length of output: 274


Script:

#!/bin/bash
# Let's get more context around the test file content
fd "posting.directive.spec.ts" | xargs cat

Length of output: 4484


Script:

#!/bin/bash
# Let's also check for any other test files that might be testing this functionality
rg -l "deletePosting" --type ts

Length of output: 462


Script:

#!/bin/bash
# Let's check the implementation to understand what scenarios need to be tested
ast-grep --pattern 'deletePostingWithoutTimeout() {
  $$$
}'

Length of output: 62


Script:

#!/bin/bash
# Let's check the implementation with a different pattern to understand the deletion scenarios
ast-grep --pattern 'class $_ {
  $$$
  deletePostingWithoutTimeout$_$_ {
    $$$
  }
  $$$
}'

Length of output: 219


Script:

#!/bin/bash
# Let's also check for ngOnDestroy implementation
ast-grep --pattern 'ngOnDestroy() {
  $$$
}'

Length of output: 46


Script:

#!/bin/bash
# Let's check the test coverage for the reactions bar components
fd "reactions-bar.*spec.ts" | xargs rg "deletePosting|ngOnDestroy"

Length of output: 68


Script:

#!/bin/bash
# Let's try to find the implementation details with ripgrep
rg -A 5 "deletePostingWithoutTimeout" --type ts

Length of output: 1685


Script:

#!/bin/bash
# Let's check the content of the reactions bar test files directly
fd "reactions-bar.*spec.ts" | xargs cat

Length of output: 30797


Script:

#!/bin/bash
# Let's also check for timeout-related code
rg "setTimeout.*delete" --type ts

Length of output: 35

}

if (this.deleteInterval !== undefined) {
Expand All @@ -72,11 +73,7 @@

this.deleteTimer = setTimeout(
() => {
if (this.isAnswerPost) {
this.metisService.deleteAnswerPost(this.posting);
} else {
this.metisService.deletePost(this.posting);
}
this.deletePostingWithoutTimeout();
},
// We add a tiny buffer to make it possible for the user to react a bit longer than the ui displays (+1000)
this.deleteTimerInSeconds * 1000 + 1000,
Expand Down Expand Up @@ -139,12 +136,17 @@
}
}

private deletePostingWithoutTimeout() {
if (this.isAnswerPost) {
this.metisService.deleteAnswerPost(this.posting);
} else {
this.metisService.deletePost(this.posting);
/**
* Create a or navigate to one-to-one chat with the referenced user
*
* @param referencedUserLogin login of the referenced user
*/
onUserReferenceClicked(referencedUserLogin: string) {

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests

',' expected.

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests

';' expected.

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests-selected

',' expected.

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests-selected

';' expected.

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-compilation

',' expected.

Check failure on line 149 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-compilation

';' expected.
const course = this.metisService.course;
if (isMessagingEnabled(course)) {
if (this.isCommunicationPage) {
Expand All @@ -164,7 +166,7 @@
/**
* Create a or navigate to one-to-one chat with the referenced user
*/
onUserNameClicked() {

Check failure on line 169 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests

';' expected.

Check failure on line 169 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-tests-selected

';' expected.

Check failure on line 169 in src/main/webapp/app/shared/metis/posting.directive.ts

View workflow job for this annotation

GitHub Actions / client-compilation

';' expected.
if (!this.posting.author?.id) {
return;
}
Expand All @@ -187,3 +189,3 @@
}
}
}
Loading