Skip to content
Snippets Groups Projects
Commit 942653db authored by Martin's avatar Martin
Browse files

OZG-6185 move link conditions to parent component

parent 87fe396b
Branches
Tags
1 merge request!71Ozg 6185 adjust styling
Showing
with 92 additions and 90 deletions
@if (bescheidResource | hasLink: BescheidLinkRel.CREATE_DOCUMENT) {
<ods-button-card
class="w-full max-w-72"
[isLoading]="bescheidDocument.create.loading"
......@@ -9,4 +8,3 @@
>
<ods-bescheid-generate-icon icon />
</ods-button-card>
}
import { BescheidDocument, BescheidLinkRel, createEmptyBescheidDocument } from '@alfa-client/bescheid-shared';
import { HasLinkPipe } from '@alfa-client/tech-shared';
import {
existsAsHtmlElement,
getElementComponentFromFixtureByCss,
mock,
Mock,
notExistsAsHtmlElement,
triggerEvent,
} from '@alfa-client/test-utils';
import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock, triggerEvent } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BescheidGenerateIconComponent, ButtonCardComponent } from '@ods/system';
import { MockComponent } from 'ng-mocks';
......@@ -73,21 +66,11 @@ describe('BescheidWizardAutomatischErstellenButtonComponent', () => {
describe('template', () => {
describe('create button', () => {
it('should exists', () => {
component.bescheidResource = createBescheidResource([BescheidLinkRel.CREATE_DOCUMENT]);
fixture.detectChanges();
existsAsHtmlElement(fixture, createButtonTestId);
});
it('should NOT exists', () => {
component.bescheidResource = createBescheidResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, createButtonTestId);
});
it('should have been called with inputs', () => {
component.bescheidResource = createBescheidResource([BescheidLinkRel.CREATE_DOCUMENT]);
component.bescheidDocument = bescheidDocument;
......
......@@ -8,7 +8,6 @@ import { BescheidFormService } from '../../../bescheid.formservice';
})
export class BescheidWizardCreateDocumentButtonComponent {
@Input() bescheidResource: BescheidResource;
@Input() set bescheidDocument(value: BescheidDocument) {
this._bescheidDocument = value;
this.formService.updateBescheidDocumentFile(value.documentUri);
......
......@@ -24,23 +24,29 @@
-->
<div class="mt-4 flex flex-col gap-4">
@if (bescheidResource | hasLink: BescheidLinkRel.CREATE_DOCUMENT) {
<alfa-bescheid-wizard-create-document-button-container
[bescheidResource]="bescheidResource"
data-test-id="create-document-button"
></alfa-bescheid-wizard-create-document-button-container>
/>
}
@if (bescheidResource | hasLink: BescheidLinkRel.UPLOAD_BESCHEID_FILE) {
<alfa-bescheid-wizard-upload-document-button-container
[bescheidResource]="bescheidResource"
data-test-id="upload-document-button"
></alfa-bescheid-wizard-upload-document-button-container>
/>
}
@if (bescheidResource | hasLink: BescheidLinkRel.UPLOAD_ATTACHMENT) {
<alfa-bescheid-wizard-upload-attachment-button-container
[bescheidResource]="bescheidResource"
data-test-id="upload-attachment-button"
></alfa-bescheid-wizard-upload-attachment-button-container>
@if (bescheidResource | hasLink: bescheidLinkRel.UPDATE) {
/>
}
@if (bescheidResource | hasLink: BescheidLinkRel.UPDATE) {
<alfa-bescheid-wizard-weiter-button
[submitStateResource]="submitStateResource$ | async"
(clickEmitter)="gotoNextStep()"
data-test-id="weiter-button"
></alfa-bescheid-wizard-weiter-button>
/>
}
</div>
......@@ -21,10 +21,10 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BescheidDocument, BescheidLinkRel, createEmptyBescheidDocument } from '@alfa-client/bescheid-shared';
import { BescheidDocument, BescheidLinkRel, BescheidResource, createEmptyBescheidDocument } from '@alfa-client/bescheid-shared';
import { CommandResource } from '@alfa-client/command-shared';
import { HasLinkPipe, StateResource } from '@alfa-client/tech-shared';
import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock, notExistsAsHtmlElement, triggerEvent, } from '@alfa-client/test-utils';
import { existsAsHtmlElement, getMockComponent, mock, Mock, notExistsAsHtmlElement, triggerEvent } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockComponent } from 'ng-mocks';
import { EMPTY, of } from 'rxjs';
......@@ -129,59 +129,92 @@ describe('BescheidWizardDokumenteHochladenFormComponent', () => {
describe('template', () => {
describe('create document button', () => {
it('should exists', () => {
const bescheidResourceWithLink: BescheidResource = createBescheidResource([BescheidLinkRel.CREATE_DOCUMENT]);
it('should be visible if link is present', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
existsAsHtmlElement(fixture, createDocumentButtonTestId);
});
it('should have been called with inputs', () => {
it('should hide if link is missing', () => {
component.bescheidResource = createBescheidResource();
fixture.detectChanges();
const createDocumentButton: BescheidWizardCreateDocumentButtonContainerComponent =
getElementComponentFromFixtureByCss<BescheidWizardCreateDocumentButtonContainerComponent>(
fixture,
createDocumentButtonTestId,
);
expect(createDocumentButton.bescheidResource).toEqual(component.bescheidResource);
notExistsAsHtmlElement(fixture, createDocumentButtonTestId);
});
it('should have been called with inputs', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
expect(getMockComponent(fixture, BescheidWizardCreateDocumentButtonContainerComponent).bescheidResource).toEqual(
bescheidResourceWithLink,
);
});
});
describe('upload document button', () => {
it('should exists', () => {
const bescheidResourceWithLink: BescheidResource = createBescheidResource([BescheidLinkRel.UPLOAD_BESCHEID_FILE]);
it('should be visible if link is present', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
existsAsHtmlElement(fixture, uploadDocumentButtonTestId);
});
it('should have been called with inputs', () => {
it('should hide if link is missing', () => {
component.bescheidResource = createBescheidResource();
fixture.detectChanges();
const uploadDocumentButton: BescheidWizardUploadDocumentButtonContainerComponent =
getElementComponentFromFixtureByCss<BescheidWizardUploadDocumentButtonContainerComponent>(
fixture,
uploadDocumentButtonTestId,
);
expect(uploadDocumentButton.bescheidResource).toEqual(component.bescheidResource);
notExistsAsHtmlElement(fixture, uploadDocumentButtonTestId);
});
it('should have been called with inputs', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
expect(getMockComponent(fixture, BescheidWizardUploadDocumentButtonContainerComponent).bescheidResource).toEqual(
bescheidResourceWithLink,
);
});
});
describe('upload attachment button', () => {
it('should exists', () => {
const bescheidResourceWithLink: BescheidResource = createBescheidResource([BescheidLinkRel.UPLOAD_ATTACHMENT]);
it('should be visible if link is present', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
existsAsHtmlElement(fixture, uploadAttachmentButtonTestId);
});
it('should have been called with inputs', () => {
it('should hide if link is missing', () => {
component.bescheidResource = createBescheidResource();
fixture.detectChanges();
const uploadAttachmentButton: BescheidWizardUploadAttachmentButtonContainerComponent =
getElementComponentFromFixtureByCss<BescheidWizardUploadAttachmentButtonContainerComponent>(
fixture,
uploadDocumentButtonTestId,
);
expect(uploadAttachmentButton.bescheidResource).toEqual(component.bescheidResource);
notExistsAsHtmlElement(fixture, uploadAttachmentButtonTestId);
});
it('should have been called with inputs', () => {
component.bescheidResource = bescheidResourceWithLink;
fixture.detectChanges();
expect(getMockComponent(fixture, BescheidWizardUploadAttachmentButtonContainerComponent).bescheidResource).toEqual(
bescheidResourceWithLink,
);
});
});
......@@ -208,11 +241,8 @@ describe('BescheidWizardDokumenteHochladenFormComponent', () => {
component.bescheidResource = createBescheidResource([BescheidLinkRel.UPDATE]);
fixture.detectChanges();
const weiterButton: BescheidWizardWeiterButtonComponent =
getElementComponentFromFixtureByCss<BescheidWizardWeiterButtonComponent>(fixture, weiterButtonTestId);
component.submitStateResource$.subscribe();
expect(weiterButton.submitStateResource).toEqual(commandStateResource);
expect(getMockComponent(fixture, BescheidWizardWeiterButtonComponent).submitStateResource).toEqual(commandStateResource);
});
describe('output', () => {
......
......@@ -53,7 +53,7 @@ export class BescheidWizardDokumenteHochladenFormComponent {
private _bescheidDocument: BescheidDocument;
protected readonly bescheidLinkRel = BescheidLinkRel;
protected readonly BescheidLinkRel = BescheidLinkRel;
public gotoNextStep(): void {
if (isNil(this._bescheidDocument.resource)) {
......
import { BescheidAttachments } from '@alfa-client/bescheid-shared';
import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared';
import { getElementComponentFromFixtureByCss, triggerEvent } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
......@@ -6,7 +5,6 @@ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { faker } from '@faker-js/faker';
import { FileUploadEditorComponent } from '@ods/component';
import { MockComponent } from 'ng-mocks';
import { createBescheidAttachments } from '../../../../../../../bescheid-shared/src/test/bescheid';
import { createBinaryFileResource } from '../../../../../../../binary-file-shared/test/binary-file';
import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test';
import { createFile } from '../../../../../../../tech-shared/test/file';
......@@ -19,8 +17,6 @@ describe('BescheidWizardUploadAttachmentButtonComponent', () => {
const uploadEditorTestId: string = getDataTestIdOf('bescheid-wizard-upload-editor');
const bescheidAttachments: BescheidAttachments = createBescheidAttachments();
let formService: BescheidFormService;
beforeEach(() => {
......
<div [formGroup]="formService.form" class="w-full">
<ods-single-file-upload-editor
*ngIf="bescheidResource | hasLink: bescheidLinkRel.UPLOAD_BESCHEID_FILE"
[uploadInProgress]="upload.loading"
[formControlName]="formServiceClass.FIELD_BESCHEID_DOCUMENT"
(newFile)="uploadFile($event)"
......
......@@ -4,7 +4,6 @@ import {
existsAsHtmlElement,
getElementComponentFromFixtureByCss,
mock,
notExistsAsHtmlElement,
triggerEvent,
useFromMock,
} from '@alfa-client/test-utils';
......@@ -110,14 +109,6 @@ describe('BescheidWizardDokumentHochladenButtonComponent', () => {
existsAsHtmlElement(fixture, fileUploadEditorTestId);
});
it('should NOT exists', () => {
component.bescheidResource = createBescheidResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, fileUploadEditorTestId);
});
it('should have been called with inputs', () => {
component.bescheidResource = createBescheidResource([BescheidLinkRel.UPLOAD_BESCHEID_FILE]);
component.upload = createPendingUpload();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment