Conversation
Hug0-Drelon
left a comment
There was a problem hiding this comment.
Could you add a small doc in README?
src/users/index.js
Outdated
|
|
||
| expect( resultCreateUser ).toContain( 'Success: Created user' ); | ||
|
|
||
| const { groups: user } = resultCreateUser.match( |
There was a problem hiding this comment.
You can use --porcelain to get only the ID and avoid parsing the string with a regex.
There was a problem hiding this comment.
Not possible.
This means we have to wp user get ${ userId } after that. Problem: this doesn't return the user's password.
There was a problem hiding this comment.
Okay, but why using a strong auto generated password here?
You can use --user_pass=password instead, am I right?
Here is as example:
const userId = execSync(
`npx wp-env run tests-cli wp user create ${ userName } ${ email } --role=editor --user_pass=password --porcelain`
)Then no need to call wp user get ${ userId }.
| * @return {Promise<User>} The user. | ||
| */ | ||
| export async function createTranslator( langSlugs, userName ) { | ||
| userName = |
There was a problem hiding this comment.
I wouldn't check types here.
The reason is that we strongly document function in this package, with TS-like checks.
If someone passes dog shit, I expect the code to fail. Here it goes on silently.
Moreover, you coded a default value but didn't document it that way.
There was a problem hiding this comment.
The type check was my way to provide a default value. Improved with 61cdb97.
Done in b62615c. |

Allows to create a user with translator capabilities:
Allows to switch to the given user: