Skip to content

Commit

Permalink
fixes for linter, import, method name and locator
Browse files Browse the repository at this point in the history
  • Loading branch information
azakrzewski-hy committed Oct 2, 2023
1 parent aa019e2 commit ff9d522
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ test.describe('Create folder from template', () => {
let folderId: string;
const selectDialogTitle = 'Select a folder template';
const dialogBreadcrumb = 'Space Templates';
const cancelButton = 'CANCEL';
const createButton = 'Create';
const nameLabel = 'Name *';
const titleLabel = 'Title';
const descriptionLabel = 'Description';
Expand All @@ -61,21 +59,21 @@ test.describe('Create folder from template', () => {
const commandKey = 'Meta';
const random = Utils.random();

const fileInRootFolder = `afile-in-root-${random}.txt`;
const folderInRootFolder = `afolder-in-root-${random}`;
const fileInRootFolder = `file-in-root-${random}.txt`;
const folderInRootFolder = `folder-in-root-${random}`;

const templateFolder1 = `aatemplate-folder1-${random}`;
const fileInFolder1 = `aafile-1-${random}.txt`;
const templateSubFolder = `atemplate-sub-folder-${random}`;
const templateFolder1 = `template-folder1-${random}`;
const fileInFolder1 = `file-1-${random}.txt`;
const templateSubFolder = `template-sub-folder-${random}`;

const templateFolder2 = `atemplate-folder2-${random}`;
const fileInFolder2 = `afile-2-${random}.txt`;
const templateFolder2 = `template-folder2-${random}`;
const fileInFolder2 = `file-2-${random}.txt`;

const restrictedTemplateFolder = `arestricted-folder-${random}`;
const fileInRestrictedFolder = `arestricted-file-${random}.txt`;
const restrictedTemplateFolder = `restricted-folder-${random}`;
const fileInRestrictedFolder = `restricted-file-${random}.txt`;

const createDialogTitle = `Create new folder from '${templateFolder1}'`;
const commonFolderName = `aplaywright-folder-${Utils.random()}`;
const commonFolderName = `playwright-folder-${Utils.random()}`;

const templates: NodeContentTree = {
folders: [
Expand Down Expand Up @@ -128,7 +126,7 @@ test.describe('Create folder from template', () => {
selectFolderTemplateDialog = personalFiles.contentNodeSelector;
dataTable = personalFiles.dataTable;
toolbar = personalFiles.acaHeader;
await toolbar.selectCreateFolderFromTemplate();
await toolbar.clickCreateFolderFromTemplate();
});

test.describe('Select Template dialog', () => {
Expand Down Expand Up @@ -224,8 +222,8 @@ test.describe('Create folder from template', () => {
await expect.soft(createFolderFromTemplateDialog.getDialogLabel(titleLabel)).toHaveValue(emptyString);
await expect.soft(createFolderFromTemplateDialog.getDialogLabel(descriptionLabel)).toBeVisible();
await expect.soft(createFolderFromTemplateDialog.getDialogLabel(descriptionLabel)).toHaveValue(emptyString);
await expect.soft(createFolderFromTemplateDialog.actionButton(cancelButton)).toBeEnabled();
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeEnabled();
await expect.soft(createFolderFromTemplateDialog.cancelButton).toBeEnabled();
await expect(createFolderFromTemplateDialog.createButton).toBeEnabled();
});

test('[C325143] Folder name is required', async () => {
Expand All @@ -237,7 +235,7 @@ test.describe('Create folder from template', () => {
expect
.soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameIsRequiredError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
});

test('[C325144] Special characters in folder name', async () => {
Expand All @@ -253,7 +251,7 @@ test.describe('Create folder from template', () => {
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
}
});

Expand All @@ -264,7 +262,7 @@ test.describe('Create folder from template', () => {
expect
.soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameEndWithDotError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
});

test('[C325146] Folder name containing only spaces', async () => {
Expand All @@ -278,7 +276,7 @@ test.describe('Create folder from template', () => {
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
});

test('[C325141] Title too long', async () => {
Expand All @@ -288,7 +286,7 @@ test.describe('Create folder from template', () => {
expect
.soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.titleLengthLimitError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
});

test('[C325140] Description too long', async () => {
Expand All @@ -301,7 +299,7 @@ test.describe('Create folder from template', () => {
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFolderFromTemplateDialog.actionButton(createButton)).toBeDisabled();
await expect(createFolderFromTemplateDialog.createButton).toBeDisabled();
});

test('[C325156] Create a folder with a duplicate name', async ({ personalFiles }) => {
Expand All @@ -314,14 +312,14 @@ test.describe('Create folder from template', () => {

test('[C325155] Cancel folder creation', async () => {
await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
await createFolderFromTemplateDialog.actionButton(cancelButton).click();
await createFolderFromTemplateDialog.cancelButton.click();
await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible();
});
});

test.describe('Folder created from template on Personal Files', () => {
test.beforeEach(async ({ personalFiles }) => {
randomFolderName = `aplaywright-folder-${Utils.random()}`;
randomFolderName = `playwright-folder-${Utils.random()}`;
randomFolderTitle = `folder-title-${Utils.random()}`;
randomFolderDescription = `folder-description-${Utils.random()}`;
createFolderFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
Expand Down Expand Up @@ -360,7 +358,7 @@ test.describe('Create folder from template', () => {
});

test.describe('Folder created from template on Personal Files Libraries', () => {
const randomLibraryName = `aplaywright-library-${Utils.random()}`;
const randomLibraryName = `playwright-library-${Utils.random()}`;

test.beforeAll(async ({ sitesApiAction, nodesApiAction }) => {
await sitesApiAction.createSite(randomLibraryName);
Expand All @@ -369,7 +367,7 @@ test.describe('Create folder from template', () => {
});

test.beforeEach(async ({ myLibrariesPage }) => {
randomFolderName = `aplaywright-folder-${Utils.random()}`;
randomFolderName = `playwright-folder-${Utils.random()}`;
randomFolderTitle = `folder-title-${Utils.random()}`;
randomFolderDescription = `folder-description-${Utils.random()}`;
await myLibrariesPage.navigate();
Expand All @@ -380,7 +378,7 @@ test.describe('Create folder from template', () => {
await dataTable.goThroughPagesLookingForRowWithName(randomLibraryName);
await dataTable.getRowByName(randomLibraryName).dblclick();
await dataTable.spinnerWaitForReload();
await toolbar.selectCreateFolderFromTemplate();
await toolbar.clickCreateFolderFromTemplate();
await dataTable.getRowByName(templateFolder1).click();
await selectFolderTemplateDialog.actionButton.click();
});
Expand All @@ -402,7 +400,7 @@ test.describe('Create folder from template', () => {

test('[C325162] Cancel folder creation in a library', async () => {
await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
await createFolderFromTemplateDialog.actionButton(cancelButton).click();
await createFolderFromTemplateDialog.cancelButton.click();
await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible();
await expect(dataTable.getRowByName(randomFolderName)).not.toBeVisible();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ <h2 mat-dialog-title [innerHTML]="title"></h2>
</form>
</div>
<div mat-dialog-actions>
<button mat-button mat-dialog-close>
<button mat-button mat-dialog-close data-automation-id="cancel-folder-template-button">
{{ 'NODE_FROM_TEMPLATE.CANCEL' | translate }}
</button>
<button
class="create"
[disabled]="form.invalid"
mat-button
(click)="onSubmit()"
data-automation-id="create-folder-template-button"
>
{{ 'NODE_FROM_TEMPLATE.CREATE' | translate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { MatMenuComponent } from '.';
import { BaseComponent } from './base.component';
import { Page } from '@playwright/test';
import { BaseComponent, MatMenuComponent } from './';
export class AcaHeader extends BaseComponent {
private static rootElement = 'aca-toolbar';
private moreActionsButton = this.getChild('button[id="app.viewer.toolbar.more"]');
Expand All @@ -46,7 +45,7 @@ export class AcaHeader extends BaseComponent {
await this.moreActionsButton.click();
}

async selectCreateFolderFromTemplate(): Promise<void> {
async clickCreateFolderFromTemplate(): Promise<void> {
await this.createButton.click();
await this.matMenu.createFolderFromTemplate.click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export abstract class BaseComponent extends PlaywrightBase {

async spinnerWaitForReload(): Promise<void> {
try {
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.normal });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.medium });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal });
} catch (e) {
this.logger.info('Spinner was not present');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class CreateFromTemplateDialogComponent extends BaseComponent {
super(page, CreateFromTemplateDialogComponent.rootElement);
}

public actionButton = (text: string) => this.getChild('.mat-button .mat-button-wrapper', { hasText: text });
cancelButton = this.getChild('[data-automation-id="cancel-folder-template-button"]');
createButton = this.getChild('[data-automation-id="create-folder-template-button"]');
getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text });
getDialogLabel = (text: string) => this.getChild('label', { hasText: text });
getErrorByText = (text: string): Locator => this.page.locator('mat-error', {hasText: text});
Expand All @@ -51,6 +52,6 @@ export class CreateFromTemplateDialogComponent extends BaseComponent {
await this.getDialogLabel('Name *').fill(nameInput);
if (titleInput) { await this.getDialogLabel('Title').fill(titleInput); }
if (descriptionInput) { await this.getDialogLabel('Description').fill(descriptionInput); }
await this.actionButton('Create').click();
await this.createButton.click();
}
}

0 comments on commit ff9d522

Please sign in to comment.