diff --git a/goofy-client/apps/goofy-e2e/src/components/ui/connection-timeout-retry-dialog.e2e.component.ts b/goofy-client/apps/goofy-e2e/src/components/ui/connection-timeout-retry-dialog.e2e.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6a1ebdfd8db937fa9648797139d44990e57fb96 --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/components/ui/connection-timeout-retry-dialog.e2e.component.ts @@ -0,0 +1,54 @@ +export class ConnectionTimeoutRetryDialogE2EComponent { + + private readonly locatorIcon: string = 'icon'; + private readonly locatorHeader: string = 'header'; + private readonly locatorMessage: string = 'message'; + + private readonly locatorRoot: string = 'connection-timeout-retry-dialog'; + + getRoot() { + return cy.getTestElement(this.locatorRoot); + } + + getIcon() { + return this.getRoot().getTestElement(this.locatorIcon); + } + + getHeader() { + return this.getRoot().getTestElement(this.locatorHeader); + } + + getMessage() { + return this.getRoot().getTestElement(this.locatorMessage); + } +} + +export class ConnectionTimeoutRetryFailDialogE2EComponent { + + private readonly locatorIcon: string = 'icon'; + private readonly locatorHeader: string = 'header'; + private readonly locatorMessage: string = 'message'; + private readonly locatorReloadButton: string = 'reload-button'; + + private readonly locatorRoot: string = 'connection-timeout-retry-fail-dialog'; + + getRoot() { + return cy.getTestElement(this.locatorRoot); + } + + getIcon() { + return this.getRoot().getTestElement(this.locatorIcon); + } + + getHeader() { + return this.getRoot().getTestElement(this.locatorHeader); + } + + getMessage() { + return this.getRoot().getTestElement(this.locatorMessage); + } + + getReloadButton() { + return this.getRoot().getTestElement(this.locatorReloadButton); + } +} \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/components/ui/internal-server-error-diaog.e2e.component.ts b/goofy-client/apps/goofy-e2e/src/components/ui/internal-server-error-diaog.e2e.component.ts index fdefc66ff694fef0b4d9ffe6303db3af9e73652e..64083e7225e5e22cd00bdf36c4a0517e9e366fbe 100644 --- a/goofy-client/apps/goofy-e2e/src/components/ui/internal-server-error-diaog.e2e.component.ts +++ b/goofy-client/apps/goofy-e2e/src/components/ui/internal-server-error-diaog.e2e.component.ts @@ -4,7 +4,7 @@ export class InternalServerErrorDialogE2EComponent { private readonly locatorHeader: string = 'error-header'; private readonly locatorMessage: string = 'error-message'; - private readonly locatoLogoutButton: string = 'logout-button'; + private readonly locatorLogoutButton: string = 'logout-button'; getIcon() { return cy.getTestElement(this.locatorIcon); @@ -19,6 +19,6 @@ export class InternalServerErrorDialogE2EComponent { } getLogoutButton() { - return cy.getTestElement(this.locatoLogoutButton); + return cy.getTestElement(this.locatorLogoutButton); } } \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/integration/interceptor/interceptor-connection-timout.e2e-spec.ts b/goofy-client/apps/goofy-e2e/src/integration/interceptor/interceptor-connection-timout.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f1a77901e5715315557c6eae70f84a21089db66 --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/integration/interceptor/interceptor-connection-timout.e2e-spec.ts @@ -0,0 +1,75 @@ +import { ConnectionTimeoutRetryDialogE2EComponent, ConnectionTimeoutRetryFailDialogE2EComponent } from '../../components/ui/connection-timeout-retry-dialog.e2e.component'; +import { VorgangDetailHeaderE2EComponent } from '../../components/vorgang/vorgang-detail-header.e2e.component'; +import { VorgangListE2EComponent } from '../../components/vorgang/vorgang-list.e2e.component'; +import { VorgangE2E } from '../../model/vorgang'; +import { MainPage } from '../../page-objects/main.po'; +import { VorgangPage } from '../../page-objects/vorgang.po'; +import { interceptWithResponse, waitOfInterceptor } from '../../support/cypress-helper'; +import { contains, exist } from '../../support/cypress.util'; +import { loginAsTest } from '../../support/user-util'; +import { createVorgang, initVorgang } from '../../support/vorgang-util'; + +describe('Interceptor Connection Timeout', () => { + const mainPage: MainPage = new MainPage(); + const vorgangList: VorgangListE2EComponent = mainPage.getVorgangList(); + const connectionTimeoutRetryDialog: ConnectionTimeoutRetryDialogE2EComponent = mainPage.getConnectionTimeoutRetryDialog(); + const connectionTimeoutRetryFailDialog: ConnectionTimeoutRetryFailDialogE2EComponent = mainPage.getConnectionTimeoutRetryFailDialog(); + + const vorgangPage: VorgangPage = new VorgangPage(); + const vorgangHeader: VorgangDetailHeaderE2EComponent = vorgangPage.getVorgangDetailHeader(); + + let vorgang: VorgangE2E = createVorgang(); + + before(() => { + initVorgang(vorgang); + + loginAsTest(); + + exist(vorgangList.getRoot()); + }) + + describe('annehmen', () => { + + const interceptor: string = 'doVorgangAnnehmen'; + const statusCode: number = 503; + + beforeEach(() => { + const url: string = '*/vorgangs/602566a807bb665df9a86111/relations/602566a807bb665df9a86111/0/commands'; + + interceptWithResponse('POST', url, { statusCode }).as(interceptor); + }) + + it('should navigate to vorgang detail', () => { + vorgangList.getListItem(vorgang.name).getRoot().click(); + + exist(vorgangHeader.getRoot()); + }) + + it('should show retry request dialog', () => { + vorgangPage.getFormularContainer().clickAnnehmenByButton(); + + waitOfInterceptor(interceptor).then((interception) => { + assert(interception.response.statusCode, statusCode.toString()); + exist(connectionTimeoutRetryDialog.getIcon()); + contains(connectionTimeoutRetryDialog.getHeader(), 'Es ist ein Verbindungsfehler aufgetreten ...'); + contains(connectionTimeoutRetryDialog.getMessage(), 'Ihre Anfrage wird wiederholt'); + }) + }) + + it.skip('(LOCAL ONLY) should show fail dialog after time is over', () => { + cy.wait(6000); + + exist(connectionTimeoutRetryFailDialog.getIcon()); + contains(connectionTimeoutRetryFailDialog.getHeader(), 'Zeitüberschreitung der Verbindung'); + contains(connectionTimeoutRetryFailDialog.getMessage(), 'Auch nach weiteren Versuchen konnte keine Verbindung aufgebaut werden'); + exist(connectionTimeoutRetryFailDialog.getReloadButton()); + }) + + it.skip('(LOCAL ONLY) should reload page on click on button', () => { + connectionTimeoutRetryFailDialog.getReloadButton().click(); + + exist(vorgangPage.getSpinner()); + exist(vorgangPage.getVorgangDetailHeader().getRoot()); + }) + }) +}) \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/page-objects/main.po.ts b/goofy-client/apps/goofy-e2e/src/page-objects/main.po.ts index b33fa6f7cb65918eb6006a4f04aa2a6bc1a9c618..b15e24d838f170c7e530f3ce5f3e330cdaa4b64e 100644 --- a/goofy-client/apps/goofy-e2e/src/page-objects/main.po.ts +++ b/goofy-client/apps/goofy-e2e/src/page-objects/main.po.ts @@ -1,3 +1,4 @@ +import { ConnectionTimeoutRetryDialogE2EComponent, ConnectionTimeoutRetryFailDialogE2EComponent } from '../components/ui/connection-timeout-retry-dialog.e2e.component'; import { InternalServerErrorDialogE2EComponent } from '../components/ui/internal-server-error-diaog.e2e.component'; import { SnackBarE2EComponent } from '../components/ui/snackbar.e2e.component'; import { VorgangListE2EComponent } from '../components/vorgang/vorgang-list.e2e.component'; @@ -10,7 +11,9 @@ export class MainPage { private readonly vorgangList: VorgangListE2EComponent = new VorgangListE2EComponent(); private readonly snackBar: SnackBarE2EComponent = new SnackBarE2EComponent(); - private readonly dialog: InternalServerErrorDialogE2EComponent = new InternalServerErrorDialogE2EComponent(); + private readonly internalServerErrorDialog: InternalServerErrorDialogE2EComponent = new InternalServerErrorDialogE2EComponent(); + private readonly connectionTimeoutRetryDialog: ConnectionTimeoutRetryDialogE2EComponent = new ConnectionTimeoutRetryDialogE2EComponent(); + private readonly connectionTimeoutRetryFailDialog: ConnectionTimeoutRetryFailDialogE2EComponent = new ConnectionTimeoutRetryFailDialogE2EComponent(); public open() { cy.visit('/'); @@ -33,6 +36,14 @@ export class MainPage { } public getInternalServerErrorDialog(): InternalServerErrorDialogE2EComponent { - return this.dialog; + return this.internalServerErrorDialog; + } + + public getConnectionTimeoutRetryDialog(): ConnectionTimeoutRetryDialogE2EComponent { + return this.connectionTimeoutRetryDialog; + } + + public getConnectionTimeoutRetryFailDialog(): ConnectionTimeoutRetryFailDialogE2EComponent { + return this.connectionTimeoutRetryFailDialog; } } \ No newline at end of file diff --git a/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-dialog/connection-timeout-retry-dialog.component.html b/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-dialog/connection-timeout-retry-dialog.component.html index 91718a0c8dbedb79dd70a9e66d127efb93d751ce..fec5194480e0321aff9f4f373c6584db536abf44 100644 --- a/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-dialog/connection-timeout-retry-dialog.component.html +++ b/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-dialog/connection-timeout-retry-dialog.component.html @@ -1,10 +1,10 @@ -<div class="notification-dialog"> +<div class="notification-dialog" data-test-id="connection-timeout-retry-dialog"> <h2 mat-dialog-title> - <mat-icon data-test-id="error-icon">error_outline</mat-icon> - <span data-test-id="error-header">Es ist ein Verbindungsfehler aufgetreten ...</span> + <mat-icon data-test-id="icon">error_outline</mat-icon> + <span data-test-id="header">Es ist ein Verbindungsfehler aufgetreten ...</span> </h2> <mat-dialog-content> - <p data-test-id="error-message"> + <p data-test-id="message"> Ihre Anfrage wird wiederholt </p> </mat-dialog-content> diff --git a/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-fail-dialog/connection-timeout-retry-fail-dialog.component.html b/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-fail-dialog/connection-timeout-retry-fail-dialog.component.html index ff8b4a34a9d5f174c7e06346a1f535d5afd120e1..44ece0ac3025fe092203bd9697e543209314379c 100644 --- a/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-fail-dialog/connection-timeout-retry-fail-dialog.component.html +++ b/goofy-client/libs/ui/src/lib/ui/http-error-dialog/connection-timeout-retry-fail-dialog/connection-timeout-retry-fail-dialog.component.html @@ -1,13 +1,15 @@ -<div class="notification-dialog"> +<div class="notification-dialog" data-test-id="connection-timeout-retry-fail-dialog"> <h2 mat-dialog-title> - <mat-icon data-test-id="error-icon">error_outline</mat-icon> - <span data-test-id="error-header">Zeitüberschreitung der Verbindung</span> + <mat-icon data-test-id="icon">error_outline</mat-icon> + <span data-test-id="header">Zeitüberschreitung der Verbindung</span> </h2> <mat-dialog-content> - <p data-test-id="error-message"> + <p data-test-id="message"> Auch nach weiteren Versuchen konnte keine Verbindung aufgebaut werden. <br /> Bitte wenden Sie sich an Ihren Administrator </p> - <goofy-client-button-with-spinner tabindex="-1" class="button" icon="refresh" text="Reload" (click)="reload()"></goofy-client-button-with-spinner> + <goofy-client-button-with-spinner tabindex="-1" class="button" icon="refresh" text="Reload" data-test-id="reload-button" + (click)="reload()"> + </goofy-client-button-with-spinner> </mat-dialog-content> </div>