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

"Given I am logged in as a user with the :role role(s) and I have the following fields" does nothing if currently-logged-in user shares role #670

Open
chrisolof opened this issue Jun 27, 2024 · 0 comments

Comments

@chrisolof
Copy link

This does not seem intuitive, as the new user defined in the step may have different field data than the prior, field data that could be important for the test.

Proposed resolution

Eliminate the if (!$this->loggedInWithRole($role)) { check and just get into creating the new user in Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRoleWithGivenFields(), simliar to how things are done in Drupal\DrupalExtension\Context\DrupalContext::assertLoggedInWithPermissions(). Essentially, always do what the step asks for regardless of who is currently logged in.

An alternate resolution might be to check that both the new user's roles and field data match the currently-logged-in user before deciding to skip user creation. This would be a more complex way to resolve the issue, but would maintain the optimization of re-using the existing user if what's asked for is the same. However, I doubt the situation of old and new user matching on both roles and field data would be a common one (why create the step in the scenario at all?), and so I lean toward the simpler resolution above.

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

No branches or pull requests

1 participant