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

Ltd 5714 other ogd sessionwizard #2263

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

Tllew
Copy link
Contributor

@Tllew Tllew commented Dec 5, 2024

replaced is_desnz with is_ogd team to ensure fcdo can't access the site manually
only sending to legacy view when fcdo team

  • Added a constant to WebDriverDelay due to frustration, leaving it in so we have a set place to modify this delay incase someone else gets as frustrated as I did with the tests

LTD-5714

@Tllew Tllew force-pushed the LTD-5706-approve-session-wizard branch 2 times, most recently from 3abfcc1 to fec9881 Compare December 9, 2024 12:16
@Tllew Tllew force-pushed the LTD-5714-other-ogd-sessionwizard branch from 38f2d86 to b493985 Compare December 9, 2024 15:30
Base automatically changed from LTD-5706-approve-session-wizard to dev December 10, 2024 09:40
@Tllew Tllew force-pushed the LTD-5714-other-ogd-sessionwizard branch 5 times, most recently from a0a4030 to 80c4dcc Compare December 12, 2024 13:47
@Tllew Tllew marked this pull request as ready for review December 12, 2024 14:01
Copy link
Contributor

@currycoder currycoder left a comment

Choose a reason for hiding this comment

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

A few minor suggestions throughout to clean this up a bit. Otherwise looking great

@@ -56,7 +56,7 @@ class Layout:
TITLE = "Recommend an approval"

approval_reasons = forms.CharField(
widget=forms.Textarea(attrs={"rows": 7, "class": "govuk-!-margin-top-4"}),
widget=forms.Textarea(attrs={"rows": 7, "class": "govuk-!-margin-top-4", "name": "approval_reasons"}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised this "name": "approval_reasons" is necessary. My understanding is that django injects that for you when this is rendered in the template.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. If it's added for a particular reason could we get a comment as to why?

Copy link
Contributor Author

@Tllew Tllew Jan 6, 2025

Choose a reason for hiding this comment

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

I believe this was me trying to force remove the form index from the approval reason, as the name here is formatted: formname-approval_reasons

ultimately this didn't work and I needed to change the ui tests to point to "recommend_approval-approval_reasons"

this is something the formwizard inserts so that you can have multiple fields with the same name in a single formwizard.

(removed now)


{% if buttons.edit_recommendation %}
{% if can_user_make_desnz_edit %}
{% if can_user_make_edit %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't noticed before that there's sort of two parts to this permission; 1) can the user make the new edit expressed with this new django rule, 2) can the user make an edit at all, expressed with buttons.edit_recommendation

I feel like it would be good to get away from buttons.edit_recommendation if we can and get to the django rules governing this completely.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this needs to be converted to use django rules everywhere.
get_advice_tab_context() decides whether we show or hide button depending on current user etc and in template we use rules on top of that. We need to make changes in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked into this a little, I do agree we could remove the if buttons. logic however there's some additional logic behind the edit_recommendation that I'm not confident we'd cover with the logic we have in the template, it seems like it could be a little out of scope at this stage in the LCDC project

form_class = SelectAdviceForm

def get_success_url(self):
recommendation = self.request.POST.get("recommendation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would recommend getting this from the form's cleaned_data rather by setting it as an instance variable in form_valid(). We are otherwise getting the raw value rather than the cleaned one

@@ -28,7 +47,7 @@ class GiveApprovalAdviceView(LoginRequiredMixin, CaseContextMixin, BaseSessionWi
]

condition_dict = {
AdviceSteps.RECOMMEND_APPROVAL: C(is_desnz_team),
AdviceSteps.RECOMMEND_APPROVAL: C(is_ogd_team),
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't get why this step is conditional. Once you're in the new flow, surely this step must show. We are handling whether or not to take users to the new or legacy flow outside of this view

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is still excluding fcdo to ensure if you were to manually navigate to the page, you'd see an error.

Comment on lines +18 to +19
def is_ogd_team(wizard):
return not is_fcdo_team(wizard)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this is named a bit confusingly as FCDO is an OGD and if I were reading this at the point of use this wouldn't be obvious to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we're still excluding fcdo in this pr, i've changed the logic to be : ~C(is_fcdo_team)
and removed is_ogd_team to make this more obvious

@@ -56,7 +56,7 @@ class Layout:
TITLE = "Recommend an approval"

approval_reasons = forms.CharField(
widget=forms.Textarea(attrs={"rows": 7, "class": "govuk-!-margin-top-4"}),
widget=forms.Textarea(attrs={"rows": 7, "class": "govuk-!-margin-top-4", "name": "approval_reasons"}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. If it's added for a particular reason could we get a comment as to why?

def can_desnz_make_edit(team):
return team in services.DESNZ_TEAMS
def can_ogd_make_edit(team):
return not team == services.FCDO_TEAM
Copy link
Contributor

Choose a reason for hiding this comment

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

!= would probably be better here.

Comment on lines +1 to +5
class WebDriverDelay:
THIRTY = 30
FORTYFIVE = 45
TWENTY = 20
SIXTY = 60
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume that you're setting these so you can change them locally to higher values?

You could always set these as env variables instead (maybe with names that aren't literally the number) and then anyone could more easily add these and do it more permanently.

The only other thing I would say though is that I would double check whether something else is going on that is causing you to get so many failures locally with timeouts. It could be a symptom of something changing that is making pages load slowly that might be worth proactively fixing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was written and added in frustration, an env variable is a nice idea, I kept it in so that if someone else was to hit this and for some reason try to modify the delay then they wouldn't need to manually update each instance of the webdriverwait

Brendan helped me resolve the slow tests in the end, in the end it was:

CELERY_ALWAYS_EAGER=True

That resolved the failing and hanging tests.

I'm happy to either:

  1. remove this as a constant
  2. convert it to an env variable

which would you prefer?

@Tllew Tllew force-pushed the LTD-5714-other-ogd-sessionwizard branch from 083c5c4 to 775b745 Compare January 6, 2025 09:58
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.

4 participants