Skip to content

Commit

Permalink
fix: move the validation to the page class
Browse files Browse the repository at this point in the history
  • Loading branch information
mortadarefd committed Oct 20, 2023
1 parent f900da4 commit e9ab59d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 11 additions & 6 deletions packages/e2e-tests/pages/ExecutorGeneralSettingsPage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Page} from '@playwright/test';
import {type Page, expect} from '@playwright/test';

export class ExecutorGeneralSettingsPage {
public readonly page: Page;
Expand All @@ -7,12 +7,17 @@ export class ExecutorGeneralSettingsPage {
this.page = page;
}

public async getExecutorName(): Promise<string | null> {
return this.page.locator('input[id="general-settings-name-type_name"]').inputValue();
}
public async validateExecutorGeneralSettings(executorName: string, executorType: string): Promise<void> {
const executorNameLocator = this.page.locator(
`//input[@id="general-settings-name-type_name" and @value="${executorName}"]`
);

expect(executorNameLocator.isVisible()).toBeTruthy();

public async getExecutorType(): Promise<string | null> {
return this.page.locator('input[id="general-settings-name-type_type"]').inputValue();
const executorTypeLocator = this.page.locator(
`//input[@id="general-settings-name-type_type" and @value="${executorType}"]`
);
expect(executorTypeLocator.isVisible()).toBeTruthy();
}

public async deleteExecutor(executorName: string): Promise<void> {
Expand Down
6 changes: 1 addition & 5 deletions packages/e2e-tests/tests/executors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ test(`Custom container executor - general settings`, async ({page}) => {
await executorsPage.openExecutorSettings(realExecutorName);

const executorGeneralSettingsPage = new ExecutorGeneralSettingsPage(page);
const executorNameInput = await executorGeneralSettingsPage.getExecutorName();

expect(executorNameInput).toBe(executorData.name);

const executorTypeInput = await executorGeneralSettingsPage.getExecutorType();
expect(executorTypeInput).not.toBeNull();
await executorGeneralSettingsPage.validateExecutorGeneralSettings(executorData.name, executorData.types[0]);

// Cleanup
await api.removeExecutor(realExecutorName);
Expand Down

0 comments on commit e9ab59d

Please sign in to comment.