-
Notifications
You must be signed in to change notification settings - Fork 212
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
test(functional): Convert Robots test, oauth webchannel tests #15379
Conversation
a21899a
to
16454ce
Compare
export enum FirefoxCommand { | ||
FxAStatus = 'fxaccounts:fxa_status', | ||
OAuthLogin = 'fxaccounts:oauth_login', | ||
Logout = 'fxaccounts:logout', |
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 tried using this in a couple other tests and ran into some type issues with createCustomEventDetail
so it might need tweaking but I think this works for now.
We may want to move these from settings into a shared file.
const command = detail.message.command; | ||
const messageId = detail.message.messageId; | ||
|
||
if (command === expectedCommand) { |
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.
@vbudhram I was able to remove the attached div stuff and it passes every time for me, it felt OK to remove. I can also remove some of this if (command === expectedCommand) {
logic and it works, but, I'm not sure we should strip that out yet because I think we may need it in other tests if we need to wait for some event that doesn't fire immediately.
@@ -50,6 +50,9 @@ export const selectors = { | |||
NOT_EMAIL_MET: '#password-same-as-email.password-strength-met', | |||
NOT_EMAIL_FAIL: '#password-same-as-email.password-strength-fail', | |||
PERMISSION_ACCEPT: '#accept', | |||
CWTS_HEADER: 'text="Choose what to sync"', |
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 start using text selectors here where we can, it's less work when we get to the React conversion work.
await this.page.locator(selectors.SUBMIT).click(); | ||
return waitForNavigation; | ||
// return waitForNavigation; |
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.
Wanted to see if removing this made stuff fail (having trouble running them all locally), for some reason when this is left my new tests don't pass. It just hangs after clicking submit on the account confirmation page. If there's a bunch of failures this'll be the cause and I'll tweak.
edit: yeah, things be failing. Looking now.
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 we make the change here so that all the failing tests works now? @LZoog
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.
Yes that's right! See this comment.
Whenever there's more than a couple of parameters passed like we were doing, an options
object can start to feel a bit nicer so I did go ahead and have to make those changes across files.
@@ -355,6 +358,24 @@ export class LoginPage extends BaseLayout { | |||
return this.page.locator(selectors.SUBMIT).click(); | |||
} | |||
|
|||
async waitForCWTSHeader() { | |||
await this.page.waitForSelector(selectors.CWTS_HEADER, { |
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 don't think our other tests with this...
return this.page.isVisible(selectors.SYNC_CONNECTED_HEADER, {
timeout: 100,
});
... actually wait. It looks like isVisible
executes immediately, even if I slapped a 5000 second timeout it wouldn't wait. Personally I think simply using this.page.waitForSelector
in our selector checks and then a simple await waitForCWTSHeader();
call is nice over checking for truthiness anyway; if it doesn't find the element the test fails.
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'm onboard to make this change 👍🏽
@@ -28,3 +28,13 @@ test.describe('severity-1', () => { | |||
expect(await relier.isLoggedIn()).toBe(true); | |||
}); | |||
}); | |||
|
|||
test.describe('robots.txt', () => { |
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'd written this one a while ago, I can remove if we no longer want this test but we don't have any unit tests for it so it seems good to leave to me?
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 can leave it on here!
Because: * We're converting tests from intern to playwright This commit: * Converts oauth_webchannel.js, robots.txt tests * Does not port over ios v1 sign up since we don't need to support it any longer * Tweaks fillOutFirstSignUp to give it an options argument Closes FXA-5923
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, added just one question about the failing tests you mentioned. Also since you tweaked the fillOutFirstSignUp(), I am guessing we made the changes on all the files that's using the function (I do see a lot of files where you have already made the changes but just wanted to double check :)). I will wait for @vbudhram to approve this though. Thanks @LZoog for working on this!
@@ -28,3 +28,13 @@ test.describe('severity-1', () => { | |||
expect(await relier.isLoggedIn()).toBe(true); | |||
}); | |||
}); | |||
|
|||
test.describe('robots.txt', () => { |
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 can leave it on here!
await this.page.locator(selectors.SUBMIT).click(); | ||
return waitForNavigation; | ||
// return waitForNavigation; |
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 we make the change here so that all the failing tests works now? @LZoog
async submit() { | ||
const waitForNavigation = this.page.waitForNavigation(); | ||
async submit(waitForNav = true) { | ||
if (waitForNav) { |
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.
Would you be able to use waitForUrl
and have it accept a RegEx of possible paths? I haven't seen these waitForNavigation
errors pop up in a while though.
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 we should be able to and that it's the recommendation now:
I could change this for the one test, but I think that might be better in a follow up since we'd still need some conditional here until we do it across the board for all tests that use this - it looks like we call this.submit
in login.ts
for various things like setTotp
and setNewPassword
etc. so we need to pass the expected URL regex in there when we call this.submit
.
test.describe('robots.txt', () => { | ||
test('should allow bots to access all pages', async ({ target, page }) => { | ||
await page.goto(`${target.contentServerUrl}/robots.txt`, { | ||
waitUntil: 'networkidle', |
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.
From latest docs 😅 -networkidle - **DISCOURAGED** consider operation to be finished when there are no network connections for at least
500 ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
Not for this PR but good for follow up.
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.
@LZoog Thank you!
Because:
This commit:
Closes FXA-5923
Previous notes below.
In 5d21ba8, I can see the event received here but then it's not picked up in the oauth web channel broker in fxaStatus.
I then tried just doing a copy-over of what we're doing in content-server in a872784, e.g. going to 123done and going through email-first with the context param, then hitting
respondToWebChannelMessage
. It finds the newly created attached div, but I don't even see the event in web-channel.js or fxaStatus.Since we're not receiving the event in fxaStatus to update
capabilities
,_getSyncEngines
in CWTS fails, causing a 500.I originally tried some things with
checkWebChannelMessage
with no luck, but maybe I'm missing something. I'll try a combination of this instead of a listener with dispatching the response, but after that I'll probably have hit a wall here.Will close FXA-5923