2022-10-27 16:49:45 +00:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
|
|
|
import { loadFixture } from '../../playwright/paths';
|
|
|
|
import { test } from '../../playwright/test';
|
|
|
|
|
|
|
|
test.describe('Dashboard', async () => {
|
|
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
|
|
test.describe('Projects', async () => {
|
|
|
|
test('Can create, rename and delete new project', async ({ page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByLabel('All Files (0)').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Git Sync');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Setup Git Sync');
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2022-11-10 12:11:21 +00:00
|
|
|
// Create new project
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create new Project' }).click();
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.getByRole('button', { name: 'Create', exact: true }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Check empty project
|
|
|
|
await expect(page.locator('.app')).toContainText('This is an empty project, to get started create your first resource:');
|
|
|
|
|
|
|
|
// Rename Project
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('row', { name: 'My Project' }).getByRole('button', { name: 'Project Actions' }).click();
|
|
|
|
await page.getByRole('menuitemradio', { name: 'Settings' }).click();
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByPlaceholder('My Project').click();
|
|
|
|
await page.getByPlaceholder('My Project').fill('My Project123');
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.getByRole('button', { name: 'Update' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2022-11-30 17:53:49 +00:00
|
|
|
// Check that the project name is updated on modal
|
|
|
|
await expect(page.locator('.app')).toContainText('My Project123');
|
|
|
|
|
2022-10-27 16:49:45 +00:00
|
|
|
// Close project settings modal
|
|
|
|
await page.locator('.app').press('Escape');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).toContainText('My Project123');
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Delete project
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('row', { name: 'My Project' }).getByRole('button', { name: 'Project Actions' }).click();
|
2023-10-10 16:00:32 +00:00
|
|
|
await page.getByRole('menuitemradio', { name: 'Delete' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// After deleting project, return to default Insomnia Dashboard
|
2023-09-24 23:12:50 +00:00
|
|
|
await expect(page.locator('.app')).toContainText('Personal Workspace');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('My Project123');
|
2022-10-27 16:49:45 +00:00
|
|
|
await expect(page.locator('.app')).toContainText('New Document');
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByLabel('All Files (0)').click();
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Setup Git Sync');
|
2022-10-27 16:49:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
test.describe('Interactions', async () => { // Not sure about the name here
|
2023-03-31 16:09:31 +00:00
|
|
|
// TODO(INS-2504) - we don't support importing multiple collections at this time
|
2023-03-31 15:46:58 +00:00
|
|
|
test.skip('Can filter through multiple collections', async ({ app, page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByLabel('All Files (0)').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Git Sync');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Setup Git Sync');
|
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
const text = await loadFixture('multiple-workspaces.yaml');
|
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('menuitemradio', { name: 'Import' }).click();
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.locator('[data-test-id="import-from-clipboard"]').click();
|
2023-03-31 15:46:58 +00:00
|
|
|
await page.getByRole('button', { name: 'Scan' }).click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionSmoke testsjust now').click();
|
2022-10-27 16:49:45 +00:00
|
|
|
// Check that 10 new workspaces are imported besides the default one
|
2023-08-28 13:53:37 +00:00
|
|
|
const workspaceCards = page.getByLabel('Workspaces').getByRole('gridcell');
|
2022-10-27 16:49:45 +00:00
|
|
|
await expect(workspaceCards).toHaveCount(11);
|
|
|
|
await expect(page.locator('.app')).toContainText('New Document');
|
|
|
|
await expect(page.locator('.app')).toContainText('collection 1');
|
|
|
|
await expect(page.locator('.app')).toContainText('design doc 1');
|
|
|
|
await expect(page.locator('.app')).toContainText('Swagger Petstore V3 JSON 1.0.0');
|
|
|
|
await expect(page.locator('.app')).toContainText('Swagger Petstore V3 YAML 1.0.0');
|
|
|
|
|
|
|
|
// Filter by collection
|
|
|
|
const filter = page.locator('[placeholder="Filter\\.\\.\\."]');
|
|
|
|
|
|
|
|
// Filter by word with results expected
|
|
|
|
await filter.fill('design');
|
|
|
|
await expect(page.locator('.card-badge')).toHaveCount(4);
|
|
|
|
|
|
|
|
// Filter by number
|
|
|
|
await filter.fill('3');
|
|
|
|
await expect(page.locator('.card-badge')).toHaveCount(2);
|
|
|
|
|
|
|
|
// Filter by word with no results expected
|
|
|
|
await filter.fill('invalid');
|
|
|
|
await expect(page.locator('.card-badge')).toHaveCount(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Can create, rename and delete a document', async ({ page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByLabel('All Files (0)').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Git Sync');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Setup Git Sync');
|
|
|
|
|
2022-10-27 16:49:45 +00:00
|
|
|
// Create new document
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
|
|
|
await page.getByRole('menuitemradio', { name: 'Design Document' }).click();
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.getByRole('button', { name: 'Create', exact: true }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2023-08-17 14:18:48 +00:00
|
|
|
await page.getByTestId('project').click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Rename document
|
2023-08-29 11:29:13 +00:00
|
|
|
await page.getByLabel('my-spec.yaml').getByRole('button').click();
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Rename' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('text=Rename DocumentName Rename >> input[type="text"]').fill('test123');
|
|
|
|
await page.click('#root button:has-text("Rename")');
|
|
|
|
await expect(page.locator('.app')).toContainText('test123');
|
|
|
|
|
|
|
|
// Duplicate document
|
|
|
|
await page.click('text=Documenttest123just now >> button');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('input[name="name"]').fill('test123-duplicate');
|
2022-11-10 12:11:21 +00:00
|
|
|
await page.click('[role="dialog"] button:has-text("Duplicate")');
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2023-08-17 14:18:48 +00:00
|
|
|
await page.getByTestId('project').click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
const workspaceCards = page.getByLabel('Workspaces').getByRole('gridcell');
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(workspaceCards).toHaveCount(2);
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Delete document
|
|
|
|
await page.click('text=Documenttest123just now >> button');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('text=Yes').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(workspaceCards).toHaveCount(1);
|
2022-10-27 16:49:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Can create, rename and delete a collection', async ({ page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByLabel('All Files (0)').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Git Sync');
|
2022-11-10 12:11:21 +00:00
|
|
|
await expect(page.locator('.app')).not.toContainText('Setup Git Sync');
|
|
|
|
|
2022-10-27 16:49:45 +00:00
|
|
|
// Create new collection
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
|
|
|
await page.getByRole('menuitemradio', { name: 'Request Collection' }).click();
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.getByRole('button', { name: 'Create', exact: true }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2023-08-17 14:18:48 +00:00
|
|
|
await page.getByTestId('project').click();
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Rename collection
|
|
|
|
await page.click('text=CollectionMy Collectionjust now >> button');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Rename' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('text=Rename CollectionName Rename >> input[type="text"]').fill('test123');
|
|
|
|
await page.click('#root button:has-text("Rename")');
|
|
|
|
await expect(page.locator('.app')).toContainText('test123');
|
|
|
|
|
|
|
|
// Duplicate collection
|
|
|
|
await page.click('text=Collectiontest123just now >> button');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('input[name="name"]').fill('test123-duplicate');
|
2022-11-10 12:11:21 +00:00
|
|
|
await page.click('[role="dialog"] button:has-text("Duplicate")');
|
2022-10-27 16:49:45 +00:00
|
|
|
|
2023-08-17 14:18:48 +00:00
|
|
|
await page.getByTestId('project').click();
|
2023-08-28 13:53:37 +00:00
|
|
|
const workspaceCards = page.getByLabel('Workspaces').getByRole('gridcell');
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(workspaceCards).toHaveCount(2);
|
2022-10-27 16:49:45 +00:00
|
|
|
|
|
|
|
// Delete collection
|
|
|
|
await page.click('text=Collectiontest123just now >> button');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
2022-10-27 16:49:45 +00:00
|
|
|
await page.locator('text=Yes').click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await expect(workspaceCards).toHaveCount(1);
|
2022-10-27 16:49:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|