Adding Merchant Products Import Products CSV test
This commit is contained in:
parent
069ab3ae46
commit
338ee3326e
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Added
|
||||
- Merchant Order Status Filter tests
|
||||
- Merchant Import Products CSV test
|
||||
|
||||
## Fixed
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
moveAllItemsToTrash
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
|
@ -11,6 +12,7 @@ const {
|
|||
const {
|
||||
it,
|
||||
describe,
|
||||
afterEach
|
||||
} = require( '@jest/globals' );
|
||||
const path = require('path')
|
||||
|
||||
|
@ -18,39 +20,60 @@ const runImportProductsTest = () => {
|
|||
describe('Import Products from a CSV file', () => {
|
||||
it('Import example file', async () => {
|
||||
|
||||
// Go to "Products" page
|
||||
// await expect(page).toClick('#menu-posts-product a')
|
||||
let filePath = path.resolve('../../../sample-data/sample_products.csv');
|
||||
|
||||
|
||||
let filePath;
|
||||
filePath = path.relative(process.cwd(), __dirname).concat('/sample-data/sample_products.csv');
|
||||
const product_names = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie",
|
||||
"Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee",
|
||||
"Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort();
|
||||
|
||||
// Click start import
|
||||
await expect(page).toClick('a.woocommerce-BlankState-cta.button-primary.button ~ a');
|
||||
|
||||
|
||||
|
||||
// const fs = require('fs');
|
||||
// const readFileAsync = helper.promisify(fs.readFile);
|
||||
// debugger;
|
||||
// const promises = filePaths.map(filePath => readFileAsync(filePath));
|
||||
//
|
||||
|
||||
// Upload file
|
||||
await page.waitForSelector('#upload');
|
||||
await page.click('#upload');
|
||||
const input = await page.$('input[type=file]');
|
||||
debugger;
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue