Playwright POM (#8109)

Related to #6641
This commit is contained in:
BOHEUS
2024-11-07 14:38:28 +00:00
committed by GitHub
parent c3343d3600
commit c571c9bdca
25 changed files with 2197 additions and 3 deletions

View File

@ -0,0 +1,54 @@
import { Locator, Page } from '@playwright/test';
export class AccountsSection {
private readonly addAccountButton: Locator;
private readonly deleteAccountButton: Locator;
private readonly addBlocklistField: Locator;
private readonly addBlocklistButton: Locator;
private readonly connectWithGoogleButton: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.addAccountButton = page.getByRole('button', { name: 'Add account' });
this.deleteAccountButton = page
.getByTestId('tooltip')
.getByText('Remove account');
this.addBlocklistField = page.getByPlaceholder(
'eddy@gmail.com, @apple.com',
);
this.addBlocklistButton = page.getByRole('button', {
name: 'Add to blocklist',
});
this.connectWithGoogleButton = page.getByRole('button', {
name: 'Connect with Google',
});
}
async clickAddAccount() {
await this.addAccountButton.click();
}
async deleteAccount(email: string) {
await this.page
.locator(`//span[contains(., "${email}")]/../div/div/div/button`)
.click();
await this.deleteAccountButton.click();
}
async addToBlockList(domain: string) {
await this.addBlocklistField.fill(domain);
await this.addBlocklistButton.click();
}
async removeFromBlocklist(domain: string) {
await this.page
.locator(
`//div[@data-testid='tooltip' and contains(., '${domain}')]/../../div[last()]/button`,
)
.click();
}
async linkGoogleAccount() {
await this.connectWithGoogleButton.click();
}
}

View File

@ -0,0 +1,30 @@
import { Locator, Page } from '@playwright/test';
export class CalendarSection {
private readonly eventVisibilityEverythingOption: Locator;
private readonly eventVisibilityMetadataOption: Locator;
private readonly contactAutoCreation: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.eventVisibilityEverythingOption = page.locator(
'input[value="SHARE_EVERYTHING"]',
);
this.eventVisibilityMetadataOption = page.locator(
'input[value="METADATA"]',
);
this.contactAutoCreation = page.getByRole('checkbox').nth(1);
}
async changeVisibilityToEverything() {
await this.eventVisibilityEverythingOption.click();
}
async changeVisibilityToMetadata() {
await this.eventVisibilityMetadataOption.click();
}
async toggleAutoCreation() {
await this.contactAutoCreation.click();
}
}

View File

@ -0,0 +1,189 @@
import { Locator, Page } from '@playwright/test';
export class DataModelSection {
private readonly searchObjectInput: Locator;
private readonly addObjectButton: Locator;
private readonly objectSingularNameInput: Locator;
private readonly objectPluralNameInput: Locator;
private readonly objectDescription: Locator;
private readonly synchronizeLabelAPIToggle: Locator;
private readonly objectAPISingularNameInput: Locator;
private readonly objectAPIPluralNameInput: Locator;
private readonly objectMoreOptionsButton: Locator;
private readonly editObjectButton: Locator;
private readonly deleteObjectButton: Locator;
private readonly activeSection: Locator;
private readonly inactiveSection: Locator;
private readonly searchFieldInput: Locator;
private readonly addFieldButton: Locator;
private readonly viewFieldDetailsMoreOptionsButton: Locator;
private readonly nameFieldInput: Locator;
private readonly descriptionFieldInput: Locator;
private readonly deactivateMoreOptionsButton: Locator;
private readonly activateMoreOptionsButton: Locator;
private readonly deactivateButton: Locator; // TODO: add attribute to make it one button
private readonly activateButton: Locator;
private readonly cancelButton: Locator;
private readonly saveButton: Locator;
constructor(public readonly page: Page) {
this.searchObjectInput = page.getByPlaceholder('Search an object...');
this.addObjectButton = page.getByRole('button', { name: 'Add object' });
this.objectSingularNameInput = page.getByPlaceholder('Listing', {
exact: true,
});
this.objectPluralNameInput = page.getByPlaceholder('Listings', {
exact: true,
});
this.objectDescription = page.getByPlaceholder('Write a description');
this.synchronizeLabelAPIToggle = page.getByRole('checkbox').nth(1);
this.objectAPISingularNameInput = page.getByPlaceholder('listing', {
exact: true,
});
this.objectAPIPluralNameInput = page.getByPlaceholder('listings', {
exact: true,
});
this.objectMoreOptionsButton = page.getByLabel('Object Options');
this.editObjectButton = page.getByTestId('tooltip').getByText('Edit');
this.deactivateMoreOptionsButton = page
.getByTestId('tooltip')
.getByText('Deactivate');
this.activateMoreOptionsButton = page
.getByTestId('tooltip')
.getByText('Activate');
this.deleteObjectButton = page.getByTestId('tooltip').getByText('Delete');
this.activeSection = page.getByText('Active', { exact: true });
this.inactiveSection = page.getByText('Inactive');
this.searchFieldInput = page.getByPlaceholder('Search a field...');
this.addFieldButton = page.getByRole('button', { name: 'Add field' });
this.viewFieldDetailsMoreOptionsButton = page
.getByTestId('tooltip')
.getByText('View');
this.nameFieldInput = page.getByPlaceholder('Employees');
this.descriptionFieldInput = page.getByPlaceholder('Write a description');
this.deactivateButton = page.getByRole('button', { name: 'Deactivate' });
this.activateButton = page.getByRole('button', { name: 'Activate' });
this.cancelButton = page.getByRole('button', { name: 'Cancel' });
this.saveButton = page.getByRole('button', { name: 'Save' });
}
async searchObject(name: string) {
await this.searchObjectInput.fill(name);
}
async clickAddObjectButton() {
await this.addObjectButton.click();
}
async typeObjectSingularName(name: string) {
await this.objectSingularNameInput.fill(name);
}
async typeObjectPluralName(name: string) {
await this.objectPluralNameInput.fill(name);
}
async typeObjectDescription(name: string) {
await this.objectDescription.fill(name);
}
async toggleSynchronizeLabelAPI() {
await this.synchronizeLabelAPIToggle.click();
}
async typeObjectSingularAPIName(name: string) {
await this.objectAPISingularNameInput.fill(name);
}
async typeObjectPluralAPIName(name: string) {
await this.objectAPIPluralNameInput.fill(name);
}
async checkObjectDetails(name: string) {
await this.page.getByRole('link').filter({ hasText: name }).click();
}
async activateInactiveObject(name: string) {
await this.page
.locator(`//div[@title="${name}"]/../../div[last()]`)
.click();
await this.activateButton.click();
}
// object can be deleted only if is custom and inactive
async deleteInactiveObject(name: string) {
await this.page
.locator(`//div[@title="${name}"]/../../div[last()]`)
.click();
await this.deleteObjectButton.click();
}
async editObjectDetails() {
await this.objectMoreOptionsButton.click();
await this.editObjectButton.click();
}
async deactivateObjectWithMoreOptions() {
await this.objectMoreOptionsButton.click();
await this.deactivateButton.click();
}
async searchField(name: string) {
await this.searchFieldInput.fill(name);
}
async checkFieldDetails(name: string) {
await this.page.locator(`//div[@title="${name}"]`).click();
}
async checkFieldDetailsWithButton(name: string) {
await this.page
.locator(`//div[@title="${name}"]/../../div[last()]`)
.click();
await this.viewFieldDetailsMoreOptionsButton.click();
}
async deactivateFieldWithButton(name: string) {
await this.page
.locator(`//div[@title="${name}"]/../../div[last()]`)
.click();
await this.deactivateMoreOptionsButton.click();
}
async activateFieldWithButton(name: string) {
await this.page
.locator(`//div[@title="${name}"]/../../div[last()]`)
.click();
await this.activateMoreOptionsButton.click();
}
async clickAddFieldButton() {
await this.addFieldButton.click();
}
async typeFieldName(name: string) {
await this.nameFieldInput.clear();
await this.nameFieldInput.fill(name);
}
async typeFieldDescription(description: string) {
await this.descriptionFieldInput.clear();
await this.descriptionFieldInput.fill(description);
}
async clickInactiveSection() {
await this.inactiveSection.click();
}
async clickActiveSection() {
await this.activeSection.click();
}
async clickCancelButton() {
await this.cancelButton.click();
}
async clickSaveButton() {
await this.saveButton.click();
}
}

View File

@ -0,0 +1,123 @@
import { Locator, Page } from '@playwright/test';
export class DevelopersSection {
private readonly readDocumentationButton: Locator;
private readonly createAPIKeyButton: Locator;
private readonly regenerateAPIKeyButton: Locator;
private readonly nameOfAPIKeyInput: Locator;
private readonly expirationDateAPIKeySelect: Locator;
private readonly createWebhookButton: Locator;
private readonly webhookURLInput: Locator;
private readonly webhookDescription: Locator;
private readonly webhookFilterObjectSelect: Locator;
private readonly webhookFilterActionSelect: Locator;
private readonly cancelButton: Locator;
private readonly saveButton: Locator;
private readonly deleteButton: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.readDocumentationButton = page.getByRole('link', {
name: 'Read documentation',
});
this.createAPIKeyButton = page.getByRole('link', {
name: 'Create API Key',
});
this.createWebhookButton = page.getByRole('link', {
name: 'Create Webhook',
});
this.nameOfAPIKeyInput = page
.getByPlaceholder('E.g. backoffice integration')
.first();
this.expirationDateAPIKeySelect = page
.locator('div')
.filter({ hasText: /^Never$/ })
.nth(3); // good enough if expiration date will change only 1 time
this.regenerateAPIKeyButton = page.getByRole('button', {
name: 'Regenerate Key',
});
this.webhookURLInput = page.getByPlaceholder('URL');
this.webhookDescription = page.getByPlaceholder('Write a description');
this.webhookFilterObjectSelect = page
.locator('div')
.filter({ hasText: /^All Objects$/ })
.nth(3); // works only for first filter
this.webhookFilterActionSelect = page
.locator('div')
.filter({ hasText: /^All Actions$/ })
.nth(3); // works only for first filter
this.cancelButton = page.getByRole('button', { name: 'Cancel' });
this.saveButton = page.getByRole('button', { name: 'Save' });
this.deleteButton = page.getByRole('button', { name: 'Delete' });
}
async openDocumentation() {
await this.readDocumentationButton.click();
}
async createAPIKey() {
await this.createAPIKeyButton.click();
}
async typeAPIKeyName(name: string) {
await this.nameOfAPIKeyInput.clear();
await this.nameOfAPIKeyInput.fill(name);
}
async selectAPIExpirationDate(date: string) {
await this.expirationDateAPIKeySelect.click();
await this.page.getByText(date, { exact: true }).click();
}
async regenerateAPIKey() {
await this.regenerateAPIKeyButton.click();
}
async deleteAPIKey() {
await this.deleteButton.click();
}
async deleteWebhook() {
await this.deleteButton.click();
}
async createWebhook() {
await this.createWebhookButton.click();
}
async typeWebhookURL(url: string) {
await this.webhookURLInput.fill(url);
}
async typeWebhookDescription(description: string) {
await this.webhookDescription.fill(description);
}
async selectWebhookObject(object: string) {
// TODO: finish
}
async selectWebhookAction(action: string) {
// TODO: finish
}
async deleteWebhookFilter() {
// TODO: finish
}
async clickCancelButton() {
await this.cancelButton.click();
}
async clickSaveButton() {
await this.saveButton.click();
}
async checkAPIKeyDetails(name: string) {
await this.page.locator(`//a/div[contains(.,'${name}')][first()]`).click();
}
async checkWebhookDetails(name: string) {
await this.page.locator(`//a/div[contains(.,'${name}')][first()]`).click();
}
}

View File

@ -0,0 +1,61 @@
import { Locator, Page } from '@playwright/test';
export class EmailsSection {
private readonly visibilityEverythingRadio: Locator;
private readonly visibilitySubjectRadio: Locator;
private readonly visibilityMetadataRadio: Locator;
private readonly autoCreationReceivedRadio: Locator;
private readonly autoCreationSentRadio: Locator;
private readonly autoCreationNoneRadio: Locator;
private readonly excludeNonProfessionalToggle: Locator;
private readonly excludeGroupToggle: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.visibilityEverythingRadio = page.locator(
'input[value="SHARE_EVERYTHING"]',
);
this.visibilitySubjectRadio = page.locator('input[value="SUBJECT"]');
this.visibilityMetadataRadio = page.locator('input[value="METADATA"]');
this.autoCreationReceivedRadio = page.locator(
'input[value="SENT_AND_RECEIVED"]',
);
this.autoCreationSentRadio = page.locator('input[value="SENT"]');
this.autoCreationNoneRadio = page.locator('input[value="NONE"]');
// first checkbox is advanced settings toggle
this.excludeNonProfessionalToggle = page.getByRole('checkbox').nth(1);
this.excludeGroupToggle = page.getByRole('checkbox').nth(2);
}
async changeVisibilityToEverything() {
await this.visibilityEverythingRadio.click();
}
async changeVisibilityToSubject() {
await this.visibilitySubjectRadio.click();
}
async changeVisibilityToMetadata() {
await this.visibilityMetadataRadio.click();
}
async changeAutoCreationToAll() {
await this.autoCreationReceivedRadio.click();
}
async changeAutoCreationToSent() {
await this.autoCreationSentRadio.click();
}
async changeAutoCreationToNone() {
await this.autoCreationNoneRadio.click();
}
async toggleExcludeNonProfessional() {
await this.excludeNonProfessionalToggle.click();
}
async toggleExcludeGroup() {
await this.excludeGroupToggle.click();
}
}

View File

@ -0,0 +1,55 @@
import { Locator, Page } from '@playwright/test';
export class ExperienceSection {
private readonly lightThemeButton: Locator;
private readonly darkThemeButton: Locator;
private readonly timezoneDropdown: Locator;
private readonly dateFormatDropdown: Locator;
private readonly timeFormatDropdown: Locator;
private readonly searchInput: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.lightThemeButton = page.getByText('AaLight'); // it works
this.darkThemeButton = page.getByText('AaDark');
this.timezoneDropdown = page.locator(
'//span[contains(., "Time zone")]/../div/div/div',
);
this.dateFormatDropdown = page.locator(
'//span[contains(., "Date format")]/../div/div/div',
);
this.timeFormatDropdown = page.locator(
'//span[contains(., "Time format")]/../div/div/div',
);
this.searchInput = page.getByPlaceholder('Search');
}
async changeThemeToLight() {
await this.lightThemeButton.click();
}
async changeThemeToDark() {
await this.darkThemeButton.click();
}
async selectTimeZone(timezone: string) {
await this.timezoneDropdown.click();
await this.page.getByText(timezone, { exact: true }).click();
}
async selectTimeZoneWithSearch(timezone: string) {
await this.timezoneDropdown.click();
await this.searchInput.fill(timezone);
await this.page.getByText(timezone, { exact: true }).click();
}
async selectDateFormat(dateFormat: string) {
await this.dateFormatDropdown.click();
await this.page.getByText(dateFormat, { exact: true }).click();
}
async selectTimeFormat(timeFormat: string) {
await this.timeFormatDropdown.click();
await this.page.getByText(timeFormat, { exact: true }).click();
}
}

View File

@ -0,0 +1,159 @@
import { Locator, Page } from '@playwright/test';
export class FunctionsSection {
private readonly newFunctionButton: Locator;
private readonly functionNameInput: Locator;
private readonly functionDescriptionInput: Locator;
private readonly editorTab: Locator;
private readonly codeEditorField: Locator;
private readonly resetButton: Locator;
private readonly publishButton: Locator;
private readonly testButton: Locator;
private readonly testTab: Locator;
private readonly runFunctionButton: Locator;
private readonly inputField: Locator;
private readonly settingsTab: Locator;
private readonly searchVariableInput: Locator;
private readonly addVariableButton: Locator;
private readonly nameVariableInput: Locator;
private readonly valueVariableInput: Locator;
private readonly cancelVariableButton: Locator;
private readonly saveVariableButton: Locator;
private readonly editVariableButton: Locator;
private readonly deleteVariableButton: Locator;
private readonly cancelButton: Locator;
private readonly saveButton: Locator;
private readonly deleteButton: Locator;
constructor(public readonly page: Page) {
this.newFunctionButton = page.getByRole('button', { name: 'New Function' });
this.functionNameInput = page.getByPlaceholder('Name');
this.functionDescriptionInput = page.getByPlaceholder('Description');
this.editorTab = page.getByTestId('tab-editor');
this.codeEditorField = page.getByTestId('dummyInput'); // TODO: fix
this.resetButton = page.getByRole('button', { name: 'Reset' });
this.publishButton = page.getByRole('button', { name: 'Publish' });
this.testButton = page.getByRole('button', { name: 'Test' });
this.testTab = page.getByTestId('tab-test');
this.runFunctionButton = page.getByRole('button', { name: 'Run Function' });
this.inputField = page.getByTestId('dummyInput'); // TODO: fix
this.settingsTab = page.getByTestId('tab-settings');
this.searchVariableInput = page.getByPlaceholder('Search a variable');
this.addVariableButton = page.getByRole('button', { name: 'Add Variable' });
this.nameVariableInput = page.getByPlaceholder('Name').nth(1);
this.valueVariableInput = page.getByPlaceholder('Value');
this.cancelVariableButton = page.locator('.css-uwqduk').first(); // TODO: fix
this.saveVariableButton = page.locator('.css-uwqduk').nth(1); // TODO: fix
this.editVariableButton = page.getByText('Edit', { exact: true });
this.deleteVariableButton = page.getByText('Delete', { exact: true });
this.cancelButton = page.getByRole('button', { name: 'Cancel' });
this.saveButton = page.getByRole('button', { name: 'Save' });
this.deleteButton = page.getByRole('button', { name: 'Delete function' });
}
async clickNewFunction() {
await this.newFunctionButton.click();
}
async typeFunctionName(name: string) {
await this.functionNameInput.fill(name);
}
async typeFunctionDescription(description: string) {
await this.functionDescriptionInput.fill(description);
}
async checkFunctionDetails(name: string) {
await this.page.getByRole('link', { name: `${name} nodejs18.x` }).click();
}
async clickEditorTab() {
await this.editorTab.click();
}
async clickResetButton() {
await this.resetButton.click();
}
async clickPublishButton() {
await this.publishButton.click();
}
async clickTestButton() {
await this.testButton.click();
}
async typeFunctionCode() {
// TODO: finish once utils are merged
}
async clickTestTab() {
await this.testTab.click();
}
async runFunction() {
await this.runFunctionButton.click();
}
async typeFunctionInput() {
// TODO: finish once utils are merged
}
async clickSettingsTab() {
await this.settingsTab.click();
}
async searchVariable(name: string) {
await this.searchVariableInput.fill(name);
}
async addVariable() {
await this.addVariableButton.click();
}
async typeVariableName(name: string) {
await this.nameVariableInput.fill(name);
}
async typeVariableValue(value: string) {
await this.valueVariableInput.fill(value);
}
async editVariable(name: string) {
await this.page
.locator(
`//div[@data-testid='tooltip' and contains(., '${name}')]/../../div[last()]/div/div/button`,
)
.click();
await this.editVariableButton.click();
}
async deleteVariable(name: string) {
await this.page
.locator(
`//div[@data-testid='tooltip' and contains(., '${name}')]/../../div[last()]/div/div/button`,
)
.click();
await this.deleteVariableButton.click();
}
async cancelVariable() {
await this.cancelVariableButton.click();
}
async saveVariable() {
await this.saveVariableButton.click();
}
async clickCancelButton() {
await this.cancelButton.click();
}
async clickSaveButton() {
await this.saveButton.click();
}
async clickDeleteButton() {
await this.deleteButton.click();
}
}

View File

@ -0,0 +1,29 @@
import { Locator, Page } from '@playwright/test';
export class GeneralSection {
private readonly workspaceNameField: Locator;
private readonly supportSwitch: Locator;
private readonly deleteWorkspaceButton: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.workspaceNameField = page.getByPlaceholder('Apple');
this.supportSwitch = page.getByRole('checkbox').nth(1);
this.deleteWorkspaceButton = page.getByRole('button', {
name: 'Delete workspace',
});
}
async changeWorkspaceName(workspaceName: string) {
await this.workspaceNameField.clear();
await this.workspaceNameField.fill(workspaceName);
}
async changeSupportSwitchState() {
await this.supportSwitch.click();
}
async clickDeleteWorkSpaceButton() {
await this.deleteWorkspaceButton.click();
}
}

View File

@ -0,0 +1,48 @@
import { Locator, Page } from '@playwright/test';
export class MembersSection {
private readonly inviteMembersField: Locator;
private readonly inviteMembersButton: Locator;
private readonly inviteLinkButton: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.inviteMembersField = page.getByPlaceholder(
'tim@apple.com, jony.ive@apple',
);
this.inviteMembersButton = page.getByRole('button', { name: 'Invite' });
this.inviteLinkButton = page.getByRole('button', { name: 'Copy link' });
}
async copyInviteLink() {
await this.inviteLinkButton.click();
}
async sendInviteEmail(email: string) {
await this.inviteMembersField.click();
await this.inviteMembersField.fill(email);
await this.inviteMembersButton.click();
}
async deleteMember(email: string) {
await this.page
.locator(`//div[contains(., '${email}')]/../../div[last()]/div/button`)
.click();
}
async deleteInviteEmail(email: string) {
await this.page
.locator(
`//div[contains(., '${email}')]/../../div[last()]/div/button[first()]`,
)
.click();
}
async refreshInviteEmail(email: string) {
await this.page
.locator(
`//div[contains(., '${email}')]/../../div[last()]/div/button[last()]`,
)
.click();
}
}

View File

@ -0,0 +1,250 @@
import { Locator, Page } from '@playwright/test';
export class NewFieldSection {
private readonly searchTypeFieldInput: Locator;
private readonly currencyFieldLink: Locator;
private readonly currencyDefaultUnitSelect: Locator;
private readonly emailsFieldLink: Locator;
private readonly linksFieldLink: Locator;
private readonly phonesFieldLink: Locator;
private readonly addressFieldLink: Locator;
private readonly textFieldLink: Locator;
private readonly numberFieldLink: Locator;
private readonly decreaseDecimalsButton: Locator;
private readonly decimalsNumberInput: Locator;
private readonly increaseDecimalsButton: Locator;
private readonly booleanFieldLink: Locator;
private readonly defaultBooleanSelect: Locator;
private readonly dateTimeFieldLink: Locator;
private readonly dateFieldLink: Locator;
private readonly relativeDateToggle: Locator;
private readonly selectFieldLink: Locator;
private readonly multiSelectFieldLink: Locator;
private readonly setAsDefaultOptionButton: Locator;
private readonly removeOptionButton: Locator;
private readonly addOptionButton: Locator;
private readonly ratingFieldLink: Locator;
private readonly JSONFieldLink: Locator;
private readonly arrayFieldLink: Locator;
private readonly relationFieldLink: Locator;
private readonly relationTypeSelect: Locator;
private readonly objectDestinationSelect: Locator;
private readonly relationFieldNameInput: Locator;
private readonly fullNameFieldLink: Locator;
private readonly UUIDFieldLink: Locator;
private readonly nameFieldInput: Locator;
private readonly descriptionFieldInput: Locator;
constructor(public readonly page: Page) {
this.searchTypeFieldInput = page.getByPlaceholder('Search a type');
this.currencyFieldLink = page.getByRole('link', { name: 'Currency' });
this.currencyDefaultUnitSelect = page.locator(
"//span[contains(., 'Default Unit')]/../div",
);
this.emailsFieldLink = page.getByRole('link', { name: 'Emails' }).nth(1);
this.linksFieldLink = page.getByRole('link', { name: 'Links' });
this.phonesFieldLink = page.getByRole('link', { name: 'Phones' });
this.addressFieldLink = page.getByRole('link', { name: 'Address' });
this.textFieldLink = page.getByRole('link', { name: 'Text' });
this.numberFieldLink = page.getByRole('link', { name: 'Number' });
this.decreaseDecimalsButton = page.locator(
"//div[contains(., 'Number of decimals')]/../div[last()]/div/div/button[2]",
);
this.decimalsNumberInput = page.locator(
// would be better if first div was span tag
"//div[contains(., 'Number of decimals')]/../div[last()]/div/div/div/div/input[2]",
);
this.increaseDecimalsButton = page.locator(
"//div[contains(., 'Number of decimals')]/../div[last()]/div/div/button[3]",
);
this.booleanFieldLink = page.getByRole('link', { name: 'True/False' });
this.defaultBooleanSelect = page.locator(
"//span[contains(., 'Default Value')]/../div",
);
this.dateTimeFieldLink = page.getByRole('link', { name: 'Date and Time' });
this.dateFieldLink = page.getByRole('link', { name: 'Date' });
this.relativeDateToggle = page.getByRole('checkbox').nth(1);
this.selectFieldLink = page.getByRole('link', { name: 'Select' });
this.multiSelectFieldLink = page.getByRole('link', {
name: 'Multi-select',
});
this.setAsDefaultOptionButton = page
.getByTestId('tooltip')
.getByText('Set as default');
this.removeOptionButton = page
.getByTestId('tooltip')
.getByText('Remove option');
this.addOptionButton = page.getByRole('button', { name: 'Add option' });
this.ratingFieldLink = page.getByRole('link', { name: 'Rating' });
this.JSONFieldLink = page.getByRole('link', { name: 'JSON' });
this.arrayFieldLink = page.getByRole('link', { name: 'Array' });
this.relationFieldLink = page.getByRole('link', { name: 'Relation' });
this.relationTypeSelect = page.locator(
"//span[contains(., 'Relation type')]/../div",
);
this.objectDestinationSelect = page.locator(
"//span[contains(., 'Object destination')]/../div",
);
this.relationIconSelect = page.getByLabel('Click to select icon (').nth(1);
this.relationFieldNameInput = page.getByPlaceholder('Field name');
this.fullNameFieldLink = page.getByRole('link', { name: 'Full Name' });
this.UUIDFieldLink = page.getByRole('link', { name: 'Unique ID' });
this.nameFieldInput = page.getByPlaceholder('Employees');
this.descriptionFieldInput = page.getByPlaceholder('Write a description');
}
async searchTypeField(name: string) {
await this.searchTypeFieldInput.fill(name);
}
async clickCurrencyType() {
await this.currencyFieldLink.click();
}
async selectDefaultUnit(name: string) {
await this.currencyDefaultUnitSelect.click();
await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
}
async clickEmailsType() {
await this.emailsFieldLink.click();
}
async clickLinksType() {
await this.linksFieldLink.click();
}
async clickPhonesType() {
await this.phonesFieldLink.click();
}
async clickAddressType() {
await this.addressFieldLink.click();
}
async clickTextType() {
await this.textFieldLink.click();
}
async clickNumberType() {
await this.numberFieldLink.click();
}
async decreaseDecimals() {
await this.decreaseDecimalsButton.click();
}
async typeNumberOfDecimals(amount: number) {
await this.decimalsNumberInput.fill(String(amount));
}
async increaseDecimals() {
await this.increaseDecimalsButton.click();
}
async clickBooleanType() {
await this.booleanFieldLink.click();
}
// either True of False
async selectDefaultBooleanValue(value: string) {
await this.defaultBooleanSelect.click();
await this.page.getByTestId('tooltip').filter({ hasText: value }).click();
}
async clickDateTimeType() {
await this.dateTimeFieldLink.click();
}
async clickDateType() {
await this.dateFieldLink.click();
}
async toggleRelativeDate() {
await this.relativeDateToggle.click();
}
async clickSelectType() {
await this.selectFieldLink.click();
}
async clickMultiSelectType() {
await this.multiSelectFieldLink.click();
}
async addSelectOption() {
await this.addOptionButton.click();
}
async setOptionAsDefault() {
// TODO: finish
await this.setAsDefaultOptionButton.click();
}
async deleteSelectOption() {
// TODO: finish
await this.removeOptionButton.click();
}
async changeOptionAPIName() {
// TODO: finish
}
async changeOptionColor() {
// TODO: finish
}
async changeOptionName() {
// TODO: finish
}
async clickRatingType() {
await this.ratingFieldLink.click();
}
async clickJSONType() {
await this.JSONFieldLink.click();
}
async clickArrayType() {
await this.arrayFieldLink.click();
}
async clickRelationType() {
await this.relationFieldLink.click();
}
// either 'Has many' or 'Belongs to one'
async selectRelationType(name: string) {
await this.relationTypeSelect.click();
await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
}
async selectObjectDestination(name: string) {
await this.objectDestinationSelect.click();
await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
}
async typeRelationName(name: string) {
await this.relationFieldNameInput.clear();
await this.relationFieldNameInput.fill(name);
}
async clickFullNameType() {
await this.fullNameFieldLink.click();
}
async clickUUIDType() {
await this.UUIDFieldLink.click();
}
async typeFieldName(name: string) {
await this.nameFieldInput.clear();
await this.nameFieldInput.fill(name);
}
async typeFieldDescription(description: string) {
await this.descriptionFieldInput.clear();
await this.descriptionFieldInput.fill(description);
}
}

View File

@ -0,0 +1,44 @@
import { Locator, Page } from '@playwright/test';
export class ProfileSection {
private readonly firstNameField: Locator;
private readonly lastNameField: Locator;
private readonly emailField: Locator;
private readonly changePasswordButton: Locator;
private readonly deleteAccountButton: Locator;
constructor(public readonly page: Page) {
this.page = page;
this.firstNameField = page.getByPlaceholder('Tim');
this.lastNameField = page.getByPlaceholder('Cook');
this.emailField = page.getByRole('textbox').nth(2);
this.changePasswordButton = page.getByRole('button', {
name: 'Change Password',
});
this.deleteAccountButton = page.getByRole('button', {
name: 'Delete account',
});
}
async changeFirstName(firstName: string) {
await this.firstNameField.clear();
await this.firstNameField.fill(firstName);
}
async changeLastName(lastName: string) {
await this.lastNameField.clear();
await this.lastNameField.fill(lastName);
}
async getEmail() {
await this.emailField.textContent();
}
async sendChangePasswordEmail() {
await this.changePasswordButton.click();
}
async deleteAccount() {
await this.deleteAccountButton.click();
}
}

View File

@ -0,0 +1,13 @@
import { Locator, Page } from '@playwright/test';
export class SecuritySection {
private readonly inviteByLinkToggle: Locator;
constructor(public readonly page: Page) {
this.inviteByLinkToggle = page.locator('input[type="checkbox"]').nth(1);
}
async toggleInviteByLink() {
await this.inviteByLinkToggle.click();
}
}