170 lines
6.3 KiB
JavaScript
170 lines
6.3 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Item', () => {
|
|
describe('Summary path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
beforeAll(done => {
|
|
nightmare
|
|
.waitForLogin('employee');
|
|
done();
|
|
});
|
|
|
|
it('should access to the items index by clicking the items button', done => {
|
|
nightmare
|
|
.click(selectors.moduleAccessView.itemsSectionButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toEqual('#!/item/index');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it('should search for the item Gem of Time', done => {
|
|
nightmare
|
|
.wait(selectors.itemsIndex.searchResult)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
|
.countElement(selectors.itemsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(1);
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should click on the search result summary button to open the item summary popup`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
|
|
.isVisible(selectors.itemSummary.basicData)
|
|
.then(result => {
|
|
expect(result).toBeFalsy();
|
|
return nightmare
|
|
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
|
|
.isVisible(selectors.itemSummary.basicData);
|
|
})
|
|
.then(result => {
|
|
expect(result).toBeTruthy();
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary preview shows fields from basic data`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Time')
|
|
.getInnerText(selectors.itemSummary.basicData)
|
|
.then(result => {
|
|
expect(result).toContain('Name: Gem of Time');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary preview shows fields from tags`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemSummary.tags, 'Color: Yellow')
|
|
.getInnerText(selectors.itemSummary.tags)
|
|
.then(result => {
|
|
expect(result).toContain('Color: Yellow');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary preview shows fields from niche`, done => {
|
|
return nightmare
|
|
.waitForTextInElement(selectors.itemSummary.niche, 'Warehouse One: A1')
|
|
.getInnerText(selectors.itemSummary.niche)
|
|
.then(result => {
|
|
expect(result).toContain('Warehouse One: A1');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary preview shows fields from botanical`, async() => {
|
|
let result = await nightmare
|
|
.waitForTextInElement(selectors.itemSummary.botanical, 'Botanical: Hedera helix')
|
|
.getInnerText(selectors.itemSummary.botanical);
|
|
|
|
expect(result).toContain('Botanical: Hedera helix');
|
|
});
|
|
|
|
it(`should check the item summary preview shows fields from barcode`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemSummary.barcode, '1')
|
|
.getInnerText(selectors.itemSummary.barcode)
|
|
.then(result => {
|
|
expect(result).toContain('1');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should close the summary popup`, done => {
|
|
nightmare
|
|
.waitToClick(selectors.itemsIndex.closeItemSummaryPreview)
|
|
.isVisible(selectors.itemSummary.basicData)
|
|
.then(result => {
|
|
expect(result).toBeFalsy();
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should navigate to the one of the items detailed section`, done => {
|
|
nightmare
|
|
.waitToClick(selectors.itemsIndex.searchResult)
|
|
.waitForURL('summary')
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toContain('summary');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary shows fields from basic data section`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Time')
|
|
.getInnerText(selectors.itemSummary.basicData)
|
|
.then(result => {
|
|
expect(result).toContain('Name: Gem of Time');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary shows fields from tags section`, done => {
|
|
nightmare
|
|
.getInnerText(selectors.itemSummary.tags)
|
|
.then(result => {
|
|
expect(result).toContain('Color: Yellow');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary shows fields from niches section`, done => {
|
|
nightmare
|
|
.getInnerText(selectors.itemSummary.niche)
|
|
.then(result => {
|
|
expect(result).toContain('Warehouse One: A1');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary shows fields from botanical section`, done => {
|
|
nightmare
|
|
.getInnerText(selectors.itemSummary.botanical)
|
|
.then(result => {
|
|
expect(result).toContain('Botanical: Hedera helix');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
|
|
it(`should check the item summary shows fields from barcodes section`, done => {
|
|
nightmare
|
|
.getInnerText(selectors.itemSummary.barcode)
|
|
.then(result => {
|
|
expect(result).toContain('1');
|
|
done();
|
|
}).catch(done.fail);
|
|
});
|
|
});
|
|
});
|