Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LYS] Add Homescreen and Settings e2e tests #47341

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add
Comment: add e2e tests to previously unreleased feature

Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const { test, expect, request } = require( '@playwright/test' );
const { setOption } = require( '../../utils/options' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;

test.describe( 'Launch Your Store front end - logged in', () => {
test.describe( 'Launch Your Store - logged in', () => {
test.use( { storageState: process.env.ADMINSTATE } );

test.beforeEach( async ( { baseURL } ) => {
await new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc-admin',
} ).post( 'onboarding/profile', {
skipped: true,
} );
} );

test.afterAll( async ( { baseURL } ) => {
try {
await setOption(
Expand All @@ -17,7 +29,10 @@ test.describe( 'Launch Your Store front end - logged in', () => {
}
} );

test( 'Entire site coming soon mode', async ( { page, baseURL } ) => {
test( 'Entire site coming soon mode frontend', async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
Expand Down Expand Up @@ -45,7 +60,10 @@ test.describe( 'Launch Your Store front end - logged in', () => {
).toBeVisible();
} );

test( 'Store only coming soon mode', async ( { page, baseURL } ) => {
test( 'Store only coming soon mode frontend', async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
Expand All @@ -72,4 +90,229 @@ test.describe( 'Launch Your Store front end - logged in', () => {
)
).toBeVisible();
} );

test( 'Site visibility settings', async ( { page, baseURL } ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'no'
);

await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'no'
);

await setOption(
request,
baseURL,
'woocommerce_private_link',
'no'
);
} catch ( error ) {
console.log( error );
}

await page.goto(
'/wp-admin/admin.php?page=wc-settings&tab=site-visibility'
);

// The Coming soon radio should not be checked.
await expect(
page.getByRole( 'radio', { name: 'Coming soon', exact: true } )
).not.toBeChecked();

// The store only checkbox should not be on the page.
await expect(
page.getByRole( 'checkbox', {
name: 'Restrict to store pages only',
} )
).toHaveCount( 0 );

// The private link should not be on the page.
await expect(
page.getByRole( 'checkbox', {
name: 'Share your site with a private link',
} )
).toHaveCount( 0 );

// The Live radio should be checked.
await expect(
page.getByRole( 'radio', { name: 'Live', exact: true } )
).toBeChecked();

// Check the Coming soon radio button.
await page
.getByRole( 'radio', { name: 'Coming soon', exact: true } )
.check();

// The store only checkbox should be visible.
await expect(
page.getByRole( 'checkbox', {
name: 'Restrict to store pages only',
} )
).toBeVisible();

// The store only checkbox should not be checked.
await expect(
page.getByRole( 'checkbox', {
name: 'Restrict to store pages only',
} )
).not.toBeChecked();

// The private link should not be checked.
await expect(
page.getByRole( 'checkbox', {
name: 'Share your site with a private link',
} )
).not.toBeChecked();

// Check the private link checkbox.
await page
.getByRole( 'checkbox', {
name: 'Share your site with a private link',
} )
.check();

// The private link input should be visible.
await expect(
page.getByRole( 'button', { name: 'Copy link' } )
).toBeVisible();
} );

test( 'Homescreen badge coming soon store only', async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);

await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'yes'
);
} catch ( error ) {
console.log( error );
}

await page.goto( '/wp-admin/admin.php?page=wc-admin' );

await expect(
page.getByRole( 'button', {
name: 'Store coming soon',
exact: true,
} )
).toBeVisible();

page.getByRole( 'button', {
name: 'Store coming soon',
exact: true,
} ).click();

await expect(
page.getByText( 'Manage site visibility' )
).toBeVisible();

await expect(
page.getByText( 'Customize "Coming soon" page' )
).toBeVisible();
} );

test( 'Homescreen badge coming soon entire store', async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);

await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'no'
);
} catch ( error ) {
console.log( error );
}

await page.goto( '/wp-admin/admin.php?page=wc-admin' );

await expect(
page.getByRole( 'button', {
name: 'Site coming soon',
exact: true,
} )
).toBeVisible();

page.getByRole( 'button', {
name: 'Site coming soon',
exact: true,
} ).click();

await expect(
page.getByText( 'Manage site visibility' )
).toBeVisible();

await expect(
page.getByText( 'Customize "Coming soon" page' )
).toBeVisible();
} );

test( 'Homescreen badge live', async ( { page, baseURL } ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'no'
);

await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'no'
);
} catch ( error ) {
console.log( error );
}

await page.goto( '/wp-admin/admin.php?page=wc-admin' );

await expect(
page.getByRole( 'button', {
name: 'Live',
exact: true,
} )
).toBeVisible();

page.getByRole( 'button', {
name: 'Live',
exact: true,
} ).click();

await expect(
page.getByText( 'Manage site visibility' )
).toBeVisible();

await expect(
page.getByText( 'Customize "Coming soon" page' )
).not.toBeVisible();
} );
} );
Loading