-
-
Notifications
You must be signed in to change notification settings - Fork 267
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(e2e): Migrated e2e tests for metadata providers api errors #16443
base: develop
Are you sure you want to change the base?
Conversation
7ba04e9
to
1f0468f
Compare
1f0468f
to
7c0e54b
Compare
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 have suggested few improvements - up to discussion
The original tests missed some key verifications, I know we plan to do bigger refactoring but I would still proposed adding those few expects
And I need help understanding one or two things.
@@ -1,5 +1,6 @@ | |||
import { Page } from '@playwright/test'; | |||
|
|||
import * as metadataUtils from '@trezor/suite/src/utils/suite/metadata'; |
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.
let's do focus importing
import * as metadataUtils from '@trezor/suite/src/utils/suite/metadata'; | |
import { encrypt } from '@trezor/suite/src/utils/suite/metadata'; |
@@ -77,11 +78,30 @@ export class MetadataProviderMock { | |||
} | |||
|
|||
@step() | |||
stop() { | |||
setNextResponse(response: Record<string, any>): void { | |||
if (!this.providerMock) { | |||
throw new Error('Provider mock not initialized'); |
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.
Let's DRY this if (!this.providerMock)
block by introducing a getter that will do the assertion and throw :)
await onboardingPage.completeOnboarding(); | ||
await dashboardPage.discoveryShouldFinish(); | ||
|
||
await settingsPage.navigateTo('application'); | ||
await settingsPage.metadataSwitch.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.
Potential to DRY these steps to before each.
not sure before which steps metadataProviderMock.setFileContent needs to be set tho ...
packages/suite-desktop-core/e2e/tests/metadata/dropbox-api-errors.test.ts
Show resolved
Hide resolved
await metadataPage.metadataInput.fill('Kvooo'); | ||
await page.keyboard.press('Enter'); | ||
|
||
// Validate the error message in the toast notification | ||
await expect(page.getByTestId('@toast/error')).toHaveText( | ||
'Error: Failed to save labeling data: Error in call to API function "files/upload": The given OAuth 2 access token is malformed.', | ||
); |
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.
Can we add a validation that the label has still the original text?
await expect(metadataPage.accountLabel(AccountLabelId.BitcoinDefault1)).toHaveText('<original name>')
metadataProviderMock.setNextResponse({ | ||
status: 200, | ||
body: { | ||
name: { | ||
given_name: 'dog', | ||
surname: 'cat', | ||
familiar_name: 'kitty-dog', | ||
display_name: 'dog-cat', | ||
abbreviated_name: 'DC', | ||
}, | ||
email: 'some@mail.com', | ||
email_verified: true, | ||
profile_photo_url: 'foo', | ||
disabled: false, | ||
country: 'CZ', | ||
locale: 'en', | ||
referral_link: 'foo', | ||
is_paired: false, | ||
}, | ||
}); | ||
|
||
metadataProviderMock.setNextResponse({ | ||
status: 429, | ||
body: 'Rate limited!', | ||
headers: { | ||
'Content-Type': 'text/plain; charset=utf-8', | ||
}, | ||
}); |
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 dont understand this part. Can we have a short call so I could get the context
I dont get the order of those two. Responses are served as FIFO
I found similar object in packages/e2e-utils/src/mocks/dropbox.ts:77:
// https://api.dropboxapi.com/2/users/get_current_account
app.post('/2/users/get_current_account', (_req, res) => {
const user = {
name: {
given_name: 'dog',
surname: 'cat',
familiar_name: 'kitty-dog',
display_name: 'dog-cat',
abbreviated_name: 'DC',
},
email: 'some@mail.com',
email_verified: true,
profile_photo_url: 'foo',
disabled: false,
country: 'CZ',
locale: 'en',
referral_link: 'foo',
is_paired: false,
};
await page.getByTestId('@account-menu/btc/normal/0').click(); | ||
await metadataPage.editLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); | ||
}); |
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.
Test does not have any verification of success of that the initial try failed and succeded on retry (not sure that info about retring is vibisble)
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.
await expect(metadataPage.accountLabel(AccountLabelId.BitcoinDefault1)).toHaveText('Kvooo')
await metadataPage.editLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); | ||
}); | ||
|
||
test('Incomplete data returned from provider', async ({ |
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 dont understand the impact of 'incomplete data' on suite and what should happen and what shouldn't.
Like should the rename fail? or is it just that the comunication is retried and does not fall apartt.
Maybe this is a candidate for the later refactoring. I have feeling that we miss some verifications here
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 my understanding of the original test, the ability to rename the label after the incomplete data is sent is the verification
Description
Migrated tests for metadata provider API errors
Related Issue
Resolve
Screenshots: