Skip to content

Commit

Permalink
Migrate @pages/BO/advancedParameters/import into ui-testing-library
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Oct 17, 2024
1 parent 8a3a71a commit 869685d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 322 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Import utils
import testContext from '@utils/testContext';

// Import pages
import importPage from '@pages/BO/advancedParameters/import';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boImportPage,
boLoginPage,
utilsFile,
utilsPlaywright,
Expand Down Expand Up @@ -48,10 +46,10 @@ describe('BO - Advanced Parameters - Import : Download sample csv files', async
boDashboardPage.advancedParametersLink,
boDashboardPage.importLink,
);
await importPage.closeSfToolBar(page);
await boImportPage.closeSfToolBar(page);

const pageTitle = await importPage.getPageTitle(page);
expect(pageTitle).to.contains(importPage.pageTitle);
const pageTitle = await boImportPage.getPageTitle(page);
expect(pageTitle).to.contains(boImportPage.pageTitle);
});

const sampleFiles = [
Expand Down Expand Up @@ -139,7 +137,7 @@ describe('BO - Advanced Parameters - Import : Download sample csv files', async
it(`should download ${sampleFile.args.type} sample file`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `${sampleFile.args.type}DownloadFile`, baseContext);

filePath = await importPage.downloadSampleFile(page, sampleFile.args.type);
filePath = await boImportPage.downloadSampleFile(page, sampleFile.args.type);

const doesFileExist = await utilsFile.doesFileExist(filePath);
expect(doesFileExist, `${sampleFile.args.type} sample file was not downloaded`).to.eq(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import testContext from '@utils/testContext';
// Import commonTests
import {setupSmtpConfigTest, resetSmtpConfigTest} from '@commonTests/BO/advancedParameters/smtp';

// Import pages
import importPage from '@pages/BO/advancedParameters/import';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boImportPage,
boLoginPage,
type MailDev,
type MailDevEmail,
Expand Down Expand Up @@ -78,17 +76,17 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {
boDashboardPage.advancedParametersLink,
boDashboardPage.importLink,
);
await importPage.closeSfToolBar(page);
await boImportPage.closeSfToolBar(page);

const pageTitle = await importPage.getPageTitle(page);
expect(pageTitle).to.contains(importPage.pageTitle);
const pageTitle = await boImportPage.getPageTitle(page);
expect(pageTitle).to.contains(boImportPage.pageTitle);
});

describe('Download then import alias simple file', async () => {
it('should download \'Sample alias file\' file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'downloadFile', baseContext);

filePath = await importPage.downloadSampleFile(page, 'alias_import');
filePath = await boImportPage.downloadSampleFile(page, 'alias_import');

const doesFileExist = await utilsFile.doesFileExist(filePath);
expect(doesFileExist, 'alias_import sample file was not downloaded').to.be.eq(true);
Expand All @@ -99,28 +97,28 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {

await utilsFile.renameFile(filePath, 'alias.csv');

const uploadSuccessText = await importPage.uploadImportFile(page, 'Alias', firstFile);
const uploadSuccessText = await boImportPage.uploadImportFile(page, 'Alias', firstFile);
expect(uploadSuccessText).to.contains(firstFile);
});

it('should go to next import file step', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'nextStep', baseContext);

const panelTitle = await importPage.goToImportNextStep(page);
expect(panelTitle).to.contains(importPage.importPanelTitle);
const panelTitle = await boImportPage.goToImportNextStep(page);
expect(panelTitle).to.contains(boImportPage.importPanelTitle);
});

it('should start import file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'confirmImport', baseContext);

const modalTitle = await importPage.startFileImport(page);
expect(modalTitle).to.contains(importPage.importModalTitle);
const modalTitle = await boImportPage.startFileImport(page);
expect(modalTitle).to.contains(boImportPage.importModalTitle);
});

it('should check that the import is completed', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'waitForImport', baseContext);

const isCompleted = await importPage.getImportValidationMessage(page);
const isCompleted = await boImportPage.getImportValidationMessage(page);
expect(isCompleted, 'The import is not completed!')
.to.contains('Data imported')
.and.to.contains('Look at your listings to make sure it\'s all there as you wished.');
Expand All @@ -129,7 +127,7 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {
it('should close import progress modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeImportModal', baseContext);

const isModalClosed = await importPage.closeImportModal(page);
const isModalClosed = await boImportPage.closeImportModal(page);
expect(isModalClosed).to.be.eq(true);
});

Expand All @@ -144,7 +142,7 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {
it('should download \'Sample suppliers file\' file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'downloadFile2', baseContext);

secondFilePath = await importPage.downloadSampleFile(page, 'suppliers_import');
secondFilePath = await boImportPage.downloadSampleFile(page, 'suppliers_import');

const doesFileExist = await utilsFile.doesFileExist(secondFilePath);
expect(doesFileExist, 'suppliers sample file was not downloaded').to.be.eq(true);
Expand All @@ -155,30 +153,30 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {

await utilsFile.renameFile(secondFilePath, 'suppliers.csv');

const uploadSuccessText = await importPage.uploadImportFile(page, 'Suppliers', secondFile);
const uploadSuccessText = await boImportPage.uploadImportFile(page, 'Suppliers', secondFile);
expect(uploadSuccessText).contain('suppliers.csv');
});

it('should click on the downloaded file and check the existence of the button choose from history', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnDownloadedFile', baseContext);

await importPage.clickOnDownloadedFile(page);
await boImportPage.clickOnDownloadedFile(page);

const isButtonVisible = await importPage.isChooseFromHistoryButtonVisible(page);
const isButtonVisible = await boImportPage.isChooseFromHistoryButtonVisible(page);
expect(isButtonVisible).to.be.eq(true);
});

it('should click on \'Choose from history / FTP\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnChooseFromHistory', baseContext);

const isFilesListTableVisible = await importPage.chooseFromHistoryFTP(page);
const isFilesListTableVisible = await boImportPage.chooseFromHistoryFTP(page);
expect(isFilesListTableVisible).to.be.eq(true);
});

it('should check the imported files list', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkImportedFilesList', baseContext);

const importedFilesList = await importPage.getImportedFilesList(page);
const importedFilesList = await boImportPage.getImportedFilesList(page);
expect(importedFilesList).to.contains(firstFile)
.and.to.contains(secondFile);
});
Expand All @@ -187,39 +185,39 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'deleteFirstFile', baseContext);

// Delete file and check that choose from history button is visible
const isButtonVisible = await importPage.deleteFile(page);
const isButtonVisible = await boImportPage.deleteFile(page);
expect(isButtonVisible).to.be.eq(true);
});

it('should use the second imported file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'useSecondFile', baseContext);

await importPage.chooseFromHistoryFTP(page);
await boImportPage.chooseFromHistoryFTP(page);

const uploadSuccessText = await importPage.useFile(page, 1);
const uploadSuccessText = await boImportPage.useFile(page, 1);
expect(uploadSuccessText).to.contains(secondFile);
});

it('should go to next import file step', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'nextStep2', baseContext);

await importPage.selectFileType(page, 'Suppliers');
await boImportPage.selectFileType(page, 'Suppliers');

const panelTitle = await importPage.goToImportNextStep(page);
expect(panelTitle).to.contains(importPage.importPanelTitle);
const panelTitle = await boImportPage.goToImportNextStep(page);
expect(panelTitle).to.contains(boImportPage.importPanelTitle);
});

it('should start import file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'confirmImport2', baseContext);

const modalTitle = await importPage.startFileImport(page);
expect(modalTitle).to.contains(importPage.importModalTitle);
const modalTitle = await boImportPage.startFileImport(page);
expect(modalTitle).to.contains(boImportPage.importModalTitle);
});

it('should check that the import is completed', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'waitForImport2', baseContext);

const isCompleted = await importPage.getImportValidationMessage(page);
const isCompleted = await boImportPage.getImportValidationMessage(page);
expect(isCompleted, 'The import is not completed!')
.to.contains('Data imported')
.and.to.contains('Look at your listings to make sure it\'s all there as you wished.');
Expand All @@ -228,7 +226,7 @@ describe('BO - Advanced Parameters - Import : Import file', async () => {
it('should close import progress modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeImportModal2', baseContext);

const isModalClosed = await importPage.closeImportModal(page);
const isModalClosed = await boImportPage.closeImportModal(page);
expect(isModalClosed).to.be.eq(true);
});

Expand Down
28 changes: 13 additions & 15 deletions tests/UI/commonTests/BO/advancedParameters/importFile.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Import utils
import testContext from '@utils/testContext';

// Import BO pages
import importPage from '@pages/BO/advancedParameters/import';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boImportPage,
boLoginPage,
utilsPlaywright,
} from '@prestashop-core/ui-testing';
Expand Down Expand Up @@ -55,41 +53,41 @@ function importFileTest(
boDashboardPage.advancedParametersLink,
boDashboardPage.importLink,
);
await importPage.closeSfToolBar(page);
await boImportPage.closeSfToolBar(page);

const pageTitle = await importPage.getPageTitle(page);
expect(pageTitle).to.contains(importPage.pageTitle);
const pageTitle = await boImportPage.getPageTitle(page);
expect(pageTitle).to.contains(boImportPage.pageTitle);
});

it(`should import '${fileName}' file`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'importFile', baseContext);

const uploadSuccessText = await importPage.uploadImportFile(page, entityToImport, fileName);
const uploadSuccessText = await boImportPage.uploadImportFile(page, entityToImport, fileName);
expect(uploadSuccessText).contain(fileName);

if (await importPage.isForceAllIDNumbersVisible(page)) {
await importPage.setForceAllIDNumbers(page);
if (await boImportPage.isForceAllIDNumbersVisible(page)) {
await boImportPage.setForceAllIDNumbers(page);
}
});

it('should go to next import file step', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'nextStep', baseContext);

const panelTitle = await importPage.goToImportNextStep(page);
expect(panelTitle).contain(importPage.importPanelTitle);
const panelTitle = await boImportPage.goToImportNextStep(page);
expect(panelTitle).contain(boImportPage.importPanelTitle);
});

it('should start import file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'confirmImport', baseContext);

const modalTitle = await importPage.startFileImport(page);
expect(modalTitle).contain(importPage.importModalTitle);
const modalTitle = await boImportPage.startFileImport(page);
expect(modalTitle).contain(boImportPage.importModalTitle);
});

it('should check that the import is completed', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'waitForImport', baseContext);

const isCompleted = await importPage.getImportValidationMessage(page);
const isCompleted = await boImportPage.getImportValidationMessage(page);
expect(isCompleted, 'The import is not completed!')
.contain('Data imported')
.and.contain('Look at your listings to make sure it\'s all there as you wished.');
Expand All @@ -98,7 +96,7 @@ function importFileTest(
it('should close import progress modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeImportModal', baseContext);

const isModalClosed = await importPage.closeImportModal(page);
const isModalClosed = await boImportPage.closeImportModal(page);
expect(isModalClosed).to.eq(true);
});
});
Expand Down
Loading

0 comments on commit 869685d

Please sign in to comment.