mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-23 12:02:10 +03:00
parent
4f2b055ee0
commit
c3343d3600
22
packages/twenty-e2e-testing/drivers/env_variables.ts
Normal file
22
packages/twenty-e2e-testing/drivers/env_variables.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export const envVariables = (variables: string) => {
|
||||
let payload = `
|
||||
PG_DATABASE_URL=postgres://twenty:twenty@localhost:5432/default
|
||||
FRONT_BASE_URL=http://localhost:3001
|
||||
ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access
|
||||
LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login
|
||||
REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
||||
FILE_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
||||
REDIS_URL=redis://localhost:6379
|
||||
`;
|
||||
payload = payload.concat(variables);
|
||||
fs.writeFile(
|
||||
path.join(__dirname, '..', '..', 'twenty-server', '.env'),
|
||||
payload,
|
||||
(err) => {
|
||||
throw err;
|
||||
},
|
||||
);
|
||||
};
|
94
packages/twenty-e2e-testing/lib/utils/keyboardShortcuts.ts
Normal file
94
packages/twenty-e2e-testing/lib/utils/keyboardShortcuts.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { Page } from '@playwright/test';
|
||||
|
||||
const MAC = process.platform === 'darwin';
|
||||
|
||||
async function keyDownCtrlOrMeta(page: Page) {
|
||||
if (MAC) {
|
||||
await page.keyboard.down('Meta');
|
||||
} else {
|
||||
await page.keyboard.down('Control');
|
||||
}
|
||||
}
|
||||
|
||||
async function keyUpCtrlOrMeta(page: Page) {
|
||||
if (MAC) {
|
||||
await page.keyboard.up('Meta');
|
||||
} else {
|
||||
await page.keyboard.up('Control');
|
||||
}
|
||||
}
|
||||
|
||||
export async function withCtrlOrMeta(page: Page, key: () => Promise<void>) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await key();
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function selectAllByKeyboard(page: Page) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await page.keyboard.press('a', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function copyByKeyboard(page: Page) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await page.keyboard.press('c', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function cutByKeyboard(page: Page) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await page.keyboard.press('x', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function pasteByKeyboard(page: Page) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await page.keyboard.press('v', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function companiesShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('c');
|
||||
}
|
||||
|
||||
export async function notesShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('n');
|
||||
}
|
||||
|
||||
export async function opportunitiesShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('o');
|
||||
}
|
||||
|
||||
export async function peopleShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('p');
|
||||
}
|
||||
|
||||
export async function rocketsShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('r');
|
||||
}
|
||||
|
||||
export async function tasksShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('t');
|
||||
}
|
||||
|
||||
export async function workflowsShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('w');
|
||||
}
|
||||
|
||||
export async function settingsShortcut(page: Page) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press('s');
|
||||
}
|
||||
|
||||
export async function customShortcut(page: Page, shortcut: string) {
|
||||
await page.keyboard.press('g', { delay: 50 });
|
||||
await page.keyboard.press(shortcut);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { selectAllByKeyboard } from './keyboardShortcuts';
|
||||
|
||||
// https://github.com/microsoft/playwright/issues/14126
|
||||
// code must have \n at the end of lines otherwise everything will be in one line
|
||||
export const pasteCodeToCodeEditor = async (
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
code: string,
|
||||
) => {
|
||||
await locator.click();
|
||||
await selectAllByKeyboard(page);
|
||||
await page.keyboard.type(code);
|
||||
};
|
15
packages/twenty-e2e-testing/lib/utils/uploadFile.ts
Normal file
15
packages/twenty-e2e-testing/lib/utils/uploadFile.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import path from 'path';
|
||||
|
||||
export const fileUploader = async (
|
||||
page: Page,
|
||||
trigger: () => Promise<void>,
|
||||
filename: string,
|
||||
) => {
|
||||
const fileChooserPromise = page.waitForEvent('filechooser');
|
||||
await trigger();
|
||||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(
|
||||
path.join(__dirname, '..', 'test_files', filename),
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user