Skip to content

Commit

Permalink
LPD-22768 Add new Playwright test and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ctang3 authored and brianchandotcom committed Oct 1, 2024
1 parent b9c2e4b commit f7136ed
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ export function createMoveURL(
export function createViewURL(
ctCollectionId,
namespace,
timelineItemCtEntryId
timelineClassNameId,
timelineClassPK
) {
return createMVCRenderCommandURL(
ctCollectionId,
'/change_tracking/view_change',
namespace,
{
ctEntryId: timelineItemCtEntryId,
modelClassNameId: timelineClassNameId,
modelClassPK: timelineClassPK,
}
);
}
Expand Down Expand Up @@ -121,7 +123,8 @@ export default function TimelineDropdownMenu({
const viewURL = createViewURL(
ctCollectionId,
namespace,
timelineItem.ctEntryId
timelineClassNameId,
timelineClassPK
);

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,26 @@ test('LPD-25853 Edit in x publication is added in the timeline dropdown actions'

await documentLibraryPage.goToEditFileEntry(title1);

await page.getByLabel('timeline-button').click();
const timelineButton = page.getByLabel('timeline-button');
await timelineButton.waitFor();
await timelineButton.click();

const timelineActionsButton = page.locator('.publication-timeline button');

await timelineActionsButton.waitFor();

await timelineActionsButton.click();

const editButton = page.getByRole('button', {
name: `Edit in ${ctCollection.name}`,
});

await editButton.waitFor();
await expect(editButton).toBeVisible();

await editButton.click();

await page
.locator('.change-tracking-indicator-title')
.filter({hasText: ctCollection.name})
.waitFor();

await expect(
page
.locator('.change-tracking-indicator-title')
Expand All @@ -107,6 +111,7 @@ test('LPD-25853 Edit in x publication is added in the timeline dropdown actions'
});

test('LPD-25853 Review Change is added in the timeline dropdown actions', async ({
apiHelpers,
ctCollection,
documentLibraryPage,
page,
Expand All @@ -116,20 +121,28 @@ test('LPD-25853 Review Change is added in the timeline dropdown actions', async

await documentLibraryPage.goToEditFileEntry(title2);

await page.getByLabel('timeline-button').click();
const timelineButton = page.getByLabel('timeline-button');
await timelineButton.waitFor();
await timelineButton.click();

const timelineActionsButton = page.locator('.publication-timeline button');

await timelineActionsButton.waitFor();

await timelineActionsButton.click();

const reviewButton = page.getByRole('button', {name: 'Review Change'});

const reviewButton = (await apiHelpers.featureFlag.isFeatureFlagEnabled(
'LPD-20556'
))
? page.getByRole('button', {name: 'Review Change'})
: page.getByRole('button', {name: 'Review Changes'});
await reviewButton.waitFor();
await expect(reviewButton).toBeVisible();

await reviewButton.click();

await page
.locator('.publication-name')
.filter({hasText: ctCollection.name})
.waitFor();

await expect(
page.locator('.publication-name').filter({hasText: ctCollection.name})
).toBeVisible();
Expand All @@ -146,20 +159,21 @@ test('LPD-25853 Discard Change is added in the timeline dropdown actions', async

await documentLibraryPage.goToEditFileEntry(title2);

await page.getByLabel('timeline-button').click();
const timelineButton = page.getByLabel('timeline-button');
await timelineButton.waitFor();
await timelineButton.click();

const timelineActionsButton = page.locator('.publication-timeline button');

await timelineActionsButton.waitFor();

await timelineActionsButton.click();

const discardButton = page.getByRole('button', {name: 'Discard'});

await discardButton.waitFor();
await expect(discardButton).toBeVisible();

await discardButton.click();

await page.getByText('Discard Changes').waitFor();

await expect(page.getByText('Discard Changes')).toBeVisible();
});

Expand All @@ -172,20 +186,21 @@ test('LPD-25853 Move Change is added in the timeline dropdown actions', async ({

await documentLibraryPage.goToEditFileEntry(title2);

await page.getByLabel('timeline-button').click();
const timelineButton = page.getByLabel('timeline-button');
await timelineButton.waitFor();
await timelineButton.click();

const timelineActionsButton = page.locator('.publication-timeline button');

await timelineActionsButton.waitFor();

await timelineActionsButton.click();

const moveButton = page.getByRole('button', {name: 'Move'});

await moveButton.waitFor();
await expect(moveButton).toBeVisible();

await moveButton.click();

await page.getByText('Move Changes').waitFor();

await expect(page.getByText('Move Changes')).toBeVisible();
});

Expand Down Expand Up @@ -257,9 +272,13 @@ test('LPD-25853 Timeline actions are not visible to user without permissions', a

await documentLibraryPage.goto(site.friendlyUrlPath);

await page.getByRole('link', {exact: true, name: title1}).click();
const dlFileEntryLink = page.getByRole('link', {exact: true, name: title1});
await dlFileEntryLink.waitFor();
await dlFileEntryLink.click();

await page.getByLabel('timeline-button').click();
const timelineButton = page.getByLabel('timeline-button');
await timelineButton.waitFor();
await timelineButton.click();

await page.getByText(ctCollection.name).waitFor();

Expand Down Expand Up @@ -299,21 +318,20 @@ test('LPD-26155 Conflict warning is visible when content is edited in more than
);

const timelineButton = page.locator('.change-tracking-timeline-button svg');

await timelineButton.waitFor();
await expect(timelineButton).toHaveCSS('color', 'rgb(255, 182, 141)');

await timelineButton.click();

const conflictWarning = page.locator(
'.publication-timeline .alert-warning'
);

await conflictWarning.waitFor();
await expect(conflictWarning).toBeVisible();

let conflictIcon = page.locator(
'.publication-timeline .change-tracking-conflict-icon-warning'
);

await conflictIcon.first().waitFor();
await expect(conflictIcon).toHaveCount(2);

await apiHelpers.featureFlag.updateFeatureFlag('LPD-20556', false);
Expand All @@ -322,10 +340,12 @@ test('LPD-26155 Conflict warning is visible when content is edited in more than

await documentLibraryPage.goto(site.friendlyUrlPath);

await page.getByRole('link', {exact: true, name: title3}).click();
const dlFileEntryLink = page.getByRole('link', {exact: true, name: title3});
await dlFileEntryLink.waitFor();
await dlFileEntryLink.click();

conflictIcon = page.locator('.change-tracking-conflict-icon-warning');

await conflictIcon.first().waitFor();
await expect(conflictIcon).toBeVisible();

await apiHelpers.headlessChangeTracking.deleteCTCollection(
Expand Down Expand Up @@ -364,21 +384,25 @@ test('LPD-26155 Production conflict info is visible when new changes have been m
const prodConflictIcon = page.locator(
'.change-tracking-conflict-icon-danger'
);

await prodConflictIcon.waitFor();
await expect(prodConflictIcon).toBeVisible();

await prodConflictIcon.click();

await expect(page.getByText('Production Conflict')).toBeVisible();
const prodConflictText = page.getByText('Production Conflict');
await prodConflictText.waitFor();
await expect(prodConflictText).toBeVisible();

await apiHelpers.featureFlag.updateFeatureFlag('LPD-20556', false);

// Refresh the page after turning off feature flag

await documentLibraryPage.goto(site.friendlyUrlPath);

await page.getByRole('link', {exact: true, name: title2}).click();
const dlFileEntryLink = page.getByRole('link', {exact: true, name: title2});
await dlFileEntryLink.waitFor();
await dlFileEntryLink.click();

await prodConflictIcon.waitFor();
await expect(prodConflictIcon).toBeVisible();
});

Expand All @@ -392,9 +416,11 @@ test('LPD-26155 No conflict icon is visible when there are no conflictsn', async

await documentLibraryPage.goto(site.friendlyUrlPath);

await page.getByRole('link', {exact: true, name: title2}).click();
const dlFileEntryLink = page.getByRole('link', {exact: true, name: title2});
await dlFileEntryLink.waitFor();
await dlFileEntryLink.click();

const noConflictIcon = page.locator('.change-tracking-conflict-icon');

await noConflictIcon.waitFor();
await expect(noConflictIcon).toBeVisible();
});
Loading

0 comments on commit f7136ed

Please sign in to comment.