2023-01-26 08:39:32 +00:00
|
|
|
import { loadFixture } from '../../playwright/paths';
|
|
|
|
import { test } from '../../playwright/test';
|
|
|
|
|
|
|
|
test.describe('Environment Editor', async () => {
|
|
|
|
|
|
|
|
test.beforeEach(async ({ app, page }) => {
|
|
|
|
await page.getByTestId('project').click();
|
|
|
|
await page.getByRole('button', { name: 'Create' }).click();
|
|
|
|
const text = await loadFixture('environments.yaml');
|
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
2023-03-31 10:53:22 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Import' }).click();
|
|
|
|
await page.getByText('Clipboard').click();
|
|
|
|
await page.getByRole('button', { name: 'Scan' }).click();
|
|
|
|
await page.getByRole('button', { name: 'Import' }).click();
|
|
|
|
|
|
|
|
await page.getByRole('link', { name: 'Debug' }).click();
|
2023-01-26 08:39:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('create a new environment', async ({ page }) => {
|
|
|
|
// Create the environment
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('ExampleA').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Manage Environments' }).click();
|
|
|
|
await page.getByTestId('CreateEnvironmentDropdown').click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Environment', exact: true }).click();
|
|
|
|
await page.getByRole('button', { name: 'New Environment' }).click();
|
|
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
|
|
|
|
|
|
// Make it active one
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('ExampleA').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'New Environment' }).click();
|
|
|
|
|
|
|
|
// Send a request check variables defaulted to base env since new env is empty
|
|
|
|
await page.getByRole('button', { name: 'GET New Request' }).click();
|
|
|
|
await page.getByRole('button', { name: 'Send' }).click();
|
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
|
|
|
await page.getByText('baseenv0').click();
|
|
|
|
await page.getByText('baseenv1').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
// rename an existing environment
|
|
|
|
test('Rename an existing environment', async ({ page }) => {
|
|
|
|
// Rename the environment
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('ExampleA').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Manage Environments' }).click();
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByRole('button', { name: 'ExampleB' }).click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByTitle('Click to edit', { exact: true }).click();
|
|
|
|
await page.getByRole('dialog').locator('input[type="text"]').fill('Gandalf');
|
|
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
|
|
|
|
|
|
// Make it active one
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('ExampleA').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Gandalf' }).click();
|
|
|
|
|
|
|
|
// Send a request check variables defaulted to base env since new env is empty
|
|
|
|
await page.getByRole('button', { name: 'GET New Request' }).click();
|
|
|
|
await page.getByRole('button', { name: 'Send' }).click();
|
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('subenvB0').click();
|
|
|
|
await page.getByText('subenvB1').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Add new variables to an existing environment', async ({ page }) => {
|
|
|
|
// Rename the environment
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.getByText('ExampleA').click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Manage Environments' }).click();
|
|
|
|
|
|
|
|
// add a new string environment variable
|
2023-03-31 16:33:41 +00:00
|
|
|
await page.locator('pre').filter({ hasText: '"exampleNumber": 1111,' }).click();
|
2023-01-26 08:39:32 +00:00
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').fill('"testNumber":9000,');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').fill('"testString":"Gandalf",');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
|
|
|
|
// Open request
|
|
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
|
|
await page.getByRole('button', { name: 'GET New Request' }).click();
|
|
|
|
|
|
|
|
// Add number variable to request body
|
|
|
|
await page.locator('pre').filter({ hasText: '_.exampleObject.anotherNumber' }).click();
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Control+ ');
|
|
|
|
await page.getByText('_.testNumber').click();
|
|
|
|
|
|
|
|
// Add string variable to request body
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Control+ ');
|
|
|
|
await page.getByText('_.testString').click();
|
|
|
|
await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
|
|
|
|
|
|
|
|
// TODO(filipe) add an environment variable that returns value of a nunjucks template (e.g. timestamp)
|
|
|
|
|
|
|
|
// Check new variables are in the timeline
|
|
|
|
await page.getByRole('button', { name: 'Send' }).click();
|
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
|
|
|
|
|
|
|
// FIXME(filipe) - adding variables to request body can be so fast they don't get picked up when sending request
|
2023-03-31 16:09:31 +00:00
|
|
|
|
2023-04-25 14:49:05 +00:00
|
|
|
// await page.locator('pre').filter({ hasText: '| 9000' }).click();
|
2023-03-31 16:09:31 +00:00
|
|
|
|
|
|
|
// NOTE - Test fails due to actual bug - the variables are not being added to the request body when the request is sent
|
2023-04-25 14:49:05 +00:00
|
|
|
// await page.locator('pre').filter({ hasText: '| Gandalf' }).click();
|
2023-01-26 08:39:32 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
});
|