-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some mocking to make UI behaviour easier to control.
- Loading branch information
1 parent
7c1d628
commit 06132b9
Showing
18 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
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 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
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,21 @@ | ||
import { test } from './page-objects'; | ||
import {expect} from '@playwright/test' | ||
import {accountsData} from './fixtures/data/accounts'; | ||
import { send } from './fixtures/mocks/send' | ||
import { pollFinished, pollInProgress } from './fixtures/mocks/poll'; | ||
|
||
test('Fund account using the faucet @mocks', async ({ page, home, faucet , mockHelper}) => { | ||
|
||
await page.goto('/'); | ||
await home.header.setNetwork("Testnet") | ||
await home.header.goTo('Faucet') | ||
|
||
await mockHelper.mockResponse('**/send', send) | ||
await faucet.fundAccount(accountsData.publicKey, "0") | ||
|
||
|
||
await mockHelper.mockResponse('**/poll', pollInProgress) | ||
await expect(await faucet.notification.getTitle()).toHaveText('Transaction is being processed...') | ||
await mockHelper.mockResponse('**/poll', pollFinished) | ||
await expect(await faucet.notification.getTitle()).toHaveText('Transaction successfully completed') | ||
}); |
File renamed without changes.
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,48 @@ | ||
export const pollInProgress = {} | ||
export const pollFinished = { | ||
"rNk4ePNVlJGwjCaVrjKFJbh3A0agpcZq6gYLfivOHYg": { | ||
"gas": 940, | ||
"result": { | ||
"status": "success", | ||
"data": "Write succeeded" | ||
}, | ||
"reqKey": "rNk4ePNVlJGwjCaVrjKFJbh3A0agpcZq6gYLfivOHYg", | ||
"logs": "GXRNaJAVVqBrZA05zJ1B66VRzos09z-s9M9LQAXdkvY", | ||
"events": [ | ||
{ | ||
"params": [ | ||
"faucet-operation", | ||
"k:db776793be0fcf8e76c75bdb35a36e67f298111dc6145c66693b0133192e2616", | ||
9.4e-6 | ||
], | ||
"name": "TRANSFER", | ||
"module": { | ||
"namespace": null, | ||
"name": "coin" | ||
}, | ||
"moduleHash": "rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4" | ||
}, | ||
{ | ||
"params": [ | ||
"coin-faucet", | ||
"938c8ec66283493844c205481f220cfbd7024bda5859c7897141f6a5c6fc52c1", | ||
100 | ||
], | ||
"name": "TRANSFER", | ||
"module": { | ||
"namespace": null, | ||
"name": "coin" | ||
}, | ||
"moduleHash": "rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4" | ||
} | ||
], | ||
"metaData": { | ||
"blockTime": 1696849672176432, | ||
"prevBlockHash": "FxZHHgag5dS7f3hyNDVnTmeVOZZkdGtyvnqbkKspzVw", | ||
"blockHash": "VnK4519k7MtweHWj9lENGQuIX_3plQj67LNAhgBljSc", | ||
"blockHeight": 3672752 | ||
}, | ||
"continuation": null, | ||
"txId": 3753319 | ||
} | ||
} |
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 @@ | ||
export const send = {"requestKeys":["rNk4ePNVlJGwjCaVrjKFJbh3A0agpcZq6gYLfivOHYg"]} |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,16 @@ | ||
import type { Page } from '@playwright/test'; | ||
|
||
export default class MockHelper { | ||
private readonly _page: Page; | ||
public constructor(page: Page) { | ||
this._page = page; | ||
} | ||
|
||
async mockResponse(uri: string|RegExp, response: object ): Promise<void> { | ||
await this._page.route(uri, async (route) => { | ||
const json = response; | ||
await route.fulfill({ json }); | ||
}); | ||
} | ||
|
||
} |
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