mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
5af79c7486
* Move basic auth routes to a separate file * Stop slowing requests down artificially * Add initial oauth routes * Mount oidc routes under /oidc * Enable all forms of oauth that Insomnia supports * Add oauth request collection fixture * Update playwright config * Use 127.0.0.1 instead of localhost * simple oauth2 test * Make the playwright extension work * Move oauth tests to a separate file * Test all oauth flows * Mark test as slow * Wait for load state for new pages * Use locators consistently * Add playwright to recommended extensions * Add instructions for how to use the playwright extension * update selectors and use fill * Fix markdown lint Co-authored-by: jackkav <jackkav@gmail.com> Co-authored-by: gatzjames <jamesgatzos@gmail.com>
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
// Read more about creating fixtures https://playwright.dev/docs/test-fixtures
|
|
import { ElectronApplication, test as baseTest, TraceMode } from '@playwright/test';
|
|
import path from 'path';
|
|
|
|
import {
|
|
bundleType,
|
|
cwd,
|
|
executablePath,
|
|
mainPath,
|
|
randomDataPath,
|
|
} from './paths';
|
|
|
|
interface EnvOptions {
|
|
INSOMNIA_DATA_PATH: string;
|
|
}
|
|
|
|
export const test = baseTest.extend<{
|
|
app: ElectronApplication;
|
|
}>({
|
|
app: async ({ playwright, trace }, use, testInfo) => {
|
|
const options: EnvOptions = {
|
|
INSOMNIA_DATA_PATH: randomDataPath(),
|
|
};
|
|
|
|
const electronApp = await playwright._electron.launch({
|
|
cwd,
|
|
executablePath,
|
|
args: bundleType() === 'package' ? [] : [mainPath],
|
|
env: {
|
|
...process.env,
|
|
...options,
|
|
PLAYWRIGHT: 'true',
|
|
},
|
|
});
|
|
|
|
const appContext = electronApp.context();
|
|
const traceMode: TraceMode = typeof trace === 'string' ? trace as TraceMode : trace.mode;
|
|
|
|
const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true };
|
|
const traceOptions = typeof trace === 'string' ? defaultTraceOptions : { ...defaultTraceOptions, ...trace, mode: undefined };
|
|
const captureTrace = (traceMode === 'on' || traceMode === 'retain-on-failure' || (traceMode === 'on-first-retry' && testInfo.retry === 1));
|
|
|
|
if (captureTrace) {
|
|
await appContext.tracing.start(traceOptions);
|
|
}
|
|
|
|
await use(electronApp);
|
|
|
|
if (captureTrace) {
|
|
await appContext.tracing.stop({
|
|
path: path.join(testInfo.outputDir, 'trace.zip'),
|
|
});
|
|
}
|
|
|
|
await electronApp.close();
|
|
},
|
|
page: async ({ app }, use) => {
|
|
const page = await app.firstWindow();
|
|
|
|
if (process.platform === 'win32') await page.reload();
|
|
|
|
await page.click("text=Don't share usage analytics");
|
|
|
|
await use(page);
|
|
},
|
|
});
|