Clear browser cache and cookies after each test.

Add merchant logins to relevant onboarding & setup tests
This commit is contained in:
Rodel Calasagsag 2021-05-21 19:27:50 +08:00
parent 8a7f185652
commit 072af834b9
3 changed files with 23 additions and 4 deletions

View File

@ -25,7 +25,7 @@ async function trashExistingPosts() {
const posts = response.data;
// Delete each post
for(const post of posts){
for (const post of posts) {
await client.delete(`${wpPostsEndpoint}/${post.id}`);
}
@ -34,11 +34,19 @@ async function trashExistingPosts() {
// Before every test suite run, delete all content created by the test. This ensures
// other posts/comments/etc. aren't dirtying tests and tests don't depend on
// each other's side-effects.
beforeAll( async () => {
beforeAll(async () => {
await trashExistingPosts();
await withRestApi.deleteAllProducts();
await withRestApi.deleteAllCoupons();
await page.goto(WP_ADMIN_LOGIN);
await clearLocalStorage();
await setBrowserViewport( 'large' );
} );
await setBrowserViewport('large');
});
// Clear browser cookies and cache using DevTools.
// This is to ensure that each test ends with no user logged in.
afterAll(async () => {
const client = await page.target().createCDPSession();
await client.send('Network.clearBrowserCookies');
await client.send('Network.clearBrowserCache');
});

View File

@ -24,6 +24,10 @@ const shippingZoneNameUS = config.get( 'addresses.customer.shipping.country' );
const runOnboardingFlowTest = () => {
describe('Store owner can go through store Onboarding', () => {
beforeAll(async () => {
await merchant.login();
});
if ( IS_RETEST_MODE ) {
it('can reset onboarding to default settings', async () => {
await withRestApi.resetOnboarding();
@ -48,6 +52,10 @@ const runOnboardingFlowTest = () => {
const runTaskListTest = () => {
describe('Store owner can go through setup Task List', () => {
beforeAll(async () => {
await merchant.login();
});
it('can setup shipping', async () => {
await page.evaluate(() => {
document.querySelector('.woocommerce-list__item-title').scrollIntoView();

View File

@ -27,6 +27,9 @@ const {
const runInitialStoreSettingsTest = () => {
describe('Store owner can finish initial store setup', () => {
beforeAll(async () => {
await merchant.login();
});
it('can enable tax rates and calculations', async () => {
// Go to general settings page