-
Notifications
You must be signed in to change notification settings - Fork 114
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
[automate-2697] stabilize project mgmt tests #3584
Conversation
no more flaky tests :))) Signed-off-by: Brenna Hewer-Darroch <[email protected]>
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
now two tests, one for project mgmt and one for project rules mgmt Signed-off-by: Brenna Hewer-Darroch <[email protected]>
9819a32
to
a389f7c
Compare
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
Signed-off-by: Brenna Hewer-Darroch <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -58,24 +64,6 @@ describe('global projects filter', () => { | |||
}); | |||
}); | |||
|
|||
function cleanupProjects(id_token: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't needed since we have our handy cy.cleanupIAMObjectsByIDPrefixes
(which also knows how to delete a project's rules before deleting it)
|
||
describe('project management', () => { | ||
// we increase the default delay to mimic the average human's typing speed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided to drop the typeDelay
here. It was added as an early attempt to deflake the tests, since sometimes characters were missed when typing. but we've since found better ways to improve stability, mostly around adding expectations to ensure the page has loaded before interacting with elements.
cy.cleanupIAMObjectsByIDPrefixes(cypressPrefix, ['projects']); | ||
|
||
// if there are projects that already exist, set the projects filter to all projects | ||
cy.request({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to turn this into a helper, like clearProjectsFilter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're not doing it here, that would be a helpful comment within the code so as we duplicate the work it stands out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the only instance we're using it, so I'll leave this as is and updatethe comment
}); | ||
|
||
// something is occasionally resetting the projects filter to (unassigned) | ||
itFlaky('can create a rule for the new project', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved these to project_rule_mgmt
cy.contains(projectName).should('exist'); | ||
cy.contains(projectID).should('exist'); | ||
|
||
cy.url().should('include', '/settings/projects'); | ||
}); | ||
|
||
it('addPolicies checkbox is always checked on modal open', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now just an assertion in can create a project with a custom ID and generate associated policies
cy.wait('@getProjects'); | ||
|
||
cy.get('app-project-list chef-td').contains(customWithoutPolsProjectID).parent() | ||
.find('.mat-select-trigger').as('controlMenu'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always had trouble selecting the right element for the control menu in these tests and getting a successful interaction, but it looks like our mat-select
refactor made it easier to target :)
} | ||
}); | ||
}); | ||
|
||
// these tests are currently interdependent so mark as flaky until the above isn't | ||
itFlaky('can create a project with a custom ID', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this up with the other create
tests and changed the ID so we wouldn't run into conflicts
associatedPolicies.forEach((policy) => { | ||
cy.request({ | ||
auth: { bearer: adminIdToken }, | ||
url: `/apis/iam/v2/policies/${customWithoutPolsProjectID}-${policy}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is sort of hard to parse at first glance. I wonder if there's a way to make it clearer?
maybe associatedPolicies
-> appendedPolicyIds
policy
-> policy_id
and or maybe create a new variable above the request instead of inside it with a new var name? Like autoCreatedPolicyId
or something?
🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe i'm hung up on associated
over autoGenerated
? 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went with a combo of yours and @msorens' suggestions
] | ||
}; | ||
// add rule via the API to save time, | ||
// since we test rules more thoroughly in project_rule_mgmt.spec.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
// we throw in a should so cypress retries until introspection allows menu to be shown | ||
cy.get('@controlMenu').should('be.visible') | ||
// we throw in a `should` so cypress retries until introspection allows menu to be shown | ||
cy.get('@controlMenu').scrollIntoView().should('be.visible') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooooh scroll into vieewwwww
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah pretty slick 😎 might need to use that in some of our other tests
cy.request({ | ||
auth: { bearer: adminIdToken }, | ||
method: 'DELETE', | ||
url: `/apis/iam/v2/projects/${customWithoutPolsProjectID}/rules/${rule.id}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for the "Project UPdate" banner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I know we don't want to test the functionality of the banner here, however, and we could remove when we add the fuller update tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
|
||
cy.url().should('include', `/settings/projects/${project.id}`); | ||
cy.get('app-project-details chef-td').contains(ruleID); | ||
cy.get('app-pending-edits-bar').contains('Project edits pending'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the project update banner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks for adding new tests along the way! 🤗
I had some clarification questions and one idea about making this a big more readable-- I think all of your inline comments do loads to that end, though.
In general, I wonder if there's a way to make some of these expectations more readable (like
cy.get('app-project-details chef-td').contains(ruleID).parent()
.find('.mat-select-trigger').as('controlMenu');
doesn't read in a way where I really know what is being verified 🤔) but it's a much bigger dilemma than this PR which fixes all the things and THEN makes new wonderful things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!! Just a couple suggestions/questions.
cy.get('[data-cy=operator-dropdown]').select('member of'); | ||
cy.get('[data-cy=operator-dropdown]').select('equals'); | ||
cy.get('[data-cy=rule-value] input').type('Chef Policy Group Foo'); | ||
// don't create associated project policies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful to provide a bit more context
// don't create associated project policies | |
// checkbox is selected by default; uncheck so we do NOT create associated project policies |
cy.contains(customWithoutPolsProjectID).should('exist'); | ||
|
||
// verify no associated policies were generated | ||
associatedPolicies.forEach((policy) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confused me for a moment; would be a bit more clear with this:
associatedPolicies.forEach((policy) => { | |
associatedPolicySuffixes.forEach(suffix => { |
// navigate back to the project list page and get latest project data | ||
cy.route('GET', '/apis/iam/v2/projects').as('getProjects'); | ||
cy.get('.breadcrumb').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Did the CreateRule change the current page? I thought we were on the ListProjects page at the start of this test, but if you are clicking on a breadcrumb, then apparently not...?
- Assuming on the project detail page, then, and the breadcrumb click takes us back to the ListProjects page, then why is the explicit projects fetch needed? Isn't that done by the breadcrumb click navigation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cy.route
line isn't actually fetching the data, it specifies what API call Cypress should wait for on L220 (cy.wait('@getProjects');
)
So we return to the list page with the breadcrumb, wait for the ListProjects call to come back, then proceed with the rest of the test.
🔩 Description: What code changed, and why?
Stabilized existing tests and marked them unflaky.
Also broke up
project_mgmt
intoproject_mgmt
, testing just Projects CRUD, andproject_rule_mgmt
, testing just Rules CRUD.This we have Cypress coverage for the Projects GUI section and most of the Project Rules flow.
What's missing is testing the project update in the UI. I'd like to make that it's own test, since it will involve a lot of moving parts: adding some resources to projects, loading some nodes that we'll write rules for, granting a new user project permissions and then having them log in to verify permissions. I've created a new tech debt card for that work.
To run them locally, follow the e2e Readme
👍 Definition of Done
project mgmt
andproject rule mgmt
pass buildkite consistently✅ Checklist