diff --git a/src/components/Navbar.ts b/src/components/Navbar.ts index 2235bdf..19d7486 100644 --- a/src/components/Navbar.ts +++ b/src/components/Navbar.ts @@ -27,6 +27,13 @@ class Navbar extends BasePageModel { return this.navbar.getByRole('menuitem', { name: name, exact: true }); } + getSectionTitle(name: string) { + return this.navbar + .locator('.subsection-section-title') + .filter({ hasText: name }) + .filter({ visible: true }); + } + get editProfileButton() { return this.navbar.getByRole('menuitem', { name: 'Edit Profile' }); } @@ -99,6 +106,10 @@ class Navbar extends BasePageModel { get transactions() { return this.getNavItem('Transactions'); } + + get inventory() { + return this.getNavItem('Inventory'); + } } export default Navbar; diff --git a/src/pages/putaway/list/PutawayListTable.ts b/src/pages/putaway/list/PutawayListTable.ts index 2a7eee9..2b9c766 100644 --- a/src/pages/putaway/list/PutawayListTable.ts +++ b/src/pages/putaway/list/PutawayListTable.ts @@ -52,5 +52,9 @@ class Row extends BasePageModel { get lineItems() { return this.row.getByTestId('line-items'); } + + get generatePdf() { + return this.row.getByTestId('generate-pdf-item'); + } } export default PutawayListTable; diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index 3381d45..83c5d06 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -301,5 +301,19 @@ test.describe('Assert putaway details page', () => { 'Completed' ); }); + + await test.step('Download putaway pdf from putaway list', async () => { + const row = putawayListPage.table.row(1); + await row.actionsButton.click(); + await row.generatePdf.click(); + const generatePutawayPdfFileName = + 'Putaway ' + `${putawayOrderIdentifier}`.toString().trim() + '.pdf'; + await putawayDetailsPage.generatePutawayListButton.click(); + const downloadPromise = page.waitForEvent('download'); + const download = await downloadPromise; + await expect(download.suggestedFilename()).toBe( + generatePutawayPdfFileName + ); + }); }); }); diff --git a/src/tests/putaway/assertPutawayInMenu.test.ts b/src/tests/putaway/assertPutawayInMenu.test.ts new file mode 100644 index 0000000..9267b2d --- /dev/null +++ b/src/tests/putaway/assertPutawayInMenu.test.ts @@ -0,0 +1,68 @@ +import AppConfig from '@/config/AppConfig'; +import { expect, test } from '@/fixtures/fixtures'; + +test.describe('Assert Putaway exist in menu', () => { + test('Assert menu content without pick and putaway stock added for location', async ({ + authService, + page, + navbar, + }) => { + await test.step('Open dashboard', async () => { + await authService.changeLocation( + AppConfig.instance.locations.noPickAndPutawayStockDepot.id + ); + await page.goto('./dashboard'); + }); + + await test.step('Assert content of inbound menu in location with pick and putaway stock', async () => { + await navbar.inbound.click(); + await expect(navbar.getSectionTitle('Putaways')).toBeHidden(); + await expect(navbar.getNavItem('Create Putaway')).toBeHidden(); + await expect(navbar.getNavItem('List Putaways')).toBeHidden(); + }); + + await test.step('Assert content of inventory menu in location with pick and putaway stock', async () => { + await navbar.inventory.click(); + await expect( + navbar.getSectionTitle('Inventory Transactions') + ).toBeVisible(); + await expect(navbar.getNavItem('Transfer stock internally')).toBeHidden(); + await expect(navbar.getNavItem('Replenish picking bins')).toBeHidden(); + await expect(navbar.getNavItem('List Stock Transfers ')).toBeHidden(); + }); + + await test.step('Return to main location', async () => { + await authService.changeLocation(AppConfig.instance.locations.main.id); + }); + }); + + test('Assert menu content when pick and putaway stock added for location', async ({ + authService, + page, + navbar, + }) => { + await test.step('Open dashboard', async () => { + await authService.changeLocation(AppConfig.instance.locations.main.id); + await page.goto('./dashboard'); + }); + + await test.step('Assert content of inbound menu in location with pick and putaway stock', async () => { + await navbar.inbound.click(); + await expect(navbar.getSectionTitle('Putaways')).toBeVisible(); + await expect(navbar.getNavItem('Create Putaway')).toBeVisible(); + await expect(navbar.getNavItem('List Putaways')).toBeVisible(); + }); + + await test.step('Assert content of inventory menu in location with pick and putaway stock', async () => { + await navbar.inventory.click(); + await expect( + navbar.getSectionTitle('Inventory Transactions') + ).toBeVisible(); + await expect( + navbar.getNavItem('Transfer stock internally') + ).toBeVisible(); + await expect(navbar.getNavItem('Replenish picking bins')).toBeVisible(); + await expect(navbar.getNavItem('List Stock Transfers ')).toBeVisible(); + }); + }); +});