Skip to content

Commit

Permalink
SSP-30: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kraal-spryker committed Feb 5, 2025
1 parent 84c3269 commit 6fa8c16
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 246 deletions.
193 changes: 114 additions & 79 deletions cypress/e2e/backoffice/file-manager-attachment/file-list.cy.ts
Original file line number Diff line number Diff line change
@@ -1,101 +1,136 @@
import { container } from '@utils';
import { UserLoginScenario } from '@scenarios/backoffice';
import { FileManagerAttachmentDynamicFixtures, FileManagerAttachmentStaticFixtures } from '@interfaces/backoffice';
import { FileManagerAttachmentListPage, FileManagerAttachmentAddPage, FileManagerAttachmentViewPage, FileManagerAttachmentDeletePage, FileManagerAttachmentDetachPage, FileManagerAttachmentAttachPage } from '@pages/backoffice';
import {
FileManagerAttachmentListPage,
FileManagerAttachmentAddPage,
FileManagerAttachmentViewPage,
FileManagerAttachmentDeletePage,
FileManagerAttachmentDetachPage,
FileManagerAttachmentAttachPage,
} from '@pages/backoffice';

describeForSsp('File Manager Module - Files List', { tags: ['@backoffice', '@fileManager', '@ssp'] }, () => {
const userLoginScenario = container.get(UserLoginScenario);
const fileManagerAttachmentListPage = container.get(FileManagerAttachmentListPage);

let dynamicFixtures: FileManagerAttachmentDynamicFixtures;
let staticFixtures: FileManagerAttachmentStaticFixtures;

before((): void => {
({ dynamicFixtures, staticFixtures } = Cypress.env());
});
const userLoginScenario = container.get(UserLoginScenario);
const fileManagerAttachmentListPage = container.get(FileManagerAttachmentListPage);

beforeEach(() => {
userLoginScenario.execute({
username: dynamicFixtures.rootUser.username,
password: staticFixtures.defaultPassword,
});
});
let dynamicFixtures: FileManagerAttachmentDynamicFixtures;
let staticFixtures: FileManagerAttachmentStaticFixtures;

it('should access the Files List page in Backoffice', () => {
fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.verifyListPage();
before((): void => {
({ dynamicFixtures, staticFixtures } = Cypress.env());
});

beforeEach(() => {
userLoginScenario.execute({
username: dynamicFixtures.rootUser.username,
password: staticFixtures.defaultPassword,
});
});

it('should successfully detach file from entity', () => {
const fileManagerAttachmentDetachPage = container.get(FileManagerAttachmentDetachPage);
it('should access the Files List page in Backoffice', () => {
fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.verifyListPage();
});

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickViewButton();

fileManagerAttachmentDetachPage.detachFile();
fileManagerAttachmentDetachPage.verifySuccessMessage();
});
it('should successfully detach file from entity', () => {
const fileManagerAttachmentDetachPage = container.get(FileManagerAttachmentDetachPage);

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickViewButton();

fileManagerAttachmentDetachPage.detachFile();
fileManagerAttachmentDetachPage.verifySuccessMessage();
});

it('should upload multiple files with size constraints', () => {
const fileManagerAttachmentAddPage = container.get(FileManagerAttachmentAddPage);

// Prepare test files that meet the constraints
const testFiles: { fileContent: any; fileName: string; mimeType: string; filePath: string }[] = [];

it('should upload multiple files with size constraints', () => {
const fileManagerAttachmentAddPage = container.get(FileManagerAttachmentAddPage);

// Prepare test files that meet the constraints
const testFiles: { fileContent: any; fileName: string; mimeType: string; filePath: string; }[] = [];

cy.fixture('suite/backoffice/file-manager-attachment/test-files/document1.pdf', 'binary').then((fileContent) => {
testFiles.push({ fileContent, fileName: 'document1.pdf', mimeType: 'application/pdf', filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/document1.pdf' });
}).then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/image1.jpeg', 'binary');
}).then((fileContent) => {
testFiles.push({ fileContent, fileName: 'image1.jpeg', mimeType: 'image/jpeg', filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/image1.jpeg' });
}).then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/image2.png', 'binary');
}).then((fileContent) => {
testFiles.push({ fileContent, fileName: 'image2.png', mimeType: 'image/png', filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/image2.png' });
}).then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/document2.pdf', 'binary');
}).then((fileContent) => {
testFiles.push({ fileContent, fileName: 'document2.pdf', mimeType: 'application/pdf', filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/document2.pdf' });
}).then(() => {
fileManagerAttachmentAddPage.visit();
fileManagerAttachmentAddPage.uploadFiles(testFiles);
fileManagerAttachmentAddPage.verifyFileUploadConstraints();
fileManagerAttachmentAddPage.submitForm();
fileManagerAttachmentAddPage.verifySuccessMessage();
cy.fixture('suite/backoffice/file-manager-attachment/test-files/document1.pdf', 'binary')
.then((fileContent) => {
testFiles.push({
fileContent,
fileName: 'document1.pdf',
mimeType: 'application/pdf',
filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/document1.pdf',
});
});
})
.then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/image1.jpeg', 'binary');
})
.then((fileContent) => {
testFiles.push({
fileContent,
fileName: 'image1.jpeg',
mimeType: 'image/jpeg',
filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/image1.jpeg',
});
})
.then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/image2.png', 'binary');
})
.then((fileContent) => {
testFiles.push({
fileContent,
fileName: 'image2.png',
mimeType: 'image/png',
filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/image2.png',
});
})
.then(() => {
cy.fixture('suite/backoffice/file-manager-attachment/test-files/document2.pdf', 'binary');
})
.then((fileContent) => {
testFiles.push({
fileContent,
fileName: 'document2.pdf',
mimeType: 'application/pdf',
filePath: 'cypress/fixtures/suite/backoffice/file-manager-attachment/test-files/document2.pdf',
});
})
.then(() => {
fileManagerAttachmentAddPage.visit();
fileManagerAttachmentAddPage.uploadFiles(testFiles);
fileManagerAttachmentAddPage.verifyFileUploadConstraints();
fileManagerAttachmentAddPage.submitForm();
fileManagerAttachmentAddPage.verifySuccessMessage();
});
});

it('should successfully delete a file', () => {
const fileManagerAttachmentDeletePage = container.get(FileManagerAttachmentDeletePage);
it('should successfully delete a file', () => {
const fileManagerAttachmentDeletePage = container.get(FileManagerAttachmentDeletePage);

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickDeleteButton();

fileManagerAttachmentDeletePage.confirmDelete();
fileManagerAttachmentDeletePage.verifySuccessMessage();
});
fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickDeleteButton();

it('should display file details on view page', () => {
const fileManagerAttachmentViewPage = container.get(FileManagerAttachmentViewPage);
fileManagerAttachmentDeletePage.confirmDelete();
fileManagerAttachmentDeletePage.verifySuccessMessage();
});

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickViewButton();
fileManagerAttachmentViewPage.verifyFileDetailsAreVisible();
});
it('should display file details on view page', () => {
const fileManagerAttachmentViewPage = container.get(FileManagerAttachmentViewPage);

it('should successfully attach file to multiple entities', () => {
const fileManagerAttachmentAttachPage = container.get(FileManagerAttachmentAttachPage);
fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickViewButton();
fileManagerAttachmentViewPage.verifyFileDetailsAreVisible();
});

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickAttachButton();
fileManagerAttachmentAttachPage.selectCompany('comp');
fileManagerAttachmentAttachPage.selectCompanyUser('spen');
fileManagerAttachmentAttachPage.selectCompanyBusinessUnit('unit');
fileManagerAttachmentAttachPage.submitForm();
fileManagerAttachmentAttachPage.verifySuccessMessage();
});
it('should successfully attach file to multiple entities', () => {
const fileManagerAttachmentAttachPage = container.get(FileManagerAttachmentAttachPage);

fileManagerAttachmentListPage.visit();
fileManagerAttachmentListPage.clickAttachButton();
fileManagerAttachmentAttachPage.selectCompany('comp');
fileManagerAttachmentAttachPage.selectCompanyUser('spen');
fileManagerAttachmentAttachPage.selectCompanyBusinessUnit('unit');
fileManagerAttachmentAttachPage.submitForm();
fileManagerAttachmentAttachPage.verifySuccessMessage();
});
});

function describeForSsp(title: string, options: { tags: string[] }, fn: () => void): void {
(['suite'].includes(Cypress.env('repositoryId')) ? describe : describe.skip)(title, fn);
(['suite'].includes(Cypress.env('repositoryId')) ? describe : describe.skip)(title, fn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"type": "helper",
"name": "haveFile",
"key": "file1",
"arguments":[
"arguments": [
{
"file_name": "fileName000.pdf"
}
Expand All @@ -70,7 +70,7 @@
"type": "helper",
"name": "haveFile",
"key": "file2",
"arguments":[
"arguments": [
{
"file_name": "fileName001.pdf"
}
Expand All @@ -79,7 +79,7 @@
{
"type": "helper",
"name": "haveFileAttachment",
"arguments":[
"arguments": [
{
"file": "#file1",
"entity_id": "#company1.id_company",
Expand All @@ -90,7 +90,7 @@
{
"type": "helper",
"name": "haveFileAttachment",
"arguments":[
"arguments": [
{
"file": "#file2",
"entity_id": "#company1.id_company",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"defaultPassword": "change123",
"rootUser": {
"firstName": "Admin",
"lastName": "Spryker",
"username": "[email protected]"
},
"fileNameToUpload": "test-file.pdf",
"fileSize": "1MB",
"fileType": "application/pdf",
"fileUploadPath": "cypress/fixtures/files/test-file.pdf"
"defaultPassword": "change123",
"rootUser": {
"firstName": "Admin",
"lastName": "Spryker",
"username": "[email protected]"
},
"fileNameToUpload": "test-file.pdf",
"fileSize": "1MB",
"fileType": "application/pdf",
"fileUploadPath": "cypress/fixtures/files/test-file.pdf"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@ import { FileManagerAttachmentAddRepository } from './file-manager-attachment-ad
@injectable()
@autoWired
export class FileManagerAttachmentAddPage extends BackofficePage {
@inject(FileManagerAttachmentAddRepository) private repository: FileManagerAttachmentAddRepository;
@inject(FileManagerAttachmentAddRepository) private repository: FileManagerAttachmentAddRepository;

protected PAGE_URL = '/file-manager-attachment/add-files/index';
protected PAGE_URL = '/file-manager-attachment/add-files/index';

uploadFiles(files: Array<{ fileContent: any; fileName: string; mimeType: string; filePath: string; }>): void {
cy.get(this.repository.getFileInputSelector()).selectFile(
files.map(file => ({
contents: file.filePath,
fileName: file.fileName,
mimeType: file.mimeType,
})),
{
force: true
}
);
}
uploadFiles(files: Array<{ fileContent: any; fileName: string; mimeType: string; filePath: string }>): void {
cy.get(this.repository.getFileInputSelector()).selectFile(
files.map((file) => ({
contents: file.filePath,
fileName: file.fileName,
mimeType: file.mimeType,
})),
{
force: true,
}
);
}

verifyFileUploadConstraints(): void {
cy.get(this.repository.getFileInputSelector())
.should('have.attr', 'multiple');
}
verifyFileUploadConstraints(): void {
cy.get(this.repository.getFileInputSelector()).should('have.attr', 'multiple');
}

submitForm(): void {
cy.get(this.repository.getSubmitButtonSelector()).click();
}
submitForm(): void {
cy.get(this.repository.getSubmitButtonSelector()).click();
}

verifySuccessMessage(): void {
cy.get(this.repository.getSuccessMessageSelector()).should('be.visible');
}
verifySuccessMessage(): void {
cy.get(this.repository.getSuccessMessageSelector()).should('be.visible');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { autoWired } from '@utils';
@injectable()
@autoWired
export class FileManagerAttachmentAddRepository {
getFileInputSelector = (): string => '[data-qa="file-upload-button"]';
getSubmitButtonSelector = (): string => '[data-qa="file-upload-submit"]';
getSuccessMessageSelector = (): string => '[data-qa="success-message"]';
getFileInputSelector = (): string => '[data-qa="file-upload-button"]';
getSubmitButtonSelector = (): string => '[data-qa="file-upload-submit"]';
getSuccessMessageSelector = (): string => '[data-qa="success-message"]';
}
Loading

0 comments on commit 6fa8c16

Please sign in to comment.