Make the test more granular
This commit is contained in:
parent
fc14a4e5da
commit
bc40163155
|
@ -40,15 +40,16 @@ const runImportProductsTest = () => {
|
|||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
await merchant.openAllProductsView();
|
||||
});
|
||||
it('can upload the CSV file and import products', async () => {
|
||||
await merchant.openImportProducts();
|
||||
|
||||
// Verify error message if you go withot provided CSV file
|
||||
});
|
||||
it('should show error message if you go without providing CSV file', async () => {
|
||||
// Verify error message if you go without providing CSV file
|
||||
await expect(page).toClick('button[value="Continue"]');
|
||||
await page.waitForSelector('div.error');
|
||||
await expect(page).toMatchElement('div.error > p', errorMessage);
|
||||
});
|
||||
|
||||
it('can upload the CSV file and import products', async () => {
|
||||
// Put the CSV products file and proceed further
|
||||
const uploader = await page.$("input[type=file]");
|
||||
await uploader.uploadFile(filePath);
|
||||
|
@ -62,7 +63,9 @@ const runImportProductsTest = () => {
|
|||
await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000});
|
||||
await page.waitForSelector('.woocommerce-importer-done');
|
||||
await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'});
|
||||
});
|
||||
|
||||
it('can see and verify the uploaded products', async () => {
|
||||
// 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');
|
||||
|
@ -70,7 +73,7 @@ const runImportProductsTest = () => {
|
|||
// Gathering product names
|
||||
await page.waitForSelector('a.row-title');
|
||||
const productTitles = await page.$$eval('a.row-title',
|
||||
elements => elements.map(item => item.innerHTML));
|
||||
elements => elements.map(item => item.innerHTML));
|
||||
|
||||
// Compare imported product names
|
||||
expect(productTitles.sort()).toEqual(productNames.sort());
|
||||
|
@ -93,7 +96,9 @@ const runImportProductsTest = () => {
|
|||
await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000});
|
||||
await page.waitForSelector('.woocommerce-importer-done');
|
||||
await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'});
|
||||
});
|
||||
|
||||
it('can see and verify the uploaded overrode products', async () => {
|
||||
// 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');
|
||||
|
@ -116,6 +121,7 @@ const runImportProductsTest = () => {
|
|||
|
||||
// Move all imported products to trash
|
||||
await moveAllItemsToTrash();
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue