Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/text reporter #85

Merged
merged 7 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const config: PlaywrightTestConfig = {
reporter: [
['html'],
['junit', { outputFile: 'results.xml' }],
// ['../src/reporter/text-reporter.ts', { outputFile: 'results.txt' }],
['../src/reporter/text', { outputFile: 'results.txt' }],
],
/* reporter: process.env.CI ? 'dot' : 'list', */

Expand Down
30 changes: 19 additions & 11 deletions __tests__/web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const test = base.extend<MyActors>({
// TODO: implement test for DoubleClick
// TODO: test different details between Fill and Type
test.describe('Testing screenplay-playwright-js web module', () => {
test.skip('Navigate', async ({ actor }) => {
test('Navigate', async ({ actor }) => {
await test.step('Navigate to playwright page', async () => {
await actor.attemptsTo(
Navigate.to('https://google.de'),
Expand Down Expand Up @@ -332,34 +332,42 @@ test.describe('Testing screenplay-playwright-js web module', () => {
});

test('Element.enabled', async ({ actor }) => {
// const ENABLED_ELEMENT = '[aria-label="Undo"]';
// const DISABLED_ELEMENT = '[aria-label="Redo"]';
// const URL = 'https://the-internet.herokuapp.com/tinymce';
// or
const ENABLED_ELEMENT = '#checkbox input[type="checkbox"]';
const DISABLED_ELEMENT = '#input-example input[type="text"]';
const URL = 'https://the-internet.herokuapp.com/dynamic_controls';

await actor.attemptsTo(
Navigate.to('https://the-internet.herokuapp.com/tinymce'),
Navigate.to(URL),
Wait.forLoadState('networkidle'),
Click.on('[aria-label="Bold"]'),
// Click.on('[aria-label="Bold"]'),
);

expect(await actor.asks(
Element.toBe.enabled('[aria-label="Undo"]'),
Element.toBe.enabled(ENABLED_ELEMENT),
)).toBe(true);

let enabledRes = false;
try {
expect(await actor.asks(
Element.toBe.enabled('[aria-label="Redo"]', { timeout: 1000 }),
Element.toBe.enabled(DISABLED_ELEMENT, { timeout: 1000 }),
)).toBe(true);
} catch (error) {
enabledRes = true;
}
expect(enabledRes).toBeTruthy();

expect(await actor.asks(
Element.notToBe.enabled('[aria-label="Redo"]'),
Element.notToBe.enabled(DISABLED_ELEMENT),
)).toBe(true);

let notEnabledRes = false;
try {
expect(await actor.asks(
Element.notToBe.enabled('[aria-label="Undo"]', { timeout: 1000 }),
Element.notToBe.enabled(ENABLED_ELEMENT, { timeout: 1000 }),
)).toBe(true);
} catch (error) {
notEnabledRes = true;
Expand Down Expand Up @@ -551,11 +559,11 @@ test.describe('Testing screenplay-playwright-js web module', () => {

// the download page contents change a lot
// thus keeping a few options in place
const DOWNLOAD_FILENAME = 'Hi.txt';
const DOWNLOAD_FILECONTENT = '';
// const DOWNLOAD_FILENAME = 'Hi.txt';
// const DOWNLOAD_FILECONTENT = '';
// or
// const DOWNLOAD_FILENAME = 'test-file.txt';
// const DOWNLOAD_FILECONTENT = 'Test file';
const DOWNLOAD_FILENAME = 'test-file.txt';
const DOWNLOAD_FILECONTENT = 'Test file';
// or
// const DOWNLOAD_FILENAME = 'newFile.txt';
// const DOWNLOAD_FILECONTENT = 'First file ';
Expand Down
20 changes: 14 additions & 6 deletions __tests__/web_playwright_locators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,36 +332,44 @@ test.describe('Testing screenplay-playwright-js web module', () => {
});

test('Element.enabled', async ({ actor }) => {
// const ENABLED_ELEMENT = '[aria-label="Undo"]';
// const DISABLED_ELEMENT = '[aria-label="Redo"]';
// const URL = 'https://the-internet.herokuapp.com/tinymce';
// or
const ENABLED_ELEMENT = '#checkbox input[type="checkbox"]';
const DISABLED_ELEMENT = '#input-example input[type="text"]';
const URL = 'https://the-internet.herokuapp.com/dynamic_controls';

const page: Page = BrowseTheWeb.as(actor).getPage();

await actor.attemptsTo(
Navigate.to('https://the-internet.herokuapp.com/tinymce'),
Navigate.to(URL),
Wait.forLoadState('networkidle'),
Click.on('[aria-label="Bold"]'),
// Click.on('[aria-label="Bold"]'),
);

expect(await actor.asks(
Element.toBe.enabled(page.locator('[aria-label="Undo"]')),
Element.toBe.enabled(page.locator(ENABLED_ELEMENT)),
)).toBe(true);

let enabledRes = false;
try {
expect(await actor.asks(
Element.toBe.enabled(page.locator('[aria-label="Redo"]'), { timeout: 1000 }),
Element.toBe.enabled(page.locator(DISABLED_ELEMENT), { timeout: 1000 }),
)).toBe(true);
} catch (error) {
enabledRes = true;
}
expect(enabledRes).toBeTruthy();

expect(await actor.asks(
Element.notToBe.enabled(page.locator('[aria-label="Redo"]')),
Element.notToBe.enabled(page.locator(DISABLED_ELEMENT)),
)).toBe(true);

let notEnabledRes = false;
try {
expect(await actor.asks(
Element.notToBe.enabled(page.locator('[aria-label="Undo"]'), { timeout: 1000 }),
Element.notToBe.enabled(page.locator(ENABLED_ELEMENT), { timeout: 1000 }),
)).toBe(true);
} catch (error) {
notEnabledRes = true;
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
- [Frame(s)](./frame_handling/frame_handling.md) - Handling frames
- **Logging**
- [Logging](./logging/logging.md) - How to enable debug logs
- **Reporter**
- [Logging](./reporter/text.md) - Screenplay report in text format

[Back to overview](../../README.md)
9 changes: 9 additions & 0 deletions docs/guides/logging/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Testla comes with logging which helps you to debug your test code. When logging
DEBUG=testla:sp
```

In addition it is possible to print structured logs to stdout. This can be achieved as follows.

```typescript
import { STRUCTURED_LOGS_ENVVAR_NAME } from '@testla/screenplay'

// activating structured logs to stdout
process.env[STRUCTURED_LOGS_ENVVAR_NAME] = 'true';
```

To understand how to enable logging in custom Actions and Questions please refer to the [logging guide](https://github.com/testla-project/testla-screenplay-core-js/blob/main/doc/logging.md) of Testla Screenplay Core.

[Back to overview](../guides.md)
25 changes: 25 additions & 0 deletions docs/guides/reporter/text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Back to overview](../guides.md)

# Text Reporter

> Introduced in: 1.7.0
>
> This feature is currently in experimental stage and might see bigger changes.

Testla comes with a text reporter which logs all activities in a file and gives insights about the overall test execution result.

To activate the reporter announce it in your `playwright.config.ts` as follows.

```typescript
reporter: [
[
// the reporter from testla
'@testla/screenplay-playwright/reporter/text',
// optional: the path to the output file, defaults to: screenplay-report.txt
{ outputFile: 'results.txt' },
],
// other reporters
],
```

[Back to overview](../guides.md)
16 changes: 9 additions & 7 deletions docs/screenplay_elements/Web/Actions/fill.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The `Fill` class is an action class in the Screenplay pattern designed for use w

### Methods

### performAs
#### performAs

```typescript
public async performAs(actor: Actor): Promise<void>;
Expand All @@ -31,20 +31,22 @@ public async performAs(actor: Actor): Promise<void>;
- `actor` - The actor performing this action.
- **Returns:** `Promise<void>` - Returns a promise that resolves after filling the specified element.

### in
#### in

```typescript
public static in(selector: Selector, input: string, options?: SelectorOptions): Fill;
public static in(selector: Selector, input: string, options?: SelectorOptions & Maskable): Fill;
```

- **Description:** Creates a new instance of the `Fill` class specifically for filling the specified element with the specified input.
- **Parameters:**
- `selector` - The selector of the element to be filled.
- `input` - The input string to fill the element with.
- `options` (optional) - Advanced selector lookup options.
- `options` (optional) - Advanced selector lookup and masking options.
- **Returns:** `Fill` - Returns a new `Fill` instance.

### inFrame
*As of 1.7.0 input values can be masked in the logs via the option `{ maskInLogs: true }` which is suggested for handling passwords or other clasified information in tests.*

#### inFrame

```typescript
public inFrame(frameSelector: FrameSelector): Fill;
Expand All @@ -55,7 +57,7 @@ public inFrame(frameSelector: FrameSelector): Fill;
- `frameSelector` - The FrameSelector.
- **Returns:** `Fill` - Returns the current action.

### withAbilityAlias
#### withAbilityAlias

```typescript
public withAbilityAlias(alias: string): Fill;
Expand All @@ -66,7 +68,7 @@ public withAbilityAlias(alias: string): Fill;
- `alias` - The alias.
- **Returns:** `Fill` - Returns the current action.

### orSkipOnFail
#### orSkipOnFail

*Introduced in: 1.6.0*

Expand Down
18 changes: 10 additions & 8 deletions docs/screenplay_elements/Web/Actions/press.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The `Press` class is an action class in the Screenplay pattern designed for use

### Methods

### performAs
#### performAs

```typescript
public async performAs(actor: Actor): Promise<void>;
Expand All @@ -32,7 +32,7 @@ public async performAs(actor: Actor): Promise<void>;
- `actor` - The actor performing this action.
- **Returns:** `Promise<void>` - Returns when the key(s) are pressed.

### key
#### key

```typescript
public static key(keys: string): Press;
Expand All @@ -43,20 +43,22 @@ public static key(keys: string): Press;
- `keys` - The key(s) to press. Multiple keys can be pressed by concatenating with "+" (e.g., Shift+A).
- **Returns:** `Press` - Returns a new `Press` instance.

### pressSequentially
#### sequentially

```typescript
public static pressSequentially(selector: Selector, input: string, options?: SelectorOptions): Press;
public static sequentially(selector: Selector, input: string, options?: SelectorOptions & Maskable): Press;
```

- **Description:** Creates a new instance of the `Press` class types the given input into the element specified by the selector.
- **Parameters:**
- `selector` - The selector of the source element.
- `input` - The input to type into the element.
- `options` - (optional) Advanced selector lookup options.
- `options` - (optional) Advanced selector lookup and masking options.
- **Returns:** `Promise<void>` - Returns when the key(s) have been pressed.

### inFrame
*As of 1.7.0 input values can be masked in the logs via the option `{ maskInLogs: true }` which is suggested for handling passwords or other clasified information in tests.*

#### inFrame

```typescript
public inFrame(frameSelector: FrameSelector): Press;
Expand All @@ -67,7 +69,7 @@ public inFrame(frameSelector: FrameSelector): Press;
- `frameSelector` - The FrameSelector.
- **Returns:** `Press` - Returns the current action.

### withAbilityAlias
#### withAbilityAlias

```typescript
public withAbilityAlias(alias: string): Press;
Expand All @@ -78,7 +80,7 @@ public withAbilityAlias(alias: string): Press;
- `alias` - The alias.
- **Returns:** `Press` - Returns the current action.

### orSkipOnFail
#### orSkipOnFail

*Introduced in: 1.6.0*

Expand Down
16 changes: 9 additions & 7 deletions docs/screenplay_elements/Web/Actions/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The `Type` class is an action class in the Screenplay pattern designed for use w

### Methods

### performAs
#### performAs

```typescript
public async performAs(actor: Actor): Promise<void>;
Expand All @@ -31,20 +31,22 @@ public async performAs(actor: Actor): Promise<void>;
- `actor` - The actor performing this action.
- **Returns:** `Promise<void>` - Resolves when the action is complete.

### in
#### in

```typescript
public static in(selector: Selector, input: string, options?: SelectorOptions): Type;
public static in(selector: Selector, input: string, options?: SelectorOptions & Maskable): Type;
```

- **Description:** Creates a new instance of the `Type` class for typing specified input into an element specified by a selector string.
- **Parameters:**
- `selector` - The selector.
- `input` - The input string to type into the element.
- `options` - (optional) Advanced selector lookup options.
- `options` - (optional) Advanced selector lookup ans masking options.
- **Returns:** `Type` - Returns a new `Type` instance.

### inFrame
*As of 1.7.0 input values can be masked in the logs via the option `{ maskInLogs: true }` which is suggested for handling passwords or other clasified information in tests.*

#### inFrame

```typescript
public inFrame(frameSelector: FrameSelector): Type;
Expand All @@ -55,7 +57,7 @@ public inFrame(frameSelector: FrameSelector): Type;
- `frameSelector` - The FrameSelector.
- **Returns:** `Type` - Returns the current action.

### withAbilityAlias
#### withAbilityAlias

```typescript
public withAbilityAlias(alias: string): Type;
Expand All @@ -66,7 +68,7 @@ public withAbilityAlias(alias: string): Type;
- `alias` - The alias.
- **Returns:** `Type` - Returns the current action.

### orSkipOnFail
#### orSkipOnFail

*Introduced in: 1.6.0*

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading