Skip to content

Commit

Permalink
Merge pull request #1800 from France-ioi/feature/add-link-for-group-s…
Browse files Browse the repository at this point in the history
…ubtitle

Adds link for subtitle
  • Loading branch information
smadbe authored Oct 1, 2024
2 parents 8c709d2 + d0d8af8 commit 41acc67
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
38 changes: 27 additions & 11 deletions e2e/groups/group-subtitle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test, expect } from 'e2e/groups/create-group-fixture';
import { initAsUsualUser } from 'e2e/helpers/e2e_auth';

const associatedItemName = 'Task #1';

test.beforeEach(async ({ page }) => {
await initAsUsualUser(page);
});
Expand All @@ -14,13 +16,13 @@ test('checks group subtitle add and remove', async ({ page, groupSettingsPage, c
await groupSettingsPage.goto(`/groups/by-id/${ createGroup.groupId };p=/settings`);
await expect.soft(page.getByRole('heading', { name: createGroup.groupName })).toBeVisible();

await test.step('checks is associated activity visible', async () => {
await groupSettingsPage.checksIsAssociatedActivityVisible();
await test.step('checks is associated activity section visible', async () => {
await groupSettingsPage.checksIsAssociatedActivitySectionVisible();
await groupSettingsPage.checksIsAssociatedActivitySearchInputVisible();
});

await test.step('search and select exist content', async () => {
await groupSettingsPage.searchAndSelectAssociatedActivity('Task #1');
await groupSettingsPage.searchAndSelectAssociatedActivity(associatedItemName);
});

await test.step('save group data', async () => {
Expand All @@ -31,18 +33,32 @@ test('checks group subtitle add and remove', async ({ page, groupSettingsPage, c
});

await test.step('checks subtitle is visible', async () => {
await groupSettingsPage.checksIsSubtitleLoadingVisible();
await groupSettingsPage.checksIsSubtitleVisible('Task #1');
});

await test.step('checks navigation to associated item', async () => {
await groupSettingsPage.navigateToAssociatedActivity(associatedItemName);
await expect.soft(page.getByRole('heading', { name: associatedItemName })).toBeVisible();
await page.goBack();
await groupSettingsPage.checksIsSubtitleLoadingVisible();
await expect.soft(page.getByRole('heading', { name: createGroup.groupName })).toBeVisible();
});

await test.step('checks is associated activity visible', async () => {
await groupSettingsPage.checksIsAssociatedActivitySectionVisible();
await groupSettingsPage.checksIsAssociatedActivityVisible(associatedItemName);
});

await test.step('remove associated activity', async () => {
await groupSettingsPage.removeAssociatedActivity();
await groupSettingsPage.saveChangesAndCheckNotification();
await groupSettingsPage.waitForGroupResponse(createGroup.groupId);
await Promise.all([
groupSettingsPage.saveChangesAndCheckNotification(),
groupSettingsPage.waitForGroupResponse(createGroup.groupId),
]);
});

await test.step('checks subtitle is not visible', async () => {
await groupSettingsPage.checksIsSubtitleNotVisible('Task #1');
await groupSettingsPage.checksIsSubtitleNotVisible(associatedItemName);
});
});

Expand All @@ -51,13 +67,13 @@ test('checks group subtitle failure response', async ({ page, groupSettingsPage,
await groupSettingsPage.goto(`/groups/by-id/${ createGroup.groupId };p=/settings`);
await expect.soft(page.getByRole('heading', { name: createGroup.groupName })).toBeVisible();

await test.step('checks is associated activity visible', async () => {
await groupSettingsPage.checksIsAssociatedActivityVisible();
await test.step('checks is associated activity section visible', async () => {
await groupSettingsPage.checksIsAssociatedActivitySectionVisible();
await groupSettingsPage.checksIsAssociatedActivitySearchInputVisible();
});

await test.step('search and select exist content', async () => {
await groupSettingsPage.searchAndSelectAssociatedActivity('Task #1');
await groupSettingsPage.searchAndSelectAssociatedActivity(associatedItemName);
});

await test.step('save group data', async () => {
Expand All @@ -76,7 +92,7 @@ test('checks group subtitle failure response', async ({ page, groupSettingsPage,
await groupSettingsPage.abortOrContinueAssociatedItemResponse('10886782127135168');
await groupSettingsPage.retrySubtitle();
await groupSettingsPage.checksIsSubtitleLoadingVisible();
await groupSettingsPage.checksIsSubtitleVisible('Task #1');
await groupSettingsPage.checksIsSubtitleVisible(associatedItemName);
});

await test.step('checks subtitle is forbidden', async () => {
Expand Down
19 changes: 16 additions & 3 deletions e2e/groups/pages/group-settings-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ export class GroupSettingsPage {
}

async checkSuccessfulNotification(): Promise<void> {
await expect.soft(this.page.getByText('SuccessChanges successfully')).toBeVisible();
const toastLocator = this.page.locator('p-toast');
const successfulLocator = toastLocator.getByText('SuccessChanges successfully');
await expect.soft(successfulLocator).toBeVisible();
await expect.soft(toastLocator.getByLabel('Close')).toBeVisible();
await toastLocator.getByLabel('Close').click();
await expect.soft(successfulLocator).not.toBeVisible();
}

async saveChanges(): Promise<void> {
Expand All @@ -112,10 +117,14 @@ export class GroupSettingsPage {
await confirmBtnLocator.click();
}

async checksIsAssociatedActivityVisible(): Promise<void> {
async checksIsAssociatedActivitySectionVisible(): Promise<void> {
await expect.soft(this.associatedActivitySectionLocator).toBeVisible();
}

async checksIsAssociatedActivityVisible(name: string): Promise<void> {
await expect.soft(this.associatedActivitySectionLocator.getByText(name)).toBeVisible();
}

async checksIsAssociatedActivitySearchInputVisible(): Promise<void> {
await expect.soft(this.searchExistingContentInputLocator).toBeVisible();
}
Expand All @@ -130,7 +139,7 @@ export class GroupSettingsPage {
}

async checksIsSubtitleLoadingVisible(): Promise<void> {
await expect.soft(this.page.getByText('Associated activity: loading...')).toBeVisible();
await expect.soft(this.page.getByText('loading...')).toBeVisible();
}

async checksIsSubtitleVisible(name: string): Promise<void> {
Expand All @@ -153,6 +162,10 @@ export class GroupSettingsPage {
);
}

async navigateToAssociatedActivity(name: string): Promise<void> {
await this.page.getByText(`Associated activity: ${name}`).getByRole('link', { name }).click();
}

async removeAssociatedActivity(): Promise<void> {
await this.associatedActivitySectionLocator.getByRole('button').click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="group-title alg-h1">{{ groupData().group.name }}</h1>
}
} @else {
@if (state.data.string.title; as title) {
{{ title }}
<a class="alg-link" [routerLink]="state.data | itemRoute | url">{{ title }}</a>
} @else {
<span i18n>Unknown title</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { LoadingComponent } from 'src/app/ui-components/loading/loading.componen
import { ErrorComponent } from 'src/app/ui-components/error/error.component';
import { mapToFetchState } from 'src/app/utils/operators/state';
import { ButtonDirective } from 'primeng/button';
import { RouterLink } from '@angular/router';
import { ItemRoutePipe } from 'src/app/pipes/itemRoute';
import { RouteUrlPipe } from 'src/app/pipes/routeUrl';

@Component({
selector: 'alg-group-header',
Expand All @@ -22,6 +25,9 @@ import { ButtonDirective } from 'primeng/button';
LoadingComponent,
ErrorComponent,
ButtonDirective,
RouterLink,
ItemRoutePipe,
RouteUrlPipe,
],
})
export class GroupHeaderComponent implements OnDestroy {
Expand Down

0 comments on commit 41acc67

Please sign in to comment.