mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +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 {chromium} = require('@playwright/test');
|
||||||
const Command = require('./command');
|
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 {
|
module.exports = class RecordTest extends Command {
|
||||||
setup() {
|
setup() {
|
||||||
this.help('Use PlayWright to record a browser-based test');
|
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() {
|
permittedEnvironments() {
|
||||||
return ['testing-browser'];
|
return ['testing-browser'];
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle(argv) {
|
async handle() {
|
||||||
const app = await testUtils.startGhost();
|
await globalSetup({
|
||||||
|
projects: [playwrightConfig]
|
||||||
if (argv.fixtures.length > 0) {
|
});
|
||||||
await testUtils.initFixtures(...argv.fixtures);
|
|
||||||
}
|
|
||||||
|
|
||||||
const browser = await chromium.launch({headless: false});
|
const browser = await chromium.launch({headless: false});
|
||||||
|
|
||||||
const baseURL = argv.admin ? `${app.url}ghost/` : app.url;
|
const context = await browser.newContext(playwrightConfig.use);
|
||||||
const context = await browser.newContext({
|
|
||||||
baseURL
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pause the page, and start recording manually.
|
// Pause the page, and start recording manually.
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
await page.goto('');
|
await page.goto('/ghost');
|
||||||
|
|
||||||
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.pause();
|
await page.pause();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ const {spawn, exec} = require('child_process');
|
|||||||
const {knex} = require('../../../core/server/data/db');
|
const {knex} = require('../../../core/server/data/db');
|
||||||
const {setupGhost, setupStripe} = require('./e2e-browser-utils');
|
const {setupGhost, setupStripe} = require('./e2e-browser-utils');
|
||||||
const {chromium} = require('@playwright/test');
|
const {chromium} = require('@playwright/test');
|
||||||
const models = require('../../../core/server/models');
|
|
||||||
const {startGhost} = require('../../utils/e2e-framework');
|
const {startGhost} = require('../../utils/e2e-framework');
|
||||||
const {stopGhost} = require('../../utils/e2e-utils');
|
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