From 88efa365423bdcad3aa93199f062fc5627d8f030 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Mon, 5 Aug 2024 19:56:42 +0800 Subject: [PATCH] Playwright: importUser function --- test-playwright/testUtils.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test-playwright/testUtils.js diff --git a/test-playwright/testUtils.js b/test-playwright/testUtils.js new file mode 100644 index 000000000..44706ed34 --- /dev/null +++ b/test-playwright/testUtils.js @@ -0,0 +1,32 @@ +import { expect } from '@playwright/test'; + +export async function importUser(page, id) { + let seedPhrase, userName, did; + + // Set seed phrase and DID based on user ID + switch(id) { + case '01': + seedPhrase = 'island fever beef wine urban aim vacant quit afford total poem flame service calm better adult neither color gaze forum month sister imitate excite'; + userName = 'User One'; + did = 'did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39'; + break; + default: // to user 00 + seedPhrase = 'rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage'; + userName = 'User Zero'; + did = 'did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F'; + } + + // Import ID + await page.goto('./start'); + await page.getByText('You have a seed').click(); + await page.getByPlaceholder('Seed Phrase').fill(seedPhrase); + await page.getByRole('button', { name: 'Import' }).click(); + + // Set name + await page.getByRole('link', { name: 'Set Your Name' }).click(); + await page.getByPlaceholder('Name').fill(userName); + await page.getByRole('button', { name: 'Save Changes' }).click(); + + // Check DID + await expect(page.getByRole('code')).toContainText(did); +} \ No newline at end of file