Skip to content

Commit

Permalink
Refactoring playwright scripts to point to designated wallet (#1899)
Browse files Browse the repository at this point in the history
Co-authored-by: Zsolt Szabo <[email protected]>
Co-authored-by: William Allen <[email protected]>
  • Loading branch information
3 people authored Aug 23, 2023
1 parent 4e4b982 commit 45202f1
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
],

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions packages/gui/src/tests/util/utils.test.js

This file was deleted.

5 changes: 5 additions & 0 deletions packages/gui/tests/data_object_model/passphrase_login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion packages/gui/tests/offers/offer_created_via_nft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions packages/gui/tests/offers/offer_transfer_via_nft.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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');
Expand All @@ -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');
Expand Down
40 changes: 40 additions & 0 deletions packages/gui/tests/plots/cancel_create_plot.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
57 changes: 57 additions & 0 deletions packages/gui/tests/plots/create_delete_plot.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
// });
17 changes: 2 additions & 15 deletions packages/gui/tests/select_key_page/create_delete_wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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();
Expand Down
14 changes: 6 additions & 8 deletions packages/gui/tests/select_key_page/rename_wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Loading

0 comments on commit 45202f1

Please sign in to comment.