You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
import { Page } from '@playwright/test';
|
|
import { User } from '../types/testing';
|
|
import { clickOnMatchingText, typeIntoInput } from '../utilities/utils';
|
|
// tslint:disable: no-console
|
|
export const newUser = async (window: Page, userName: string): Promise<User> => {
|
|
// Create User
|
|
await clickOnMatchingText(window, 'Create Session ID');
|
|
// Wait for animation for finish creating ID
|
|
await window.waitForTimeout(1500);
|
|
//Save session ID to a variable
|
|
const sessionid = await window.inputValue('[data-testid=session-id-signup]');
|
|
await clickOnMatchingText(window, 'Continue');
|
|
// Input username = testuser
|
|
await typeIntoInput(window, 'display-name-input', userName);
|
|
await clickOnMatchingText(window, 'Get started');
|
|
// save recovery phrase
|
|
await clickOnMatchingText(window, 'Reveal Recovery Phrase');
|
|
const recoveryPhrase = await window.innerText('[data-testid=recovery-phrase-seed-modal]');
|
|
|
|
console.info(`${userName}: Session ID: ${sessionid} and Recovery phrase: ${recoveryPhrase}`);
|
|
await window.click('.session-icon-button.small');
|
|
return { userName, sessionid, recoveryPhrase };
|
|
};
|
|
|
|
// const openAppAndNewUser = async (multi: string): Promise<User & { window: Page }> => {
|
|
// const window = await openAppAndWait(multi);
|
|
|
|
// const userName = `${multi}-user`;
|
|
// const loggedIn = await newUser(window, userName);
|
|
// return { window, ...loggedIn };
|
|
// };
|
|
|
|
// export async function openAppsAndNewUsers(windowToCreate: number) {
|
|
// if (windowToCreate >= multisAvailable.length) {
|
|
// throw new Error(`Do you really need ${multisAvailable.length} windows?!`);
|
|
// }
|
|
// // if windowToCreate = 3, this array will be ABC. If windowToCreate = 5, this array will be ABCDE
|
|
// const multisToUse = multisAvailable.slice(0, windowToCreate);
|
|
// const loggedInDetails = await Promise.all(
|
|
// [...multisToUse].map(async m => {
|
|
// return openAppAndNewUser(m);
|
|
// })
|
|
// );
|
|
|
|
// const windows = loggedInDetails.map(w => w.window);
|
|
// const users = loggedInDetails.map(w => {
|
|
// return _.pick(w, ['sessionid', 'recoveryPhrase', 'userName']);
|
|
// });
|
|
// return { windows, users };
|
|
// }
|