2022-06-22 15:29:27 +00:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
2022-10-11 08:56:12 +00:00
|
|
|
import { loadFixture } from '../../playwright/paths';
|
|
|
|
import { test } from '../../playwright/test';
|
2022-06-22 15:29:27 +00:00
|
|
|
|
|
|
|
test('can render schema and send GraphQL requests', async ({ app, page }) => {
|
|
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
|
|
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'Create' }).click();
|
2022-06-22 15:29:27 +00:00
|
|
|
|
|
|
|
// Copy the collection with the graphql query to clipboard
|
|
|
|
const text = await loadFixture('graphql.yaml');
|
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
|
|
|
|
|
|
|
// Import from clipboard
|
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();
|
2023-06-27 18:46:43 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionSmoke GraphQLjust now').click();
|
2022-06-22 15:29:27 +00:00
|
|
|
// Open the graphql request
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'GraphQL request' }).click();
|
2022-11-04 17:53:28 +00:00
|
|
|
// Assert the schema is fetched after switching to GraphQL request
|
2023-05-15 09:06:53 +00:00
|
|
|
await expect(page.locator('.graphql-editor__meta')).toContainText('schema fetched just now');
|
2022-06-22 15:29:27 +00:00
|
|
|
|
|
|
|
// Assert schema documentation stuff
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'schema' }).click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Show Documentation' }).click();
|
2022-06-22 15:29:27 +00:00
|
|
|
await page.click('a:has-text("Query")');
|
|
|
|
await page.locator('a:has-text("RingBearer")').click();
|
|
|
|
const graphqlExplorer = page.locator('.graphql-explorer');
|
|
|
|
await expect(graphqlExplorer).toContainText('Characters who at any time bore a Ring of Power.');
|
|
|
|
await page.click('text=QueryRingBearer >> button');
|
|
|
|
|
|
|
|
// Send and assert GraphQL request
|
|
|
|
await page.click('[data-testid="request-pane"] >> text=Send');
|
|
|
|
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
|
|
|
|
const responseBody = page.locator('[data-testid="response-pane"] >> [data-testid="CodeEditor"]:visible', {
|
|
|
|
has: page.locator('.CodeMirror-activeline'),
|
|
|
|
});
|
|
|
|
await expect(responseBody).toContainText('"bearer": "Gandalf"');
|
|
|
|
});
|
2023-01-17 15:55:39 +00:00
|
|
|
|
|
|
|
test('can send GraphQL requests after editing and prettifying query', async ({ app, page }) => {
|
|
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
|
|
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'Create' }).click();
|
2023-01-17 15:55:39 +00:00
|
|
|
|
|
|
|
const text = await loadFixture('graphql.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();
|
2023-06-27 18:46:43 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionSmoke GraphQLjust now').click();
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'GraphQL request' }).click();
|
2023-01-17 15:55:39 +00:00
|
|
|
|
|
|
|
// Edit and prettify query
|
2023-08-04 10:42:00 +00:00
|
|
|
await page.locator('pre[role="presentation"]:has-text("bearer")').click();
|
2023-01-17 15:55:39 +00:00
|
|
|
await page.locator('.app').press('Enter');
|
|
|
|
await page.locator('text=Prettify GraphQL').click();
|
|
|
|
await page.click('[data-testid="request-pane"] >> text=Send');
|
|
|
|
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
|
|
|
|
const responseBody = page.locator('[data-testid="response-pane"] >> [data-testid="CodeEditor"]:visible', {
|
|
|
|
has: page.locator('.CodeMirror-activeline'),
|
|
|
|
});
|
|
|
|
await expect(responseBody).toContainText('"bearer": "Gandalf"');
|
|
|
|
});
|