refactor invite link & add test

This commit is contained in:
2024-10-08 08:36:32 -06:00
parent 2e100aedf5
commit 98afa8a259
8 changed files with 81 additions and 37 deletions

View File

@@ -34,10 +34,15 @@ export async function importUser(page: Page, id?: string): Promise<string> {
// This is to switch to someone already in the identity table. It doesn't include registration.
export async function switchToUser(page: Page, did: string): Promise<void> {
await page.goto('./account');
await page.getByRole('heading', { name: 'Advanced' }).click();
await page.getByRole('link', { name: 'Switch Identifier' }).click();
await page.getByRole('code', { name: did }).click();
// await page.goto('./account');
// await page.getByRole('heading', { name: 'Advanced' }).click();
// await page.getByRole('link', { name: 'Switch Identifier' }).click();
await page.goto('./identity-switcher');
const didElem = await page.locator(`code:has-text("${did}")`);
await didElem.isVisible();
await didElem.click();
// wait for the switch to happen and the account page to fully load
await page.getByTestId('didWrapper').locator('code:has-text("did:")');
}
function createContactName(did: string): string {
@@ -56,17 +61,21 @@ export async function deleteContact(page: Page, did: string): Promise<void> {
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
}
// Generate a new random user and register them.
// Note that this makes 000 the active user. Use switchToUser to switch to this DID.
export async function generateEthrUser(page: Page): Promise<string> {
export async function generateNewEthrUser(page: Page): Promise<string> {
await page.goto('./start');
await page.getByTestId('newSeed').click();
await expect(page.locator('span:has-text("Created")')).toBeVisible();
await page.goto('./account');
// wait until the DID shows on the page in the 'did' element
const didElem = await page.getByTestId('didWrapper').locator('code:has-text("did:")');
const newDid = await didElem.innerText();
return newDid;
}
// Generate a new random user and register them.
// Note that this makes 000 the active user. Use switchToUser to switch to this DID.
export async function generateAndRegisterEthrUser(page: Page): Promise<string> {
const newDid = await generateNewEthrUser(page);
await importUser(page, '000'); // switch to user 000