Skip to content

Commit

Permalink
c/p to fix rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
psealock committed May 21, 2024
1 parent f57de64 commit eb5871a
Showing 1 changed file with 252 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
const { test, expect, request } = require( '@playwright/test' );
const { setOption } = require( '../../utils/options' );

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 ( { page } ) => {
// Dismiss the core profiler
await page.goto( '/wp-admin/admin.php?page=wc-admin' );
// if the core profiler is already complete, skip this
try {
await page
.getByRole( 'button', { name: 'Skip guided setup' } )
.click( { timeout: 5000 } );
await page.getByLabel( 'Select country/region' ).click();
await page.getByRole( 'option', { name: 'Afghanistan' } ).click();
await page
.getByRole( 'button', { name: 'Go to my store' } )
.click();
} catch ( error ) {
console.log( 'Core profiler completed already.' );
}
} );

test.afterAll( async ( { baseURL } ) => {
try {
await setOption(
Expand All @@ -17,7 +35,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 +66,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 +96,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();
} );
} );

0 comments on commit eb5871a

Please sign in to comment.