diff --git a/goofy-client/apps/goofy-e2e/src/components/postfach/postfach-mail.e2e.component.ts b/goofy-client/apps/goofy-e2e/src/components/postfach/postfach-mail.e2e.component.ts index a8a9aa827e200e30feae06db4ba17a8e55c93029..6aff70a2ee14d5a996e56e9c07c11ef568b81828 100644 --- a/goofy-client/apps/goofy-e2e/src/components/postfach/postfach-mail.e2e.component.ts +++ b/goofy-client/apps/goofy-e2e/src/components/postfach/postfach-mail.e2e.component.ts @@ -27,11 +27,13 @@ import { UserProfileE2EComponent } from '../user-profile/user-profile.component. export class PostfachMailE2EComponent { - private readonly locatorCreateMailButtonWithText: string = 'create-mail-button-with-text'; - private readonly locatorCreateMailButtonWithoutText: string = 'create-mail-button-without-text'; - private readonly locatorList: string = 'postfach-mail-list'; - private readonly locatorNoPostfachText: string = 'no-postfach-text'; - private readonly locatorAttachments: string = 'postfach-nachricht-attachments-container'; + private readonly createMailButtonWithText: string = 'create-mail-button-with-text'; + private readonly createMailButtonWithoutText: string = 'create-mail-button-without-text'; + private readonly list: string = 'postfach-mail-list'; + private readonly noPostfachText: string = 'no-postfach-text'; + private readonly attachments: string = 'postfach-nachricht-attachments-container'; + private readonly downloadButtonWithIcon: string = 'postfach-pdf-export-button'; + private readonly downloadButtonWithLabel: string = 'postfach-pdf-export-label-button'; private readonly locatorRoot: string = 'postfach-nachrichten-container-in-vorgang'; @@ -40,19 +42,19 @@ export class PostfachMailE2EComponent { } public getCreateButtonWithText() { - return cy.getTestElement(this.locatorCreateMailButtonWithText); + return cy.getTestElement(this.createMailButtonWithText); } public getCreateButtonWithoutText() { - return cy.getTestElement(this.locatorCreateMailButtonWithoutText); + return cy.getTestElement(this.createMailButtonWithoutText); } public getList() { - return cy.getTestElement(this.locatorList); + return cy.getTestElement(this.list); } public getNoPostfachText() { - return cy.getTestElement(this.locatorNoPostfachText); + return cy.getTestElement(this.noPostfachText); } public getListItem(subject: string): PostfachMailListItem { @@ -60,7 +62,15 @@ export class PostfachMailE2EComponent { } public getAttachments() { - return cy.getTestElement(this.locatorAttachments); + return cy.getTestElement(this.attachments); + } + + public getDownloadButtonWithIcon() { + return cy.getTestElement(this.downloadButtonWithIcon); + } + + public getDownloadButtonWithLabel() { + return cy.getTestElement(this.downloadButtonWithLabel); } } diff --git a/goofy-client/apps/goofy-e2e/src/e2e/main-tests/postfach-mail/postfach-nachrichten.cy.ts b/goofy-client/apps/goofy-e2e/src/e2e/main-tests/postfach-mail/postfach-nachrichten.cy.ts index a21f78ed8c51b085fa05ae9b5a43aa3cb964bd17..5fda81fdc8f441ae009fffce67b3ced35b825cba 100644 --- a/goofy-client/apps/goofy-e2e/src/e2e/main-tests/postfach-mail/postfach-nachrichten.cy.ts +++ b/goofy-client/apps/goofy-e2e/src/e2e/main-tests/postfach-mail/postfach-nachrichten.cy.ts @@ -27,21 +27,33 @@ import { HttpMethodE2E } from '../../../model/util'; import { VorgangE2E } from '../../../model/vorgang'; import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; import { VorgangPage } from '../../../page-objects/vorgang.po'; -import { dropCollections, interceptWithResponse } from '../../../support/cypress-helper'; +import { dropCollections, countDownloadFiles, deleteDownloadFolder, interceptWithResponse } from '../../../support/cypress-helper'; import { exist, notExist } from '../../../support/cypress.util'; import { LinkRelE2E } from '../../../support/linkrels'; import { removeLinkFromResource } from '../../../support/tech.util'; import { loginAsSabine } from '../../../support/user-util'; -import { createVorgang, initVorgang } from '../../../support/vorgang-util'; +import { buildVorgang, createVorgang, initVorgaenge, objectIds } from '../../../support/vorgang-util'; +import { PostfachMailItemE2E, VorgangAttachedItemE2E } from '../../../model/vorgang-attached-item'; +import { createPostfachNachrichtAttachedItem, createPostfachNachrichtReplyItem, initVorgangAttachedItem } from 'apps/goofy-e2e/src/support/vorgang-attached-item-util'; +import { PostfachMailE2EComponent} from 'apps/goofy-e2e/src/components/postfach/postfach-mail.e2e.component'; +import { PostfachMailPage } from 'apps/goofy-e2e/src/page-objects/postfach-mail.component.po'; + describe('Postfach Nachrichten', () => { const vorgangList: VorgangListE2EComponent = new MainPage().getVorgangList(); const vorgangPage: VorgangPage = new VorgangPage(); + const postfachMailContainer: PostfachMailE2EComponent = vorgangPage.getPostfachMailcontainer(); + const postfachMailPage: PostfachMailPage = new PostfachMailPage(); const vorgang: VorgangE2E = createVorgang(); + const vorgangWithReply: VorgangE2E = { ...buildVorgang(objectIds[0], 'VorgangWithReply') }; + + const postfachMailReply: PostfachMailItemE2E = createPostfachNachrichtReplyItem(); + const postfachNachrichtAttachedItem: VorgangAttachedItemE2E = { ...createPostfachNachrichtAttachedItem(objectIds[1], objectIds[0]), item: postfachMailReply }; before(() => { - initVorgang(vorgang); + initVorgaenge([vorgang, vorgangWithReply]); + initVorgangAttachedItem([postfachNachrichtAttachedItem]); loginAsSabine(); @@ -53,7 +65,7 @@ describe('Postfach Nachrichten', () => { dropCollections(); }) - describe('navigate to vorganDetail', () => { + describe('navigate to vorgangDetail', () => { beforeEach(() => { interceptWithResponse(HttpMethodE2E.GET, '*/vorgangs/*', (req) => modifyResponse(req)); @@ -74,4 +86,53 @@ describe('Postfach Nachrichten', () => { notExist(vorgangPage.getPostfachMailcontainer().getRoot()); }) }) + + describe('download nachrichten as pdf', () => { + + describe('by download button on vorgang main page', () => { + + it('should be visible as icon button', () => { + vorgangPage.getSubnavigation().getBackButton().click(); + vorgangList.getListItem(vorgangWithReply.name).getRoot().click(); + waitForSpinnerToDisappear(); + + exist(postfachMailContainer.getDownloadButtonWithLabel()); + }) + + it('should have 1 file in download folder after click on download', () => { + postfachMailContainer.getDownloadButtonWithLabel().click(); + waitForSpinnerToDisappear(); + + countDownloadFiles().then((count) => { + expect(count).to.eq(1); + deleteDownloadFolder(); + }); + }) + }) + + describe('by download button on nachrichten details page', () => { + + it ('should show an overview of all nachrichten after clicking on nachricht', () => { + postfachMailContainer.getList().click(); + waitForSpinnerToDisappear(); + + exist(postfachMailPage.getRoot()); + }) + + it ('should exist a pdf download button', () => { + exist(postfachMailPage.getDownloadButton()); + }) + + it('should have 1 file in download folder after click on download', () => { + postfachMailPage.getDownloadButton().click(); + waitForSpinnerToDisappear(); + + countDownloadFiles().then((count) => { + expect(count).to.eq(1); + deleteDownloadFolder(); + }); + }) + }) + + }) }) \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/page-objects/postfach-mail.component.po.ts b/goofy-client/apps/goofy-e2e/src/page-objects/postfach-mail.component.po.ts index 713082709338690a9594492a2b4cb125d1981078..a7d10ebb4e964c7385f8371e1f0ee99f62890ff9 100644 --- a/goofy-client/apps/goofy-e2e/src/page-objects/postfach-mail.component.po.ts +++ b/goofy-client/apps/goofy-e2e/src/page-objects/postfach-mail.component.po.ts @@ -27,13 +27,14 @@ import { PostfachMailListItem } from '../components/postfach/postfach-mail.e2e.c export class PostfachMailPage { - private readonly locatorBreadcrump: string = 'postfach-breadcrump'; - private readonly locatorRoot: string = 'postfach-mail-list'; + private readonly breadcrump: string = 'postfach-breadcrump'; + private readonly root: string = 'postfach-mail-list'; + private readonly downloadButton: string = 'postfach-pdf-export-button'; private readonly subnavigation: PostfachMailSubnavigation = new PostfachMailSubnavigation(); getRoot() { - return cy.getTestElement(this.locatorRoot); + return cy.getTestElement(this.root); } getSubnavigation(): PostfachMailSubnavigation { @@ -41,10 +42,14 @@ export class PostfachMailPage { } getBreadcrump() { - return cy.getTestElement(this.locatorBreadcrump); + return cy.getTestElement(this.breadcrump); } getListItem(subject: string): PostfachMailListItem { return new PostfachMailListItem(subject); } + + getDownloadButton() { + return cy.getTestElement(this.downloadButton); + } } \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts b/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts index d92b9e80d3c05c57f3e62671449e84d4ecd40f5b..b8a1bac27dbf39c722b3c2e268d4ef58780c6e54 100644 --- a/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts +++ b/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts @@ -1,5 +1,6 @@ import { rmdir } from 'fs'; import { Long, MongoClient, ObjectId } from 'mongodb'; +const fs = require('fs'); const Binary = require('mongodb').Binary;