Skip to content

Commit

Permalink
Add generateId to e2e tests
Browse files Browse the repository at this point in the history
- Wasn't in this branch yet
  • Loading branch information
mofojed committed Jan 2, 2025
1 parent ca7e817 commit bdc6231
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/console.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { test, expect, Page, Locator } from '@playwright/test';
import shortid from 'shortid';
import { generateVarName, pasteInMonaco, makeTableCommand } from './utils';
import {
generateId,
generateVarName,
pasteInMonaco,
makeTableCommand,
} from './utils';

function logMessageLocator(page: Page, text?: string): Locator {
return page
Expand Down
13 changes: 13 additions & 0 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ export async function openPlot(
}
}

/**
* Generate a unique Id
* @param length Length to give id
* @returns A unique valid id
*/
export function generateId(length = 21): string {
let id = '';
for (let i = 0; i < length; i += 1) {
id += Math.random().toString(36).substr(2, 1);
}
return id;
}

/**
* Generate a unique python variable name
* @param prefix Prefix to give the variable name
Expand Down

0 comments on commit bdc6231

Please sign in to comment.