mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-28 06:47:25 +00:00
chore: Move helper to E2E test (#37546)
This commit is contained in:
parent
9f77c721f1
commit
8a6cae6f14
@ -1,14 +0,0 @@
|
||||
export const createToken = (): string => {
|
||||
const array = new Uint8Array(16);
|
||||
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
|
||||
window.crypto.getRandomValues(array);
|
||||
} else {
|
||||
// Use Node.js crypto
|
||||
const { randomBytes } = require('crypto'); // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
const buffer = randomBytes(16);
|
||||
array.set(buffer);
|
||||
}
|
||||
return Array.from(array)
|
||||
.map((byte) => byte.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
};
|
||||
@ -1,11 +1,23 @@
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
import { createToken } from '../../../client/lib/utils/createToken';
|
||||
import { Users } from '../fixtures/userStates';
|
||||
import { OmnichannelContacts } from '../page-objects/omnichannel-contacts-list';
|
||||
import { OmnichannelSection } from '../page-objects/omnichannel-section';
|
||||
import { test, expect } from '../utils/test';
|
||||
|
||||
const createToken = (): string => {
|
||||
const array = new Uint8Array(16);
|
||||
|
||||
const buffer = randomBytes(16);
|
||||
array.set(buffer);
|
||||
|
||||
return Array.from(array)
|
||||
.map((byte) => byte.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
};
|
||||
|
||||
const createContact = (generateToken = false) => ({
|
||||
id: null,
|
||||
name: `${faker.person.firstName()} ${faker.person.lastName()}`,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user