Adding Merchant Products Import Products CSV test
This commit is contained in:
parent
069ab3ae46
commit
338ee3326e
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
- Merchant Order Status Filter tests
|
- Merchant Order Status Filter tests
|
||||||
|
- Merchant Import Products CSV test
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
const {
|
const {
|
||||||
|
moveAllItemsToTrash
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +12,7 @@ const {
|
||||||
const {
|
const {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
|
afterEach
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
|
@ -18,39 +20,60 @@ const runImportProductsTest = () => {
|
||||||
describe('Import Products from a CSV file', () => {
|
describe('Import Products from a CSV file', () => {
|
||||||
it('Import example file', async () => {
|
it('Import example file', async () => {
|
||||||
|
|
||||||
// Go to "Products" page
|
let filePath = path.resolve('../../../sample-data/sample_products.csv');
|
||||||
// await expect(page).toClick('#menu-posts-product a')
|
|
||||||
|
|
||||||
|
const product_names = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie",
|
||||||
let filePath;
|
"Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee",
|
||||||
filePath = path.relative(process.cwd(), __dirname).concat('/sample-data/sample_products.csv');
|
"Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort();
|
||||||
|
|
||||||
// Click start import
|
// Click start import
|
||||||
await expect(page).toClick('a.woocommerce-BlankState-cta.button-primary.button ~ a');
|
await expect(page).toClick('a.woocommerce-BlankState-cta.button-primary.button ~ a');
|
||||||
|
|
||||||
|
// Upload file
|
||||||
|
|
||||||
// const fs = require('fs');
|
|
||||||
// const readFileAsync = helper.promisify(fs.readFile);
|
|
||||||
// debugger;
|
|
||||||
// const promises = filePaths.map(filePath => readFileAsync(filePath));
|
|
||||||
//
|
|
||||||
|
|
||||||
await page.waitForSelector('#upload');
|
await page.waitForSelector('#upload');
|
||||||
await page.click('#upload');
|
|
||||||
const input = await page.$('input[type=file]');
|
const input = await page.$('input[type=file]');
|
||||||
debugger;
|
|
||||||
|
|
||||||
await input.uploadFile(filePath);
|
await input.uploadFile(filePath);
|
||||||
await page.click('#upload');
|
|
||||||
|
|
||||||
// await input.evaluate(upload => upload.dispatchEvent(new Event('change', { bubbles: true })));
|
// Click on Continue
|
||||||
|
await expect(page).toClick('button[value="Continue"]');
|
||||||
|
|
||||||
debugger;
|
// Click on Run the importer
|
||||||
|
await page.waitForSelector('button[value="Run the importer"]');
|
||||||
|
await expect(page).toClick('button[value="Run the importer"]');
|
||||||
|
|
||||||
|
// Waiting for importer to finish
|
||||||
|
await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000});
|
||||||
|
|
||||||
|
// Click on view products
|
||||||
|
await page.waitForSelector('div.wc-actions a.button.button-primary');
|
||||||
|
await expect(page).toClick('div.wc-actions a.button.button-primary');
|
||||||
|
|
||||||
|
// Getting product names
|
||||||
|
await page.waitForSelector('a.row-title');
|
||||||
|
let linkTexts = await page.$$eval('a.row-title', elements => elements.map(item => item.innerHTML));
|
||||||
|
|
||||||
|
// Compare imported product names
|
||||||
|
await expect(product_names).toEqual(linkTexts.sort());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
// Deleting imported products
|
||||||
|
|
||||||
|
|
||||||
|
// Click on select all
|
||||||
|
await page.waitForSelector('#cb-select-all-1', {visible:true});
|
||||||
|
moveAllItemsToTrash();
|
||||||
|
|
||||||
|
await page.waitForSelector('ul.subsubsub li.trash a', {visible:true});
|
||||||
|
await page.click('ul.subsubsub li.trash a');
|
||||||
|
|
||||||
|
await page.waitForSelector('#delete_all', {visible:true});
|
||||||
|
await page.click('#delete_all');
|
||||||
|
|
||||||
|
|
||||||
|
await page.waitForSelector('a.woocommerce-BlankState-cta.button-primary.button ~ a', {visible:true});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = runImportProductsTest;
|
module.exports = runImportProductsTest;
|
||||||
|
|
Loading…
Reference in New Issue