From 45202f1c6e1e9001ae54fffef5bc600afe63370b Mon Sep 17 00:00:00 2001 From: jfawChia <105236411+jfawChia@users.noreply.github.com> Date: Wed, 23 Aug 2023 18:08:41 -0400 Subject: [PATCH] Refactoring playwright scripts to point to designated wallet (#1899) Co-authored-by: Zsolt Szabo Co-authored-by: William Allen --- .eslintrc.json | 2 +- package-lock.json | 1 + packages/gui/package.json | 1 + packages/gui/src/tests/util/utils.test.js | 23 -------- .../data_object_model/passphrase_login.ts | 5 ++ .../offers/offer_created_via_nft.spec.ts | 5 +- .../offers/offer_transfer_via_nft.spec.ts | 12 ++-- .../tests/plots/cancel_create_plot.spec.ts | 40 +++++++++++++ .../tests/plots/create_delete_plot.spec.ts | 57 +++++++++++++++++++ .../create_delete_wallet.spec.ts | 17 +----- .../key_import_negative_test.spec.ts | 3 +- .../paste_key_import_negative_test.spec.ts | 4 +- .../select_key_page/rename_wallet.spec.ts | 14 ++--- .../rename_wallet_existing_name.spec.ts | 14 ++--- .../gui/tests/settings/auto_login.spec.ts | 8 +-- .../tests/settings/data_layer_test.spec.ts | 7 +-- .../tests/settings/passphrase_test.spec.ts | 10 ++-- .../gui/tests/settings/settings_test.spec.ts | 4 +- .../receive_generatenew_address.spec.ts | 19 +++---- .../gui/tests/tokens/receive_txch.spec.ts | 10 ++-- .../tests/tokens/send_amount_greater.spec.ts | 16 +++--- .../gui/tests/tokens/send_error_page.spec.ts | 12 ++-- .../gui/tests/tokens/send_fee_txch.spec.ts | 15 ++--- 23 files changed, 172 insertions(+), 127 deletions(-) delete mode 100644 packages/gui/src/tests/util/utils.test.js create mode 100644 packages/gui/tests/plots/cancel_create_plot.spec.ts create mode 100644 packages/gui/tests/plots/create_delete_plot.spec.ts diff --git a/.eslintrc.json b/.eslintrc.json index dced3641c2..7b09f937cb 100755 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -102,7 +102,7 @@ // You can change the file name extension to .dev.ts to avoid the: "XX should be listed in the project's dependencies, not devDependencies." "**/*.dev.{js,jsx,ts,tsx}" ], - "optionalDependencies": false + "optionalDependencies": true } ], diff --git a/package-lock.json b/package-lock.json index a06d8e272e..d220e5f64a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24571,6 +24571,7 @@ "concurrently": "8.2.1", "copy-webpack-plugin": "11.0.0", "cross-env": "7.0.3", + "date-and-time": "2.4.3", "css-loader": "6.8.1", "electron": "26.0.0", "electron-devtools-assembler": "1.2.0", diff --git a/packages/gui/package.json b/packages/gui/package.json index e17ccbace2..75ae649be5 100644 --- a/packages/gui/package.json +++ b/packages/gui/package.json @@ -242,6 +242,7 @@ "concurrently": "8.2.1", "copy-webpack-plugin": "11.0.0", "cross-env": "7.0.3", + "date-and-time": "2.4.3", "css-loader": "6.8.1", "electron": "26.0.0", "electron-devtools-assembler": "1.2.0", diff --git a/packages/gui/src/tests/util/utils.test.js b/packages/gui/src/tests/util/utils.test.js deleted file mode 100644 index 7cdf1e83ac..0000000000 --- a/packages/gui/src/tests/util/utils.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const utils = require('../../util/utils'); - -describe('utils', () => { - describe('#hexToArray', () => { - it('converts lowercase hex string to an array', () => { - const result = utils.hexToArray('0xeeaa'); - - expect(result).toEqual([238, 170]); - }); - it('converts uppercase hex string to an array', () => { - const result = utils.hexToArray('0xEEAA'); - - expect(result).toEqual([238, 170]); - }); - }); - describe('#arrToHex', () => { - it('converts an array to a hex string', () => { - const result = utils.arrToHex([238, 170]); - - expect(result).toBe('eeaa'); - }); - }); -}); diff --git a/packages/gui/tests/data_object_model/passphrase_login.ts b/packages/gui/tests/data_object_model/passphrase_login.ts index 4601582096..44dab6a8d4 100644 --- a/packages/gui/tests/data_object_model/passphrase_login.ts +++ b/packages/gui/tests/data_object_model/passphrase_login.ts @@ -23,6 +23,11 @@ export class LoginPage { await this.page.locator('text=Unlock Keyring').click(); } + async getPlayWrightWallet() { + // Get the Playwright Wallet + await this.page.locator('h6:has-text("playwright")').click(); + } + async changePassphrase() { // Given I enter my Current Passphrase await this.page diff --git a/packages/gui/tests/offers/offer_created_via_nft.spec.ts b/packages/gui/tests/offers/offer_created_via_nft.spec.ts index 1c31d4a6d3..7c52d85dba 100644 --- a/packages/gui/tests/offers/offer_created_via_nft.spec.ts +++ b/packages/gui/tests/offers/offer_created_via_nft.spec.ts @@ -20,7 +20,10 @@ test('Verify that an Offer can created via the NFT page', async () => { //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); - // Given I navigate to an NFT page within wallet + //Given I navigate to a Wallet + //await new LoginPage(page).getPlayWrightWallet() + + //Given I navigate to an NFT page within wallet await page.getByRole('button', { name: 'Jahi 1st Wallet' }).click(); //When I create an offer for an NFT diff --git a/packages/gui/tests/offers/offer_transfer_via_nft.spec.ts b/packages/gui/tests/offers/offer_transfer_via_nft.spec.ts index af86ded749..31eddfa590 100644 --- a/packages/gui/tests/offers/offer_transfer_via_nft.spec.ts +++ b/packages/gui/tests/offers/offer_transfer_via_nft.spec.ts @@ -1,8 +1,6 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import { CloseDialog } from '../data_object_model/close_dialog'; -import date from 'date-and-time'; -const now = new Date(); let electronApp: ElectronApplication; let page: Page; @@ -18,14 +16,14 @@ test.afterAll(async () => { test('Verify that an NFT can be Transfer to another account', async () => { //Pre-requisites - let receive_nft_wallet = 'txch15zuw5285d075w8ge99sz23tdcf9kyq2pzez9x3x82z22l5u8g68qs5gec8'; - let send_wallet = 'txch1z23pn6l698hxygxrrdz0sz3j87dnuylp52d53h96tl4g5p09qtes5r5r2f'; + let ReceiveNftWallet = 'txch15zuw5285d075w8ge99sz23tdcf9kyq2pzez9x3x82z22l5u8g68qs5gec8'; + let SendNftWallet = 'txch1z23pn6l698hxygxrrdz0sz3j87dnuylp52d53h96tl4g5p09qtes5r5r2f'; //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); // Given I am in a Wallet with NFTs - await page.getByRole('button', { name: 'receive_nft_wallet' }).click(); + await page.getByRole('button', { name: 'ReceiveNftWallet' }).click(); //await page.pause(); //When I navigate to the NFTs tab and select an NFT @@ -34,7 +32,7 @@ test('Verify that an NFT can be Transfer to another account', async () => { //Then I should be able to transfer the NFT to another account await page.getByRole('menuitem', { name: 'Transfer NFT' }).click(); - await page.getByLabel('Send to Address *').type(send_wallet); + await page.getByLabel('Send to Address *').type(SendNftWallet); await page.getByRole('button', { name: '0 (>5 min) TXCH' }).click(); await page.getByRole('option', { name: 'Enter a custom fee...' }).click(); await page.getByLabel('Fee').fill('0.00003'); @@ -55,7 +53,7 @@ test('Verify that an NFT can be Transfer to another account', async () => { await page.waitForSelector('text=Bobble #3', { state: 'visible', timeout: 300000 }); await page.getByRole('button', { name: 'Bobble #3' }).getByRole('button').click(); await page.getByRole('menuitem', { name: 'Transfer NFT' }).click(); - await page.getByLabel('Send to Address *').type(receive_nft_wallet); + await page.getByLabel('Send to Address *').type(ReceiveNftWallet); await page.getByRole('button', { name: '0 (>5 min) TXCH' }).click(); await page.getByRole('option', { name: 'Enter a custom fee...' }).click(); await page.getByLabel('Fee').fill('0.00003'); diff --git a/packages/gui/tests/plots/cancel_create_plot.spec.ts b/packages/gui/tests/plots/cancel_create_plot.spec.ts new file mode 100644 index 0000000000..efa91deb95 --- /dev/null +++ b/packages/gui/tests/plots/cancel_create_plot.spec.ts @@ -0,0 +1,40 @@ +import { ElectronApplication, Page, _electron as electron } from 'playwright'; +import { test } from '@playwright/test'; +import { LoginPage } from '../data_object_model/passphrase_login'; + +let electronApp: ElectronApplication; +let page: Page; + +test.beforeAll(async () => { + electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); + page = await electronApp.firstWindow(); +}); + +test.afterAll(async () => { + await page.close(); +}); + +//Works and Passes +test('Confirm can Create and Delete a Plot. ', async () => { + //Pre-requisites to get user back to Wallet selection page + await page.locator('button:has-text("Close")').click(); + + //Given I navigate to a Wallet + await new LoginPage(page).getPlayWrightWallet(); + + //And I click on the Plots Icon + await page.getByTestId('DashboardSideBar-plots').click(); + + //And I click on ADD A PLOT + await page.getByRole('button', { name: '+ Add a Plot' }).click(); + + //When I add a Plot to a Plot NFT + await page.getByRole('button', { name: 'Chia Proof of Space 1.0.11' }).click(); + await page.getByRole('option', { name: 'Chia Proof of Space 1.0.11' }).click(); + await page.getByRole('button', { name: '101.4GiB (k=32, temporary space: 239GiB)' }).click(); + await page.getByRole('option', { name: '208.8GiB (k=33, temporary space: 521GiB)' }).click(); + + //Then I can Discard Plot Creation + await page.locator('[data-testid="ArrowBackIosNewIcon"]').click(); + await page.getByRole('button', { name: 'Discard' }).click(); +}); diff --git a/packages/gui/tests/plots/create_delete_plot.spec.ts b/packages/gui/tests/plots/create_delete_plot.spec.ts new file mode 100644 index 0000000000..354f9aac98 --- /dev/null +++ b/packages/gui/tests/plots/create_delete_plot.spec.ts @@ -0,0 +1,57 @@ +// import { ElectronApplication, Page, _electron as electron } from 'playwright'; +// import { test} from '@playwright/test'; + +// let electronApp: ElectronApplication; +// let page: Page; + +// test.beforeAll(async () => { +// electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); +// page = await electronApp.firstWindow(); +// }); + +// test.afterAll(async () => { +// await page.close(); +// }); + +// //BROWERS FEATURE WILL BE CHANGING. WILL IMPEMENT THIS AFTER!! +// test('Confirm can Create and Delete a Plot. ', async () => { +// //Pre-requisites to get user back to Wallet selection page +// await page.locator('button:has-text("Close")').click(); + +// //Given I navigate to a Wallet +// await page.locator('h6:has-text("playwright")').click(); + +// //And I click on the Plots Icon +// await page.getByTestId('DashboardSideBar-plots').click(); + +// //And I click on ADD A PLOT +// await page.getByRole('button', { name: '+ Add a Plot' }).click(); + +// //When I add a Plot Size +// await page.getByRole('button', { name: 'Chia Proof of Space 1.0.11' }).click(); +// await page.getByRole('option', { name: 'Chia Proof of Space 1.0.11' }).click(); + +// //And I set the location +// await page.getByRole('button', { name: 'Browse' }).first().click(); +// await page.on('dialog', (dialog) => dialog.accept()); + +// //await page.getByRole('button', { name: 'Close' }).click(); +// //await page.getByRole('button', { name: '🧜 Jahi 1st Wallet 1922132445 more' }).click(); + +// // await page.getByLabel('Temporary folder location *').click(); +// // await page.getByLabel('Final folder location *').click(); +// // await page.locator('div').filter({ hasText: 'Final folder location * Selected' }).getByRole('button', { name: 'Selected' }).click(); +// // await page.locator('#mui-component-select-p2SingletonPuzzleHash').click(); +// // await page.getByRole('option', { name: 'Maroon Narwhal' }).click(); +// // await page.getByRole('button', { name: 'Create' }).click(); +// // await page.getByRole('row', { name: 'K-32, 101.348 GiB 0x8fa56b619e3b6d05c83412f839289dc1d90c4f92ab46ce98fd1b5b4309ab656bae6c92ab8b9769efbf1d31825c3eb647 txch17j7llengm98vtsdr03x0nz92l73hhszz58celd34vc68y69th5xsjg8f6d /Users/jahifaw/Downloads/plot-k32-2023-02-22-14-24-292325f6852d3b371917b32701e832fba2a333cedf73ce3b8845faff94b34983.plot Not Available more' }).getByRole('button', { name: 'more' }).click(); +// // await page.getByRole('menuitem', { name: 'Delete' }).click(); +// // await page.getByRole('button', { name: 'Delete' }).click(); + +// // await page.locator('#mui-component-select-p2SingletonPuzzleHash').click(); +// // await page.getByRole('option', { name: 'Orange Peafowl' }).click(); + +// await page.locator('div').filter({ hasText: 'Add a Plot' }).getByRole('button').click(); +// await page.getByText('You have made changes. Do you want to discard them?').click(); +// await page.getByRole('button', { name: 'Discard' }).click(); +// }); diff --git a/packages/gui/tests/select_key_page/create_delete_wallet.spec.ts b/packages/gui/tests/select_key_page/create_delete_wallet.spec.ts index f23fd99dcb..f2193e4a3e 100644 --- a/packages/gui/tests/select_key_page/create_delete_wallet.spec.ts +++ b/packages/gui/tests/select_key_page/create_delete_wallet.spec.ts @@ -1,8 +1,5 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { LoginPage } from '../data_object_model/passphrase_login'; -import { isWalletSynced, getWalletBalance } from '../utils/wallet'; -import { waitForDebugger } from 'inspector'; import { CloseDialog } from '../data_object_model/close_dialog'; let electronApp: ElectronApplication; @@ -17,6 +14,7 @@ test.afterAll(async () => { await page.close(); }); +//PASSED AS OF 7/9/2023 test('Create a new Wallet , logout and Delete new Wallet', async () => { //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); @@ -28,17 +26,15 @@ test('Create a new Wallet , logout and Delete new Wallet', async () => { await page.getByText('Create New').click(); //When I enter a Wallet Name - // await page.getByLabel('Wallet Name').fill('New Wallet'); await page.locator('text=Wallet NameWallet Name >> input[type="text"]').fill('New Wallet'); //And I click on the Next button await page.getByRole('button', { name: 'Next' }).click(); - //await page.locator('button:has-text("Next")').click(); //And I save the Wallet ID of the wallet await page.waitForTimeout(10000); const deleteWallet = await page.$eval('[data-testid="LayoutDashboard-fingerprint"]', (el) => el.textContent); - console.log(deleteWallet); + //console.log(deleteWallet); const newlyDeleteWallet = deleteWallet.trim(); //Then I am able to check the balance of that wallet @@ -68,13 +64,4 @@ test('Create a new Wallet , logout and Delete new Wallet', async () => { expect( await page.locator(`[data-testid="SelectKeyItem-fingerprint-${newlyDeleteWallet}"] [aria-label="more"]`).count() ).toEqual(0); - - // - - // await page.getByTestId('SelectKeyItem-fingerprint-1362932744').getByRole('button', { name: 'more', exact: true }).click(); - // await page.getByText('Delete', { exact: true }).click(); - // await page.getByRole('heading', { name: 'Delete key 1362932744' }).click(); - // await page.getByLabel('Wallet Fingerprint').click(); - // await page.getByLabel('Wallet Fingerprint').fill('1362932744'); - // await page.getByRole('button', { name: 'Delete' }).click(); }); diff --git a/packages/gui/tests/select_key_page/key_import_negative_test.spec.ts b/packages/gui/tests/select_key_page/key_import_negative_test.spec.ts index de2ff66e14..d13a482ffc 100644 --- a/packages/gui/tests/select_key_page/key_import_negative_test.spec.ts +++ b/packages/gui/tests/select_key_page/key_import_negative_test.spec.ts @@ -6,8 +6,6 @@ import { ReadData } from '../data_object_model/read_data_file'; let electronApp: ElectronApplication; let page: Page; -let dataFile = require('../data_fixtures/data.json'); - test.beforeAll(async () => { electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); page = await electronApp.firstWindow(); @@ -17,6 +15,7 @@ test.afterAll(async () => { await page.close(); }); +//PASSED AS OF 7/9/23 test('Read data from Json file', async () => { //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); diff --git a/packages/gui/tests/select_key_page/paste_key_import_negative_test.spec.ts b/packages/gui/tests/select_key_page/paste_key_import_negative_test.spec.ts index 1419424ebd..4a6824e084 100644 --- a/packages/gui/tests/select_key_page/paste_key_import_negative_test.spec.ts +++ b/packages/gui/tests/select_key_page/paste_key_import_negative_test.spec.ts @@ -17,6 +17,7 @@ test.afterAll(async () => { await page.close(); }); +//PASSED AS OF 7/9/23 test('Read data from Json file and Paste in Mnemonic', async () => { //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); @@ -32,7 +33,7 @@ test('Read data from Json file and Paste in Mnemonic', async () => { //And I click on PASTE MNEMONIC await page.getByRole('button', { name: 'Paste Mnemonic' }).click(); - await page.pause(); + //await page.pause(); //And I enter the first 24 words of the mnemonic //await new ReadData(page).pasteWords(); await page @@ -46,7 +47,6 @@ test('Read data from Json file and Paste in Mnemonic', async () => { //And I click on PASTE MNEMONIC and complete Import process await page.getByRole('button', { name: 'Paste Mnemonic' }).click(); - //await page.locator('#mui-52').fill(' "abandon" "ability" "able" "about" "above" "absent" "baby" "bachelor" "bacon" "badge" "bag" "balance" "cabbage" "cabin" "cable" "cactus" "cage" "cake" "dad" "damage" "damp" "dance" "danger" "daring"'); await new ReadData(page).pasteWords(); await page.getByRole('button', { name: 'Import' }).click(); await page.getByRole('button', { name: 'Next' }).click(); diff --git a/packages/gui/tests/select_key_page/rename_wallet.spec.ts b/packages/gui/tests/select_key_page/rename_wallet.spec.ts index 8543564473..d87332ab00 100644 --- a/packages/gui/tests/select_key_page/rename_wallet.spec.ts +++ b/packages/gui/tests/select_key_page/rename_wallet.spec.ts @@ -1,8 +1,5 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { LoginPage } from '../data_object_model/passphrase_login'; -import { isWalletSynced, getWalletBalance } from '../utils/wallet'; -import { waitForDebugger } from 'inspector'; import { CloseDialog } from '../data_object_model/close_dialog'; let electronApp: ElectronApplication; @@ -18,14 +15,15 @@ test.afterAll(async () => { }); test('Verify that renaming work and canceling the renaming wallet flow works.', async () => { - const orgName = 'Jahi 1st Wallet'; + const orgName = 'playwright'; const newName = 'MyChiaMainWallet'; + const fingerprint = '314593068'; //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); //Given I click on miniMenu on a Wallet name - await page.locator('[data-testid="SelectKeyItem-fingerprint-1922132445"] [aria-label="more"]').click(); + await page.locator(`[data-testid="SelectKeyItem-fingerprint-${fingerprint}"] [aria-label="more"]`).click(); //And I click on rename option await page.locator('text=Rename').click(); @@ -40,14 +38,14 @@ test('Verify that renaming work and canceling the renaming wallet flow works.', await expect(page.locator(`h6:has-text("${orgName}")`)).toBeVisible(); //Given I rename the Wallet and save - await page.locator('[data-testid="SelectKeyItem-fingerprint-1922132445"] [aria-label="more"]').click(); + await page.locator(`[data-testid="SelectKeyItem-fingerprint-${fingerprint}"] [aria-label="more"]`).click(); await page.locator('text=Rename').click(); await page.locator('[data-testid="SelectKeyRenameForm-label"]').fill(newName); await page.locator('[data-testid="SelectKeyRenameForm-save"]').click(); //Then new name displays inside of App await page.waitForTimeout(10000); - await page.locator('[data-testid="SelectKeyItem-fingerprint-1922132445"]').click(); + await page.locator(`[data-testid="SelectKeyItem-fingerprint-${fingerprint}"]`).click(); await expect(page.locator(`text=${newName}`)).toBeVisible(); //await page.locator('[data-testid="ExitToAppIcon"]').click(); await page.locator('[data-testid="LayoutDashboard-log-out"]').click(); @@ -57,7 +55,7 @@ test('Verify that renaming work and canceling the renaming wallet flow works.', expect(await page.locator(`h6:has-text("${orgName}")`).count()).toEqual(0); //Reset Test Data - await page.locator('[data-testid="SelectKeyItem-fingerprint-1922132445"] [aria-label="more"]').click(); + await page.locator(`[data-testid="SelectKeyItem-fingerprint-${fingerprint}"] [aria-label="more"]`).click(); await page.locator('text=Rename').click(); await page.locator('[data-testid="SelectKeyRenameForm-label"]').fill(orgName); await page.locator('[data-testid="SelectKeyRenameForm-save"]').click(); diff --git a/packages/gui/tests/select_key_page/rename_wallet_existing_name.spec.ts b/packages/gui/tests/select_key_page/rename_wallet_existing_name.spec.ts index 4a50d6740a..d10a34e94c 100644 --- a/packages/gui/tests/select_key_page/rename_wallet_existing_name.spec.ts +++ b/packages/gui/tests/select_key_page/rename_wallet_existing_name.spec.ts @@ -1,7 +1,6 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import { CloseDialog } from '../data_object_model/close_dialog'; -import { waitForDebugger } from 'inspector'; let electronApp: ElectronApplication; let page: Page; @@ -15,9 +14,9 @@ test.afterAll(async () => { await page.close(); }); +//PASSED AS OF 7/9/23 test('Verify that renaming a wallet to an existing wallet name should throw an error.', async () => { - const existingName = 'Jahi 1st Wallet'; - const orgName = 'NFT TESTING WALLET'; + const existingName = 'playwright'; //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); @@ -34,7 +33,8 @@ test('Verify that renaming a wallet to an existing wallet name should throw an e //Assert that error message is displayed await expect(page.locator('div[role="dialog"]')).toHaveText( - "Errormalformed request: label 'Jahi 1st Wallet' already exists for fingerprint '1922132445'OK" + //"Errormalformed request: label 'Jahi 1st Wallet' already exists for fingerprint '1922132445'OK" + "Errormalformed request: label 'playwright' already exists for fingerprint '314593068'OK" ); await page.getByRole('button', { name: 'OK' }).click(); @@ -42,9 +42,5 @@ test('Verify that renaming a wallet to an existing wallet name should throw an e await page.locator('[aria-label="cancel"]').click(); //Then previous name is still displaying - await page.locator('[data-testid="SelectKeyItem-fingerprint-965505910"]').click(); - //await page.pause(); - await page.waitForLoadState(); - await expect(page.getByRole('heading', { name: 'NFT TESTING WALLET' })).toBeVisible(); - //await expect(page.getByRole('heading', { name: orgName })).toBeVisible(); + await page.locator('[data-testid="SelectKeyItem-fingerprint-314593068"]').click(); }); diff --git a/packages/gui/tests/settings/auto_login.spec.ts b/packages/gui/tests/settings/auto_login.spec.ts index 3667f7164c..dae10d185d 100644 --- a/packages/gui/tests/settings/auto_login.spec.ts +++ b/packages/gui/tests/settings/auto_login.spec.ts @@ -1,7 +1,6 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; -import { test, expect } from '@playwright/test'; +import { test } from '@playwright/test'; import { LoginPage } from '../data_object_model/passphrase_login'; -import ChildProcess from 'child_process'; import { stopAllChia } from '../utils/wallet'; let electronApp: ElectronApplication; @@ -19,10 +18,9 @@ test.afterAll(async () => { test('Confirm Enable Auto Login feature works as expected. ', async () => { //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); - //await page.locator('[data-testid="LayoutDashboard-log-out"]').click(); - //Given I navigate to 1922132445 Wallet - await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + //Given I navigate to a Wallet + await new LoginPage(page).getPlayWrightWallet(); //And I navigate to the Setting's Gear await page.locator('[data-testid="DashboardSideBar-settings"]').click(); diff --git a/packages/gui/tests/settings/data_layer_test.spec.ts b/packages/gui/tests/settings/data_layer_test.spec.ts index 1996880034..b57052f6c5 100644 --- a/packages/gui/tests/settings/data_layer_test.spec.ts +++ b/packages/gui/tests/settings/data_layer_test.spec.ts @@ -1,7 +1,6 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import { LoginPage } from '../data_object_model/passphrase_login'; -import ChildProcess from 'child_process'; import { stopAllChia } from '../utils/wallet'; let electronApp: ElectronApplication; @@ -21,8 +20,8 @@ test('Confirm user can navigate and interact with the Settings page in user acce //Pre-requisites to Close Version dialog await page.locator('button:has-text("Close")').click(); - //Given I navigate to 1922132445 Wallet - await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + //Given I navigate to a Wallet + await new LoginPage(page).getPlayWrightWallet(); //Given I navigate to the Setting's Gear await page.locator('[data-testid="DashboardSideBar-settings"]').click(); @@ -41,7 +40,7 @@ test('Confirm user can navigate and interact with the Settings page in user acce electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); page = await electronApp.firstWindow(); await page.locator('button:has-text("Close")').click(); - await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + await new LoginPage(page).getPlayWrightWallet(); //And I navigate back to Data layer tab await page.locator('[data-testid="DashboardSideBar-settings"]').click(); diff --git a/packages/gui/tests/settings/passphrase_test.spec.ts b/packages/gui/tests/settings/passphrase_test.spec.ts index 6a3e6994eb..b2affa93cb 100644 --- a/packages/gui/tests/settings/passphrase_test.spec.ts +++ b/packages/gui/tests/settings/passphrase_test.spec.ts @@ -1,7 +1,6 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; -import { test, expect } from '@playwright/test'; +import { test } from '@playwright/test'; import { LoginPage } from '../data_object_model/passphrase_login'; -import { waitForDebugger } from 'inspector'; import { stopAllChia } from '../utils/wallet'; let electronApp: ElectronApplication; @@ -22,8 +21,8 @@ test('Confirm user can add and remove passphrase ', async () => { //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); - //Given I navigate to 1922132445 Wallet - await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + //Given I navigate to a Wallet + await new LoginPage(page).getPlayWrightWallet(); //And I navigate to Setting's Page await page.locator('div[role="button"]:has-text("Settings")').click(); @@ -56,7 +55,8 @@ test('Confirm user can add and remove passphrase ', async () => { await new LoginPage(page).login('password2023!@'); //Given I navigate back to settings page - await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + //await page.locator('h6:has-text("Jahi 1st Wallet")').click(); + await new LoginPage(page).getPlayWrightWallet(); await page.locator('div[role="button"]:has-text("Settings")').click(); //And I remove passphrase and close chia diff --git a/packages/gui/tests/settings/settings_test.spec.ts b/packages/gui/tests/settings/settings_test.spec.ts index 2f94f72f13..146543f333 100644 --- a/packages/gui/tests/settings/settings_test.spec.ts +++ b/packages/gui/tests/settings/settings_test.spec.ts @@ -1,6 +1,5 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; -import { test, expect } from '@playwright/test'; -import { stopAllChia } from '../utils/wallet'; +import { test } from '@playwright/test'; let electronApp: ElectronApplication; let page: Page; @@ -18,7 +17,6 @@ test.afterAll(async () => { test('Confirm user can navigate and interact with the Settings page in user acceptable manner. ', async () => { //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); - //await page.locator('[data-testid="LayoutDashboard-log-out"]').click(); //Given I navigate to 1922132445 Wallet await page.locator('h6:has-text("Jahi 1st Wallet")').click(); diff --git a/packages/gui/tests/tokens/receive_generatenew_address.spec.ts b/packages/gui/tests/tokens/receive_generatenew_address.spec.ts index dc34cdfc18..288282a9a5 100644 --- a/packages/gui/tests/tokens/receive_generatenew_address.spec.ts +++ b/packages/gui/tests/tokens/receive_generatenew_address.spec.ts @@ -1,10 +1,9 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { LoginPage } from '../data_object_model/passphrase_login'; let electronApp: ElectronApplication; let page: Page; -let appWindow: Page; +//let appWindow: Page; test.beforeAll(async () => { electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); @@ -32,24 +31,24 @@ test('Verify that new address button creates new address', async () => { await page.locator('[data-testid="WalletReceiveAddress-address-copy"]').click(); //Then current wallet address is now stored into a variable - const wallet_address = await page + const walletAddress = await page .locator('text=Receive Address New AddressAddress >> input[type="text"]') .inputValue(); - console.log(wallet_address); + console.log(walletAddress); //When I generate a new wallet address id await page.locator('[data-testid="WalletReceiveAddress-new-address"]').click(); //And I store the new wallet address id in a new variable - const wallet_new = await page.locator('text=Receive Address New AddressAddress >> input[type="text"]').inputValue(); - console.log(wallet_new); + const walletNew = await page.locator('text=Receive Address New AddressAddress >> input[type="text"]').inputValue(); + console.log(walletNew); //And I Compare Values variables. This should be false. wallet_address != wallet_new - if (wallet_address == wallet_new) { - expect(wallet_address).toEqual(wallet_new); + if (walletAddress === walletNew) { + expect(walletAddress).toEqual(walletNew); console.log('The Wallet Address has not been updated!'); - } else if (wallet_address != wallet_new) { - expect(wallet_address).not.toEqual(wallet_new); + } else if (walletAddress !== walletNew) { + expect(walletAddress).not.toEqual(walletNew); console.log('A New Wallet Address has been successfully generated!'); } }); diff --git a/packages/gui/tests/tokens/receive_txch.spec.ts b/packages/gui/tests/tokens/receive_txch.spec.ts index 8427da1821..c8f384ee15 100644 --- a/packages/gui/tests/tokens/receive_txch.spec.ts +++ b/packages/gui/tests/tokens/receive_txch.spec.ts @@ -1,12 +1,10 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { LoginPage } from '../data_object_model/passphrase_login'; import { SendFunds } from '../data_object_model/send_funds'; import { isWalletSynced, getWalletBalance } from '../utils/wallet'; let electronApp: ElectronApplication; let page: Page; -let appWindow: Page; test.beforeAll(async () => { electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); @@ -19,8 +17,8 @@ test.afterAll(async () => { test('Verify that a recipient wallet receives funds from sending wallet!', async () => { //Pre-requisites - let receive_wallet = 'txch17m0jla968szqmw7mf6msaea2jxl553g9m5kx8ryuqadvml8w49tqr75l9y'; - let send_wallet = 'txch1rkk6haccvw095t9ajc6h9tqekm2rz4zwurhep8dcrmsr2q2446zsndld57'; + let receiveWallet = 'txch17m0jla968szqmw7mf6msaea2jxl553g9m5kx8ryuqadvml8w49tqr75l9y'; + let sendWallet = 'txch1rkk6haccvw095t9ajc6h9tqekm2rz4zwurhep8dcrmsr2q2446zsndld57'; //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); @@ -38,7 +36,7 @@ test('Verify that a recipient wallet receives funds from sending wallet!', async await page.locator('[data-testid="WalletHeader-tab-send"]').click(); //When I complete the send page required fields - await new SendFunds(page).send(receive_wallet, '0.01'); //, '0.00000275276505264396'); + await new SendFunds(page).send(receiveWallet, '0.01'); //, '0.00000275276505264396'); //Then I receive a success message await expect(page.locator('div[role="dialog"]')).toHaveText( @@ -73,5 +71,5 @@ test('Verify that a recipient wallet receives funds from sending wallet!', async // Given I send funds back await page.locator('[data-testid="WalletHeader-tab-send"]').click(); - await new SendFunds(page).send(send_wallet, '0.01'); //, '0.00000275276505264396'); + await new SendFunds(page).send(sendWallet, '0.01'); }); diff --git a/packages/gui/tests/tokens/send_amount_greater.spec.ts b/packages/gui/tests/tokens/send_amount_greater.spec.ts index 2d7ae98d0e..8f25748b77 100644 --- a/packages/gui/tests/tokens/send_amount_greater.spec.ts +++ b/packages/gui/tests/tokens/send_amount_greater.spec.ts @@ -1,7 +1,5 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { dialog } from 'electron'; -import { LoginPage } from '../data_object_model/passphrase_login'; import { isWalletSynced, getWalletBalance } from '../utils/wallet'; let electronApp: ElectronApplication; @@ -17,24 +15,24 @@ test.afterAll(async () => { }); test('Confirm that User cannot send a TXCH amount greater then in Wallet', async () => { - let receive_wallet = 'txch1ksr59en3j3t9zaprmya0jp9k6mkazq2u5lfccaf85sej7kgmvjjscanfxd'; - let funded_wallet = '1922132445'; + let receiveWallet = 'txch1ksr59en3j3t9zaprmya0jp9k6mkazq2u5lfccaf85sej7kgmvjjscanfxd'; + let fundedWallet = '1922132445'; //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); //And I navigate to a wallet with funds - await page.locator(`text=${funded_wallet}`).click(); + await page.locator(`text=${fundedWallet}`).click(); //Begin: Wait for Wallet to Sync - while (!isWalletSynced(funded_wallet)) { + while (!isWalletSynced(fundedWallet)) { console.log('Waiting for wallet to sync...'); await page.waitForTimeout(1000); } - console.log(`Wallet ${funded_wallet} is now fully synced`); + console.log(`Wallet ${fundedWallet} is now fully synced`); - const balance = getWalletBalance(funded_wallet); + const balance = getWalletBalance(fundedWallet); console.log(`XCH Balance: ${balance}`); //End: Wait for Wallet to Sync @@ -43,7 +41,7 @@ test('Confirm that User cannot send a TXCH amount greater then in Wallet', async await page.locator('[data-testid="WalletHeader-tab-send"]').click(); //When I enter a valid wallet address in address field - await page.locator('[data-testid="WalletSend-address"]').fill(receive_wallet); + await page.locator('[data-testid="WalletSend-address"]').fill(receiveWallet); //And I enter an amount higher then in account await page.locator('[data-testid="WalletSend-amount"]').fill('200'); diff --git a/packages/gui/tests/tokens/send_error_page.spec.ts b/packages/gui/tests/tokens/send_error_page.spec.ts index 3936ef591f..bd126a8a02 100644 --- a/packages/gui/tests/tokens/send_error_page.spec.ts +++ b/packages/gui/tests/tokens/send_error_page.spec.ts @@ -1,7 +1,5 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { dialog } from 'electron'; -import { LoginPage } from '../data_object_model/passphrase_login'; import { isWalletSynced, getWalletBalance } from '../utils/wallet'; let electronApp: ElectronApplication; @@ -17,23 +15,23 @@ test.afterAll(async () => { }); test('Confirm Error Dialog when wrong data is entered on Send Page for 1922132445 ID', async () => { - let funded_wallet = '1922132445'; + let fundedWallet = '1922132445'; //Pre-requisites to get user back to Wallet selection page await page.locator('button:has-text("Close")').click(); //Given I navigate to a wallet with funds - await page.locator(`text=${funded_wallet}`).click(); + await page.locator(`text=${fundedWallet}`).click(); // Begin: Wait for Wallet to Sync - while (!isWalletSynced(funded_wallet)) { + while (!isWalletSynced(fundedWallet)) { console.log('Waiting for wallet to sync...'); await page.waitForTimeout(1000); } - console.log(`Wallet ${funded_wallet} is now fully synced`); + console.log(`Wallet ${fundedWallet} is now fully synced`); - const balance = getWalletBalance(funded_wallet); + const balance = getWalletBalance(fundedWallet); console.log(`XCH Balance: ${balance}`); //End: Wait for Wallet to Sync diff --git a/packages/gui/tests/tokens/send_fee_txch.spec.ts b/packages/gui/tests/tokens/send_fee_txch.spec.ts index 81e743743b..6942384780 100644 --- a/packages/gui/tests/tokens/send_fee_txch.spec.ts +++ b/packages/gui/tests/tokens/send_fee_txch.spec.ts @@ -1,15 +1,10 @@ import { ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import { LoginPage } from '../data_object_model/passphrase_login'; -import { SendFunds } from '../data_object_model/send_funds'; -import { isWalletSynced, getWalletBalance } from '../utils/wallet'; +import { isWalletSynced } from '../utils/wallet'; import { CloseDialog } from '../data_object_model/close_dialog'; -import date from 'date-and-time'; -const now = new Date(); let electronApp: ElectronApplication; let page: Page; -let appWindow: Page; test.beforeAll(async () => { electronApp = await electron.launch({ args: ['./build/electron/main.js'] }); @@ -22,8 +17,8 @@ test.afterAll(async () => { test('Verify that a recipient wallet receives funds from sending wallet!', async () => { //Pre-requisites - let receive_wallet = 'txch1km02nle6485x6fv676m7nx67zfyk75ed0znq3dwumj8wvxm2pvms9m0dnf'; - let send_wallet = 'txch1ls7ur56shuh58zlvzkqkwgzch8zy6llfwr7ydm3n8rvky4rdf3dqlceyzx'; + let receiveWallet = 'txch1km02nle6485x6fv676m7nx67zfyk75ed0znq3dwumj8wvxm2pvms9m0dnf'; + let sendWallet = 'txch1ls7ur56shuh58zlvzkqkwgzch8zy6llfwr7ydm3n8rvky4rdf3dqlceyzx'; //Pre-requisites to get user back to Wallet selection page await new CloseDialog(page).closeIt(); @@ -46,7 +41,7 @@ test('Verify that a recipient wallet receives funds from sending wallet!', async await page.getByLabel('Fee').fill('0.0005'); //And I enter a valid wallet address in address field - await page.locator('[data-testid="WalletSend-address"]').fill(receive_wallet); + await page.locator('[data-testid="WalletSend-address"]').fill(receiveWallet); //And I enter an amount await page.locator('[data-testid="WalletSend-amount"]').fill('.09'); @@ -83,7 +78,7 @@ test('Verify that a recipient wallet receives funds from sending wallet!', async await page.locator('[data-testid="WalletHeader-tab-send"]').click(); //And I enter a valid wallet address in address field and amount - await page.locator('[data-testid="WalletSend-address"]').fill(send_wallet); + await page.locator('[data-testid="WalletSend-address"]').fill(sendWallet); await page.locator('[data-testid="WalletSend-amount"]').fill('.05'); await page.getByText('Show Advanced Options').click(); await page.getByTestId('WalletSend-memo').click();