File size: 4,636 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
/**
* @group calypso-release
*/
import {
DataHelper,
StartSiteFlow,
RestAPIClient,
DomainSearchComponent,
envVariables,
SignupPickPlanPage,
NewUserResponse,
LoginPage,
UserSignupPage,
EditorPage,
} from '@automattic/calypso-e2e';
import { Page, Browser } from 'playwright';
import { apiCloseAccount, fixme_retry } from '../shared';
declare const browser: Browser;
describe( DataHelper.createSuiteTitle( 'Onboarding: Write Focus' ), function () {
const blogName = DataHelper.getBlogName();
const testUser = DataHelper.getNewTestUser( {
usernamePrefix: 'signupfree',
} );
let newUserDetails: NewUserResponse;
let page: Page;
let selectedFreeDomain: string;
beforeAll( async function () {
page = await browser.newPage();
} );
describe( 'Register as new user', function () {
let loginPage: LoginPage;
it( 'Navigate to the Login page', async function () {
loginPage = new LoginPage( page );
await loginPage.visit();
} );
it( 'Click on button to create a new account', async function () {
await loginPage.clickCreateNewAccount();
} );
it( 'Sign up as a new user', async function () {
const userSignupPage = new UserSignupPage( page );
newUserDetails = await userSignupPage.signupSocialFirstWithEmail( testUser.email );
} );
it( 'Select a .wordpress.com domain name', async function () {
const domainSearchComponent = new DomainSearchComponent( page );
await domainSearchComponent.search( blogName );
selectedFreeDomain = await domainSearchComponent.selectDomain(
'.wordpress.com',
envVariables.VIEWPORT_NAME === 'mobile'
);
} );
it( 'Select WordPress.com Free plan', async function () {
const signupPickPlanPage = new SignupPickPlanPage( page );
await signupPickPlanPage.selectPlan( 'Free' );
} );
} );
describe( 'Onboarding', function () {
const themeName = 'Retrospect';
let startSiteFlow: StartSiteFlow;
beforeAll( async function () {
startSiteFlow = new StartSiteFlow( page );
} );
it( 'Enter Onboarding flow for the selected domain', async function () {
await page.waitForURL( /setup\/site-setup\/goals\?/, { timeout: 30 * 1000 } );
// Additional assertions for the URL.
expect( page.url() ).toContain( 'siteSlug' );
expect( page.url() ).toContain( selectedFreeDomain );
} );
it( 'Select "Publish a blog" goal', async function () {
await startSiteFlow.selectGoal( 'Publish a blog' );
await startSiteFlow.clickButton( 'Next' );
} );
it( 'Select theme', async function () {
await startSiteFlow.clickButton( 'Show all Blog themes' );
await startSiteFlow.selectTheme( themeName );
await startSiteFlow.clickButton( 'Continue' );
} );
} );
describe( 'Write', function () {
const postTitle = DataHelper.getRandomPhrase();
let editorPage: EditorPage;
it( 'Launchpad is shown', async function () {
// dirty hack to wait for the launchpad to load.
// Stepper has a quirk where it redirects twice. Playwright hooks to the first one and thinks it was aborted.
await fixme_retry( () => page.waitForURL( /home/ ) );
} );
it( 'Write first post', async function () {
await page.getByRole( 'link', { name: 'Write your first post' } ).click();
} );
it( 'Editor loads', async function () {
editorPage = new EditorPage( page );
await editorPage.waitUntilLoaded();
await editorPage.closeWelcomeGuideIfNeeded();
} );
it( 'Enter blog title', async function () {
await editorPage.enterTitle( postTitle );
} );
it( 'Publish post', async function () {
await editorPage.publish();
} );
it( 'First post congratulatory message is shown', async function () {
const editorParent = await editorPage.getEditorParent();
await editorParent
.getByRole( 'heading', { name: 'Your first post is published!' } )
.waitFor();
} );
it( 'View Next Steps', async function () {
const editorParent = await editorPage.getEditorParent();
await editorParent.getByRole( 'button', { name: 'Next steps' } ).click();
} );
} );
describe( 'Launchpad', function () {
it( 'Focused Launchpad is shown', async function () {
const title = await page.getByText( "Let's get started!" );
await title.waitFor( { timeout: 30 * 1000 } );
} );
} );
afterAll( async function () {
if ( ! newUserDetails ) {
return;
}
const restAPIClient = new RestAPIClient(
{ username: testUser.username, password: testUser.password },
newUserDetails.body.bearer_token
);
await apiCloseAccount( restAPIClient, {
userID: newUserDetails.body.user_id,
username: newUserDetails.body.username,
email: testUser.email,
} );
} );
} );
|