mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 05:52:40 +03:00
Record tests using same setup as the test runner
no issue
This commit is contained in:
parent
8c41807978
commit
d6072ea0e8
@ -1,46 +1,29 @@
|
||||
const {chromium} = require('@playwright/test');
|
||||
const Command = require('./command');
|
||||
const testUtils = require('../../test/utils');
|
||||
const playwrightConfig = require('../../playwright.config');
|
||||
const {globalSetup} = require('../../test/e2e-browser/utils');
|
||||
|
||||
module.exports = class RecordTest extends Command {
|
||||
setup() {
|
||||
this.help('Use PlayWright to record a browser-based test');
|
||||
this.argument('--admin', {type: 'boolean', defaultValue: false, desc: 'Start browser-based test in Ghost admin'});
|
||||
this.argument('--no-setup', {type: 'boolean', defaultValue: false, desc: 'Disable the default setup, for testing Ghost admin setup'});
|
||||
this.argument('--fixtures', {type: 'array', defaultValue: [], delimiter: ',', desc: 'A list of comma-separated fixtures to include'});
|
||||
}
|
||||
|
||||
permittedEnvironments() {
|
||||
return ['testing-browser'];
|
||||
}
|
||||
|
||||
async handle(argv) {
|
||||
const app = await testUtils.startGhost();
|
||||
|
||||
if (argv.fixtures.length > 0) {
|
||||
await testUtils.initFixtures(...argv.fixtures);
|
||||
}
|
||||
async handle() {
|
||||
await globalSetup({
|
||||
projects: [playwrightConfig]
|
||||
});
|
||||
|
||||
const browser = await chromium.launch({headless: false});
|
||||
|
||||
const baseURL = argv.admin ? `${app.url}ghost/` : app.url;
|
||||
const context = await browser.newContext({
|
||||
baseURL
|
||||
});
|
||||
const context = await browser.newContext(playwrightConfig.use);
|
||||
|
||||
// Pause the page, and start recording manually.
|
||||
const page = await context.newPage();
|
||||
await page.goto('');
|
||||
|
||||
if (argv.admin && !argv['no-setup']) {
|
||||
await page.getByPlaceholder('The Daily Awesome').click();
|
||||
await page.getByPlaceholder('The Daily Awesome').fill('The Local Test');
|
||||
await page.getByPlaceholder('Jamie Larson').fill('Testy McTesterson');
|
||||
await page.getByPlaceholder('jamie@example.com').fill('testy@example.com');
|
||||
await page.getByPlaceholder('At least 10 characters').fill('Mc.T3ster$0n');
|
||||
await page.getByPlaceholder('At least 10 characters').press('Enter');
|
||||
await page.locator('.gh-done-pink').click();
|
||||
}
|
||||
await page.goto('/ghost');
|
||||
|
||||
await page.pause();
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ const {spawn, exec} = require('child_process');
|
||||
const {knex} = require('../../../core/server/data/db');
|
||||
const {setupGhost, setupStripe} = require('./e2e-browser-utils');
|
||||
const {chromium} = require('@playwright/test');
|
||||
const models = require('../../../core/server/models');
|
||||
const {startGhost} = require('../../utils/e2e-framework');
|
||||
const {stopGhost} = require('../../utils/e2e-utils');
|
||||
|
||||
|
@ -1 +1,4 @@
|
||||
module.exports = require('./e2e-browser-utils');
|
||||
module.exports = {
|
||||
...require('./e2e-browser-utils'),
|
||||
globalSetup: require('./global-setup')
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user