Skip to content

Commit

Permalink
chore(admin): #994 improve bpn edc configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mmaul committed Jul 2, 2024
1 parent ebff94a commit c6ee4c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</p>

<div class="bpn-config--save" *ngIf="changeInformation$ | async as info"
matTooltip="{{ ((info.deleted.length + info.added.length + info.changed.length) > 0 ? 'actions.save' : 'actions.noChanges') | i18n}}"
matTooltip="{{ ((info.deleted.length + info.added.length + info.changed.length) > 0 ? 'actions.saveChanges' : 'actions.noChanges') | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
Expand All @@ -44,6 +44,7 @@
[isDisabled]="!(info.deleted.length + info.added.length + info.changed.length)"
onkeydown="saveData()"
(click)="saveData()"
data-testId="bpn-config-save-button"
>
</app-button>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ describe('BpnConfigurationComponent', () => {
expect(newBpnInput.value).toEqual(bpn);
expect(newUrlInput.value).toEqual(url);

const addedCount = await waitFor(() => screen.getByTestId('text-with-icon--added'));
expect(addedCount).toBeInTheDocument();
expect(addedCount.innerText).toContain('pageAdmin.bpnConfig.added: 1');

const removeButton = (await waitFor(() => screen.getByText('actions.remove'))) as HTMLButtonElement;
fireEvent.click(removeButton);
Expand All @@ -123,8 +120,6 @@ describe('BpnConfigurationComponent', () => {
const urlInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-4'))) as HTMLInputElement;
const containerElement = await waitFor(() => screen.getByTestId('bpn-url-container-0'));

const changedCount = await waitFor(() => screen.getByTestId('text-with-icon--changed'));

expect(containerElement).not.toHaveClass('bpn-config__edit');
expect(containerElement).not.toHaveClass('bpn-config__new');

Expand All @@ -135,11 +130,9 @@ describe('BpnConfigurationComponent', () => {

expect(containerElement).toHaveClass('bpn-config__edit');
expect(urlInputElement.value).toEqual(url);
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 1');

const resetIcon = await waitFor(() => screen.getByTestId('BaseInputElement-4-icon'));
fireEvent.click(resetIcon);
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 0');
expect(containerElement).not.toHaveClass('bpn-config__edit');
expect(urlInputElement.value).toEqual(originalUrl);
});
Expand All @@ -149,9 +142,6 @@ describe('BpnConfigurationComponent', () => {
const bpnInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-3'))) as HTMLInputElement;
const containerElement = await waitFor(() => screen.getByTestId('bpn-url-container-0'));

const addedCount = await waitFor(() => screen.getByTestId('text-with-icon--added'));
const deletedCount = await waitFor(() => screen.getByTestId('text-with-icon--deleted'));

expect(containerElement).not.toHaveClass('bpn-config__edit');
expect(containerElement).not.toHaveClass('bpn-config__new');

Expand All @@ -161,16 +151,13 @@ describe('BpnConfigurationComponent', () => {

expect(containerElement).toHaveClass('bpn-config__new');
expect(bpnInputElement.value).toEqual(bpn);
expect(addedCount.innerText).toContain('pageAdmin.bpnConfig.added: 1');
expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 1');
});

it('should edit correctly', async () => {
await renderBpnConfigurationComponent();
const urlInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-4'))) as HTMLInputElement;
const containerElement = await waitFor(() => screen.getByTestId('bpn-url-container-0'));

const changedCount = await waitFor(() => screen.getByTestId('text-with-icon--changed'));

expect(containerElement).not.toHaveClass('bpn-config__edit');
expect(containerElement).not.toHaveClass('bpn-config__new');
Expand All @@ -182,11 +169,9 @@ describe('BpnConfigurationComponent', () => {

expect(containerElement).toHaveClass('bpn-config__edit');
expect(urlInputElement.value).toEqual(url);
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 1');

const resetIcon = await waitFor(() => screen.getByTestId('BaseInputElement-4-icon'));
fireEvent.click(resetIcon);
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 0');
expect(containerElement).not.toHaveClass('bpn-config__edit');
expect(urlInputElement.value).toEqual(originalUrl);
});
Expand All @@ -195,10 +180,6 @@ describe('BpnConfigurationComponent', () => {
const { fixture } = await renderBpnConfigurationComponent();
const bpnInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-3'))) as HTMLInputElement;
expect(bpnInputElement).toBeInTheDocument();
const baseValue = bpnInputElement.value;

const deletedCount = await waitFor(() => screen.getByTestId('text-with-icon--deleted'));
expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 0');

const deleteButton = (await waitFor(() => screen.getAllByText('actions.delete')))[0];
fireEvent.click(deleteButton);
Expand All @@ -207,7 +188,6 @@ describe('BpnConfigurationComponent', () => {
await sleepForTests(1000);
fixture.detectChanges();
expect(await waitFor(() => screen.queryByTestId('BaseInputElement-3'))).not.toBeInTheDocument();
expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 1');
});

it('should search', async () => {
Expand Down Expand Up @@ -241,7 +221,7 @@ describe('BpnConfigurationComponent', () => {
bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
right <= (window.innerWidth || document.documentElement.clientWidth);

const buttonElement = (await waitFor(() => screen.getByText('actions.saveChanges'))) as HTMLButtonElement;
const buttonElement = (await waitFor(() => screen.getByTestId('bpn-config-save-button'))) as HTMLButtonElement;
const bpnInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-15'))) as HTMLInputElement;

expect(bpnInputElement).toBeInTheDocument();
Expand All @@ -259,39 +239,21 @@ describe('BpnConfigurationComponent', () => {
it('should save data correctly', async () => {
const { fixture } = await renderBpnConfigurationComponent();

const addedCount = await waitFor(() => screen.getByTestId('text-with-icon--added'));
const deletedCount = await waitFor(() => screen.getByTestId('text-with-icon--deleted'));
const changedCount = await waitFor(() => screen.getByTestId('text-with-icon--changed'));

expect(addedCount.innerText).toContain('pageAdmin.bpnConfig.added: 0');
expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 0');
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 0');

const bpnInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-3'))) as HTMLInputElement;
const urlInputElement = (await waitFor(() => screen.getByTestId('BaseInputElement-6'))) as HTMLInputElement;

fireEvent.input(bpnInputElement, { target: { value: 'BPNLnewnewnewnew' } });
fireEvent.input(urlInputElement, { target: { value: 'test.de' } });

expect(addedCount.innerText).toContain('pageAdmin.bpnConfig.added: 1');
expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 1');
expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 1');


const buttonElement = (await waitFor(() => screen.getByText('actions.saveChanges'))) as HTMLButtonElement;
expect(buttonElement).toBeInTheDocument();
fireEvent.click(buttonElement);
fixture.detectChanges();
fixture.autoDetectChanges();

const saveButtonElement = (await waitFor(() => screen.getByText('actions.save'))) as HTMLButtonElement;
const saveButtonElement = (await waitFor(() => screen.getByTestId('bpn-config-save-button'))) as HTMLButtonElement;
expect(saveButtonElement).toBeInTheDocument();
fireEvent.click(saveButtonElement);

// Wait for saving data
await sleepForTests(1000);

await waitFor(() => expect(addedCount.innerText).toContain('pageAdmin.bpnConfig.added: 0'));
await waitFor(() => expect(deletedCount.innerText).toContain('pageAdmin.bpnConfig.deleted: 0'));
await waitFor(() => expect(changedCount.innerText).toContain('pageAdmin.bpnConfig.changed: 0'));
});
});

0 comments on commit c6ee4c9

Please sign in to comment.