Skip to content

Commit

Permalink
[ACS-6456] fixed code smells and removed duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
SheenaMalhotra182 committed Dec 18, 2023
1 parent a58075f commit e4a2806
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion projects/aca-playwright-shared/src/api/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class NodesApi {
async getNodeProperty(nodeId: string, property: string): Promise<string> {
try {
const node = await this.getNodeById(nodeId);
return (node.entry.properties && node.entry.properties[property]) || '';
return node.entry.properties?.[property] || '';
} catch (error) {
console.error(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import { Locator, Page } from '@playwright/test';
import { ElementHandle, Locator, Page } from '@playwright/test';
import { BaseComponent } from '../base.component';
import { timeouts } from '../../../utils';
import { DateTimePicker } from '../datetime-picker/datetime-picker.component';
Expand Down Expand Up @@ -85,19 +85,24 @@ export class ShareDialogComponent extends BaseComponent {
await this.closeButton.click();
}

async isToggleStatus(toggle: ElementHandle, status: string): Promise<boolean> {
const toggleClass = await toggle.getAttribute('class');
return toggleClass.includes(status);
}

async isShareToggleChecked(): Promise<boolean> {
const toggleClass = await this.shareToggle.getAttribute('class');
return toggleClass.includes('checked');
const shareToggleElement = await this.shareToggle.elementHandle();
return this.isToggleStatus(shareToggleElement, 'checked');
}

async isShareToggleDisabled(): Promise<boolean> {
const toggleClass = await this.shareToggle.getAttribute('class');
return toggleClass.includes('mat-disabled');
const shareToggleElement = await this.shareToggle.elementHandle();
return this.isToggleStatus(shareToggleElement, 'mat-disabled');
}

async isExpireToggleEnabled(): Promise<boolean> {
const toggleClass = await this.expireToggle.getAttribute('class');
return toggleClass.includes('checked');
const expireToggleElement = await this.expireToggle.elementHandle();
return this.isToggleStatus(expireToggleElement, 'checked');
}

async getExpireDate(): Promise<string> {
Expand Down

0 comments on commit e4a2806

Please sign in to comment.