-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate network tests, closes #3707
- Loading branch information
1 parent
068d3cd
commit b1831fb
Showing
5 changed files
with
87 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Page } from '@playwright/test'; | ||
import { NetworkSelectors } from '@tests/selectors/network.selectors'; | ||
import { createTestSelector } from '@tests/utils'; | ||
|
||
export class NetworkPage { | ||
readonly networkNameSelector = createTestSelector(NetworkSelectors.NetworkName); | ||
readonly networkAddressSelector = createTestSelector(NetworkSelectors.NetworkAddress); | ||
readonly networkKeySelector = createTestSelector(NetworkSelectors.NetworkKey); | ||
readonly btnAddNetworkSelector = createTestSelector(NetworkSelectors.BtnAddNetwork); | ||
readonly errorTextSelector = createTestSelector(NetworkSelectors.ErrorText); | ||
|
||
constructor(readonly page: Page) {} | ||
|
||
async inputNetworkNameField(input: string) { | ||
const field = this.page.locator(this.networkNameSelector); | ||
await field?.type(input); | ||
} | ||
|
||
async inputNetworkAddressField(input: string) { | ||
const field = this.page.locator(this.networkAddressSelector); | ||
await field?.type(input); | ||
} | ||
|
||
async inputNetworkKeyField(input: string) { | ||
const field = this.page.locator(this.networkKeySelector); | ||
await field?.type(input); | ||
} | ||
|
||
async waitForErrorMessage() { | ||
await this.page.waitForSelector(this.errorTextSelector); | ||
} | ||
|
||
async getErrorMessage() { | ||
return this.page.locator(this.errorTextSelector); | ||
} | ||
|
||
async clickAddNetwork() { | ||
await this.page.locator(this.btnAddNetworkSelector).click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export enum NetworkSelectors { | ||
NetworkName = 'network-name', | ||
NetworkAddress = 'network-address', | ||
NetworkKey = 'network-key', | ||
BtnAddNetwork = 'btn-add-network', | ||
ErrorText = 'error-text', | ||
EmptyAddressError = 'Enter a valid URL', | ||
NoNodeFetch = 'Unable to fetch info from node.', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { NetworkSelectors } from '@tests/selectors/network.selectors'; | ||
import { SettingsSelectors } from '@tests/selectors/settings.selectors'; | ||
|
||
import { test } from '../../fixtures/fixtures'; | ||
|
||
test.describe('Networks tests', () => { | ||
test.beforeEach(async ({ extensionId, globalPage, onboardingPage, homePage, page }) => { | ||
await globalPage.setupAndUseApiCalls(extensionId); | ||
await onboardingPage.signInWithTestAccount(extensionId); | ||
await homePage.clickSettingsButton(); | ||
await page.getByTestId(SettingsSelectors.ChangeNetworkAction).click(); | ||
await page.getByTestId(SettingsSelectors.BtnAddNetwork).click(); | ||
}); | ||
|
||
test('validation error when address is empty', async ({ page, networkPage }) => { | ||
await networkPage.clickAddNetwork(); | ||
await networkPage.waitForErrorMessage(); | ||
|
||
const errorMsgElement = await networkPage.getErrorMessage(); | ||
const errorMessage = await errorMsgElement.innerText(); | ||
test.expect(errorMessage).toEqual(NetworkSelectors.EmptyAddressError); | ||
}); | ||
|
||
test('unable to fetch info from node', async ({ networkPage }) => { | ||
await networkPage.inputNetworkAddressField('https://www.google.com/'); | ||
await networkPage.inputNetworkKeyField('test-network'); | ||
await networkPage.clickAddNetwork(); | ||
await networkPage.waitForErrorMessage(); | ||
const errorMsgElement = await networkPage.getErrorMessage(); | ||
const errorMessage = await errorMsgElement.innerText(); | ||
test.expect(errorMessage).toEqual(NetworkSelectors.NoNodeFetch); | ||
}); | ||
}); |