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

Write feature test to replicate scenario with where user modifies JudgeAssignTask in multiple tabs #16582

Merged

Conversation

eileen-nava
Copy link
Contributor

@eileen-nava eileen-nava commented Aug 3, 2021

Resolves Multiple Judge/Attorney Tasks.

Description

The purpose of this PR was to replicate the scenario where a user creates multiple Judge and Attorney tasks by doing the same actions in two different tabs, as described in this comment from Yoom. The user's actions cause a JudgeAssignTask to change status from cancelled to completed, which is an invalid flow.

(The below section is no longer relevant because JC and Yoom answered my question, but I am including it for posterity's edification.)
I was unable to completely replicate the scenario, because I couldn't figure out how to select "Assign an attorney" when there were two dropdowns on the page with this option. Here is the error that the test currently throws.

Failures:

  1) duplicate JudgeAssignTask investigation Judge reassigns JudgeAssignTask in first tab and complete task in second tab Caseflow creates multiple JudgeDecisionReview and JudgeAssign tasks
     Failure/Error: container.find(selector, **keyword_args)
     
     Capybara::Ambiguous:
       Ambiguous match, found 2 elements matching visible css ".cf-select__control"
     # ./spec/support/feature_helper.rb:120:in `find_dropdown'
     # ./spec/support/feature_helper.rb:24:in `click_dropdown'
     # ./spec/fixes/investigate_duplicate_judge_tasks_spec.rb:61:in `block (4 levels) in <top (required)>'
     # ./spec/fixes/investigate_duplicate_judge_tasks_spec.rb:46:in `block (3 levels) in <top (required)>'

Finished in 37.65 seconds (files took 9.74 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/fixes/investigate_duplicate_judge_tasks_spec.rb:24 # duplicate JudgeAssignTask investigation Judge reassigns JudgeAssignTask in first tab and complete task in second tab Caseflow creates multiple JudgeDecisionReview and JudgeAssign tasks

I tried to open the test in a local browser and then select the "Assign an attorney" option based on its css selector, which is how I had selected the dropdown itself. However, the dev tools did not display the css selectors for the task action options.... I am unsure why.

Guidance on how to select the task option would be appreciated, please!

Acceptance Criteria

  • Test replicates the scenario where the user opens multiple tabs and causes a JudgeAssignTask to change status from cancelled to completed

Testing Plan

  1. Run the test

@eileen-nava eileen-nava changed the title Write feature to replicate scenario with multiple Judge/Attorney tasks Write feature test to replicate scenario with multiple Judge/Attorney tasks Aug 3, 2021
@eileen-nava eileen-nava changed the title Write feature test to replicate scenario with multiple Judge/Attorney tasks WIP: Write feature test to replicate scenario with multiple Judge/Attorney tasks Aug 3, 2021
@codeclimate
Copy link

codeclimate bot commented Aug 3, 2021

Code Climate has analyzed commit 3561be1 and detected 0 issues on this pull request.

View more on Code Climate.

# below correctly selects the second task action dropdown
find("#currently-active-tasks > div:nth-child(4) > table > tbody > tr:nth-child(3) > td.taskContainerStyling.taskActionsContainerStyling > div > div > div > div > div > div").click
# below - could not successfully select the "assign to attorney" dropdown because there were two dropdowns with this option
click_dropdown(text: "Assign to attorney")
Copy link
Contributor

@jcq jcq Aug 3, 2021

Choose a reason for hiding this comment

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

You should be able to scope it by specifying the container (second argument, after the options hash):

assign_task_row = find("#currently-active-tasks > div:nth-child(4) > table > tbody > tr:nth-child(3)")
click_dropdown({text: "Assign to attorney"}, assign_task_row)

Copy link
Contributor

@yoomlam yoomlam Aug 3, 2021

Choose a reason for hiding this comment

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

I like assign_task_row = find("table[summary='layout table'] tr:nth-child(3)") a bit better.

@eileen-nava eileen-nava changed the title WIP: Write feature test to replicate scenario with multiple Judge/Attorney tasks Write feature test to replicate scenario with multiple Judge/Attorney tasks Aug 10, 2021
Rubaiyat Rashid and others added 5 commits August 10, 2021 11:10
…ed from virtual to video or central (#16600)

Connects [CASEFLOW-1556](https://vajira.max.gov/browse/CASEFLOW-1556)

### Description
Read [thread](https://dsva.slack.com/archives/C01MBDKAC7P/p1628282082046700?thread_ts=1628004392.010800&cid=C01MBDKAC7P) on why this only implements the copy changes for when virtual hearing is converted back to Video or Central. 
- modify email copy and subject when virtual hearing is converted back to video or central

### Acceptance Criteria
- [x] When a scheduled hearing is converted from Virtual to Video or Central send an email with the following content to the appellant
    - [x] Subject: "Your Board hearing will be held at {Hearing Location or RO Name}"
    - [x] Replace the opening paragraph of the intro section with: "Your hearing with a Veterans Law Judge of the Board of Veterans’ Appeals has changed format. Instead of a virtual tele-hearing, you will go in person to {Hearing Location or RO name} and the Judge will meet with you {via video conference / in person}."
    - [x] Display the following sections underneath the salutation and intro
        - [x] Date and Time
        - [x] Location
        - [x] What should I expect on the day of my hearing?
        - [x] Signature
        - [x] Internal use
- [x] When a scheduled hearing is converted from Virtual to Video or Central and a representative email has already been added to the hearing, send an email with the following content to the representative
    - [x] Subject: "{Full Appellant Name}’s hearing will be held at {Hearing Location or RO Name}"
    - [x] Replace the opening paragraph of the intro section with: "Your client's hearing with a Veterans Law Judge of the Board of Veterans’ Appeals has changed format. Instead of a virtual tele-hearing, you will go in person to {Hearing Location or RO name} and the Judge will meet with you {via video conference / in person}."
    - [x] Display the following sections underneath the salutation and intro
        - [x] Appellant name
        - [x] Case Details link
        - [x] Date and Time
        - [x] Location
        - [x] Signature
        - [x] Internal use

### Testing Plan
```bash
bundle exec rake emails:hearings:sample
Check the content of `cancellation_appellant.rb` and `cancellation_representative.rb`
```
* bug fix

* move method call
Connects  https://vajira.max.gov/browse/CASEFLOW-1034

### Description
User Story: As a VLJ Support Team user, I want the ability to indicate I want to edit an Appellant's information, so that I may correct any mistakes made during intake. 

### Acceptance Criteria
- [ ] Code compiles correctly

### Testing Plan
1. Go to ...

- [ ] For higher-risk changes: [Deploy the custom branch to UAT to test](https://github.com/department-of-veterans-affairs/appeals-deployment/wiki/Applications---Deploy-Custom-Branch-to-UAT)

### User Facing Changes
<img width="1110" alt="Screen Shot 2021-08-10 at 9 34 02 AM" src="https://user-images.githubusercontent.com/23080951/128876347-299003b9-0671-4938-8d84-d4012c75553b.png">
@eileen-nava eileen-nava changed the title Write feature test to replicate scenario with multiple Judge/Attorney tasks Write feature test to replicate scenario with where user modifies JudgeAssignTask in multiple tabs Aug 11, 2021
Comment on lines +77 to +78
# app currently allows the invalid flow of a JudgeAssignTask going from cancelled to completed
expect(Task.find(first_judge_assign_task_id).status).to eq("completed")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# app currently allows the invalid flow of a JudgeAssignTask going from cancelled to completed
expect(Task.find(first_judge_assign_task_id).status).to eq("completed")
# BUG: app currently allows the invalid flow of a JudgeAssignTask going from cancelled to completed
expect(Task.find(first_judge_assign_task_id).status).to eq("completed")

appeal.reload.treee

# open a second window and visit case details page, window B
second_window = open_new_window
Copy link
Contributor

Choose a reason for hiding this comment

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

This is so cool and great to see! Very well-described too.

Copy link
Contributor

@pbradin pbradin left a comment

Choose a reason for hiding this comment

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

Nice job Eileen!

@eileen-nava eileen-nava changed the base branch from master to 2075/limit-jdr-atty-tasks August 13, 2021 14:05
@eileen-nava
Copy link
Contributor Author

eileen-nava commented Aug 13, 2021

Update: I decided to merge this branch into eileen/2075-multiple-judge-tasks and then merge eileen/2075-multiple-judge-tasks into master. It seems simpler than having two separate PRs that are based off master.

@eileen-nava eileen-nava merged commit 3561be1 into 2075/limit-jdr-atty-tasks Aug 13, 2021
va-bot pushed a commit that referenced this pull request Aug 16, 2021
…eDecisionReviewTask (#16586)

Resolves jira ticket [Research and prevent recurrence of bug where one case has multiple JudgeAssignTasks, JudgeDecisionReviewTasks, and AttorneyTasks](https://vajira.max.gov/projects/CASEFLOW/issues/CASEFLOW-2075) .
Relates to github PR [Write feature test to replicate scenario with multiple Judge/Attorney tasks](#16582).

### Description
A bug occurred in production where a user created multiple Judge and Attorney tasks by doing the same actions in two different tabs, as described in [this comment from Yoom](https://github.com/department-of-veterans-affairs/dsva-vacols/issues/212#issuecomment-889401070).
The `JudgeAssignTask` [model already had a validation ](#16072) to ensure that an appeal cannot have more than one `JudgeAssignTask` open at the same time.  I expanded this validation to the `JudgeDecisionReviewTask` and `AttorneyTask` models.  I also refactored the validation to use instance variables instead of thread-local variables, as suggested in [this StackOverflow post](https://stackoverflow.com/questions/8881712/skip-certain-validation-method-in-model) that Yoom linked in a previous thread.


### Acceptance Criteria
- [ ] Code compiles correctly
- [ ] All automated tests pass
- [ ] Task validations no longer use thread-local variables
- [ ] If a user attempts to act on the same `JudgeAssignTask` in two different windows, they will not be able to create multiple `JudgeDecisionReviewTask`s and `AttorneyTask`s. 

### Testing Plan
[ ] Find an appeal with an open `JudgeAssignTask`
```
jat = JudgeAssignTask.open.last
appeal = jat.appeal
```
[ ] On local caseflow, switch users to the judge who has the `JudgeAssignTask` assigned to them
[ ] Navigate to the case details page for the relevant appeal. Open the same page in a second tab
`/queue/appeals/${appeal.uuid}`
[ ] In the first tab, reassign the `JudgeAssignTask` to another judge
[ ] In the second tab, attempt to complete the `JudgeAssignTask` by assigning the case to an attorney.  You should not be able to complete this action
@eileen-nava eileen-nava deleted the eileen/2075-multiple-judge-tasks branch September 13, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants