Skip to content

Commit

Permalink
LPD-31536 Move vars to JournalEditArticlePage.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoHu97 authored and brianchandotcom committed Jul 16, 2024
1 parent f25611e commit 1823b1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
48 changes: 21 additions & 27 deletions modules/test/playwright/tests/journal-web/journalArticle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,9 @@ autoSaveAsDraftTest(

await fillAndClickOutside(page, localizableField, content);

const changesSavedIndicator = await page.locator(
'#_com_liferay_journal_web_portlet_JournalPortlet_changesSavedIndicator'
);

await expect(changesSavedIndicator).toBeVisible();
await expect(
journalEditArticlePage.changesSavedIndicator
).toBeVisible();

await page.getByTitle('Go to Web Content').click();

Expand Down Expand Up @@ -193,12 +191,7 @@ autoSaveAsDraftTest(
autoSaveAsDraftTest(
'LPD-26863: Undo/Redo buttons work with metadata fields',
async ({journalEditArticlePage, page, site}) => {
const changesSavedIndicator = await page.locator(
'#_com_liferay_journal_web_portlet_JournalPortlet_changesSavedIndicator'
);
const redoButton = page.getByTitle('Redo', {exact: true});
const title = getRandomString();
const undobutton = page.getByTitle('Undo', {exact: true});

await journalEditArticlePage.goto({siteUrl: site.friendlyUrlPath});

Expand All @@ -209,20 +202,22 @@ autoSaveAsDraftTest(
title
);

await expect(undobutton).toBeEnabled();
await expect(journalEditArticlePage.undoButton).toBeEnabled();
}).toPass();

await expect(changesSavedIndicator).toBeVisible();
await expect(
journalEditArticlePage.changesSavedIndicator
).toBeVisible();

await undobutton.click();
await journalEditArticlePage.undoButton.click();

await expect(undobutton).toBeDisabled();
await expect(journalEditArticlePage.undoButton).toBeDisabled();

await expect(journalEditArticlePage.titleInput).toHaveValue('');

await redoButton.click();
await journalEditArticlePage.redoButton.click();

await expect(redoButton).toBeDisabled();
await expect(journalEditArticlePage.redoButton).toBeDisabled();

await expect(journalEditArticlePage.titleInput).toHaveValue(title);
}
Expand All @@ -247,12 +242,7 @@ autoSaveAsDraftTest(
structureName,
});

const changesSavedIndicator = await page.locator(
'#_com_liferay_journal_web_portlet_JournalPortlet_changesSavedIndicator'
);
const redoButton = await page.getByTitle('Redo', {exact: true});
const title = getRandomString();
const undoButton = await page.getByTitle('Undo', {exact: true});

const localizableField = await page.getByRole('textbox', {
name: localizableFieldName,
Expand All @@ -265,22 +255,26 @@ autoSaveAsDraftTest(
title
);

await expect(undoButton).toBeEnabled();
await expect(journalEditArticlePage.undoButton).toBeEnabled();
}).toPass();

await expect(changesSavedIndicator).toBeVisible();
await expect(
journalEditArticlePage.changesSavedIndicator
).toBeVisible();

await fillAndClickOutside(page, localizableField, title);

await expect(changesSavedIndicator).toBeVisible();
await expect(
journalEditArticlePage.changesSavedIndicator
).toBeVisible();

await undoButton.click();
await journalEditArticlePage.undoButton.click();

await expect(localizableField).toHaveValue('');

await redoButton.click();
await journalEditArticlePage.redoButton.click();

await expect(redoButton).toBeDisabled();
await expect(journalEditArticlePage.redoButton).toBeDisabled();

await expect(localizableField).toHaveValue(title);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@ import {JournalPage} from './JournalPage';
export class JournalEditArticlePage {
readonly page: Page;

readonly changesSavedIndicator: Locator;
readonly journalPage: JournalPage;
readonly propertiesTab: Locator;
readonly publishButton: Locator;
readonly redoButton: Locator;
readonly submitForWorkflowButton: Locator;
readonly titleInput: Locator;
readonly undoButton: Locator;

constructor(page: Page) {
this.page = page;

this.changesSavedIndicator = page.locator(
'#_com_liferay_journal_web_portlet_JournalPortlet_changesSavedIndicator'
);
this.journalPage = new JournalPage(page);
this.propertiesTab = page.getByRole('tab', {name: 'Properties'});
this.publishButton = page.getByRole('button', {name: 'Publish'});
this.redoButton = page.getByTitle('Redo', {exact: true});
this.submitForWorkflowButton = page.getByRole('button', {
name: 'Submit for Workflow',
});
this.titleInput = page.getByPlaceholder('Untitled ');
this.undoButton = page.getByTitle('Undo', {exact: true});
}

async goto({
Expand Down

0 comments on commit 1823b1f

Please sign in to comment.