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

Feat/auth plugin #4783

Merged
merged 9 commits into from
Jan 28, 2025
Merged

Feat/auth plugin #4783

merged 9 commits into from
Jan 28, 2025

Conversation

DavertMik
Copy link
Contributor

  • renamed autoLogin plugin to auth plugin
  • wrapped login steps into a meta step
  • added Comment step
  • added support to use loginAs function to work from BeforeSuite
BeforeSuite({ loginAs } => loginAs('user0');

In this case cookies can be preloaded into Playwright when creating new browser session for faster access

@DavertMik DavertMik requested a review from kobenguyent January 27, 2025 07:36
const event = require('../event')
const recorder = require('../recorder')
const { debug } = require('../output')
const isAsyncFunction = require('../utils').isAsyncFunction
Copy link
Collaborator

Choose a reason for hiding this comment

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

const { isAsyncFunction } = require('../utils')

just a code style I guess to make everything look consistant.

}

if (isPlaywrightSession() && test?.opts?.cookies) {
if (test.opts.user == name) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Double equals (==) will perform a type conversion when comparing two things, and will handle NaN, -0, and +0 specially to conform to IEEE 754 (so NaN != NaN, and -0 == +0);
  • Triple equals (===) will do the same comparison as double equals (including the special handling for NaN, -0, and +0) but without type conversion; if the types differ, false is returned.

i'm not sure if we would try to do strict equality

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 don't think this matters for 2 strings....

}

if (!config.saveToFile) return
const cookieFile = path.join(global.output_dir, `${name}_session.json`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

may you think we shall store this output_dir in Store?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I was thinking about it... Probably we need to switch to this
but it's too much of refactoring to do

loadCookiesFromFile(config)
}

const loginFunction = async name => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I could be wrong but what if user just puts some name that is not defined in config, shall we handle that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, this should be handled

@DavertMik DavertMik merged commit 7e05e75 into 3.x Jan 28, 2025
12 checks passed
@DavertMik DavertMik deleted the feat/auth-plugin branch January 28, 2025 04:29
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.

2 participants