Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serenity-js/web

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serenity-js/web - npm Package Compare versions

Comparing version 3.0.0-rc.36 to 3.0.0-rc.37

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.0.0-rc.37](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.36...v3.0.0-rc.37) (2022-12-18)
### Bug Fixes
* **web:** support for setting cookies using async or partially async data ([ec8a65d](https://github.com/serenity-js/serenity-js/commit/ec8a65d9e3c1e2eb311d14eb32f1de9e26b5879b)), closes [#1421](https://github.com/serenity-js/serenity-js/issues/1421)
# [3.0.0-rc.36](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.35...v3.0.0-rc.36) (2022-11-28)

@@ -8,0 +19,0 @@

71

lib/screenplay/models/Cookie.d.ts

@@ -1,2 +0,2 @@

import { Answerable, Interaction, Optional, QuestionAdapter, Timestamp } from '@serenity-js/core';
import { Answerable, Interaction, Optional, QuestionAdapter, Timestamp, WithAnswerableProperties } from '@serenity-js/core';
import { CookieData } from './CookieData';

@@ -6,3 +6,62 @@ /**

*
* ## Checking if a cookie exists
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('example-cookie-name'),
* isPresent()
* ),
* )
* ```
*
* ## Setting a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent, not } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(Cookie.called('example-cookie-name'), not(isPresent())),
*
* Cookie.set({
* name: 'favourite',
* value: 'triple chocolate',
* }),
*
* Ensure.that(Cookie.called('example-cookie-name'), isPresent()),
* )
* ```
*
* ## Reading a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, equals } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('some-cookie-name').value(),
* equals('triple chocolate')
* ),
* )
* ```
*
* ## Learn more
* - {@apilink CookieData}
* - {@apilink Page.cookie}

@@ -21,10 +80,12 @@ *

/**
* Sets a cookie for the current {@apilink Page}.
* Sets a cookie for the current {@apilink Page}. Note that {@apilink CookieData} can be either a plain-old JavaScript object, or an {@apilink Answerable} {@apilink WithAnswerableProperties}.
*
* **Note:** Make sure that the actor performing this interaction is on the page that should receive the cookie.
* An actor can't set a cookie for an arbitrary page without being on that page.
* :::info
* Make sure that the actor performing this interaction is on the page that should receive the cookie.
* Because of browser security restrictions, an actor can't set a cookie for an arbitrary page without being on that page.
* :::
*
* @param cookieData
*/
static set(cookieData: Answerable<CookieData>): Interaction;
static set(cookieData: Answerable<WithAnswerableProperties<CookieData>>): Interaction;
/**

@@ -31,0 +92,0 @@ * Creates an {@apilink Interaction|interaction} to delete all cookies available to the current {@apilink Page}..

@@ -11,3 +11,62 @@ "use strict";

*
* ## Checking if a cookie exists
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('example-cookie-name'),
* isPresent()
* ),
* )
* ```
*
* ## Setting a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent, not } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(Cookie.called('example-cookie-name'), not(isPresent())),
*
* Cookie.set({
* name: 'favourite',
* value: 'triple chocolate',
* }),
*
* Ensure.that(Cookie.called('example-cookie-name'), isPresent()),
* )
* ```
*
* ## Reading a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, equals } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('some-cookie-name').value(),
* equals('triple chocolate')
* ),
* )
* ```
*
* ## Learn more
* - {@apilink CookieData}
* - {@apilink Page.cookie}

@@ -31,6 +90,8 @@ *

/**
* Sets a cookie for the current {@apilink Page}.
* Sets a cookie for the current {@apilink Page}. Note that {@apilink CookieData} can be either a plain-old JavaScript object, or an {@apilink Answerable} {@apilink WithAnswerableProperties}.
*
* **Note:** Make sure that the actor performing this interaction is on the page that should receive the cookie.
* An actor can't set a cookie for an arbitrary page without being on that page.
* :::info
* Make sure that the actor performing this interaction is on the page that should receive the cookie.
* Because of browser security restrictions, an actor can't set a cookie for an arbitrary page without being on that page.
* :::
*

@@ -41,3 +102,3 @@ * @param cookieData

return core_1.Interaction.where((0, core_1.d) `#actor sets cookie: ${cookieData}`, async (actor) => {
const cookie = (0, tiny_types_1.ensure)('cookieData', await actor.answer(cookieData), (0, tiny_types_1.isDefined)(), (0, tiny_types_1.isPlainObject)());
const cookie = (0, tiny_types_1.ensure)('cookieData', await actor.answer(core_1.Question.fromObject(cookieData)), (0, tiny_types_1.isDefined)(), (0, tiny_types_1.isPlainObject)());
const page = await abilities_1.BrowseTheWeb.as(actor).currentPage();

@@ -44,0 +105,0 @@ const sanitisedCookieData = {

18

package.json
{
"name": "@serenity-js/web",
"version": "3.0.0-rc.36",
"version": "3.0.0-rc.37",
"description": "Serenity/JS Screenplay Pattern APIs for the Web",

@@ -30,5 +30,5 @@ "author": {

"scripts": {
"clean": "rimraf .nyc_output lib target",
"clean": "rimraf '../../target/coverage/web'",
"test": "nyc mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
"compile": "tsc --project tsconfig.build.json"
"compile": "rimraf lib && tsc --project tsconfig.build.json"
},

@@ -48,4 +48,4 @@ "repository": {

"dependencies": {
"@serenity-js/assertions": "3.0.0-rc.36",
"@serenity-js/core": "3.0.0-rc.36",
"@serenity-js/assertions": "3.0.0-rc.37",
"@serenity-js/core": "3.0.0-rc.37",
"tiny-types": "^1.19.0"

@@ -56,9 +56,9 @@ },

"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.0",
"mocha": "^10.1.0",
"@types/mocha": "^10.0.1",
"mocha": "^10.2.0",
"nyc": "15.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
"typescript": "^4.9.4"
},
"gitHead": "5a433b1fc6d4cdf05463083f631d4ff4033826bf"
"gitHead": "7856213c0d34cc512e55c22c2d2635832c3499b8"
}

@@ -20,3 +20,1 @@ # Serenity/JS

[`@serenity-js/web`](https://serenity-js.org/modules/web/) contains Serenity/JS Screenplay Pattern APIs for testing Web apps.
[![Build Status](https://app.saucelabs.com/browser-matrix/jan-molak.svg)](https://app.saucelabs.com/builds/b709ea824727341f8cf23a82ce1cfe59)

@@ -1,2 +0,2 @@

import { Answerable, d, Interaction, Optional, Question, QuestionAdapter, Timestamp } from '@serenity-js/core';
import { Answerable, d, Interaction, Optional, Question, QuestionAdapter, Timestamp, WithAnswerableProperties } from '@serenity-js/core';
import { ensure, isBoolean, isDefined, isInstanceOf, isOneOf, isPlainObject, isString, Predicate } from 'tiny-types';

@@ -11,3 +11,62 @@

*
* ## Checking if a cookie exists
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('example-cookie-name'),
* isPresent()
* ),
* )
* ```
*
* ## Setting a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, isPresent, not } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(Cookie.called('example-cookie-name'), not(isPresent())),
*
* Cookie.set({
* name: 'favourite',
* value: 'triple chocolate',
* }),
*
* Ensure.that(Cookie.called('example-cookie-name'), isPresent()),
* )
* ```
*
* ## Reading a cookie
*
* ```typescript
* import { actorCalled } from '@serenity-js/core'
* import { Navigate, Cookie } from '@serenity-js/web'
* import { Ensure, equals } from '@serenity-js/assertions'
*
* await actorCalled('Sid')
* .attemptsTo(
* Navigate.to('https://example.org'),
*
* Ensure.that(
* Cookie.called('some-cookie-name').value(),
* equals('triple chocolate')
* ),
* )
* ```
*
* ## Learn more
* - {@apilink CookieData}
* - {@apilink Page.cookie}

@@ -33,13 +92,15 @@ *

/**
* Sets a cookie for the current {@apilink Page}.
* Sets a cookie for the current {@apilink Page}. Note that {@apilink CookieData} can be either a plain-old JavaScript object, or an {@apilink Answerable} {@apilink WithAnswerableProperties}.
*
* **Note:** Make sure that the actor performing this interaction is on the page that should receive the cookie.
* An actor can't set a cookie for an arbitrary page without being on that page.
* :::info
* Make sure that the actor performing this interaction is on the page that should receive the cookie.
* Because of browser security restrictions, an actor can't set a cookie for an arbitrary page without being on that page.
* :::
*
* @param cookieData
*/
static set(cookieData: Answerable<CookieData>): Interaction {
static set(cookieData: Answerable<WithAnswerableProperties<CookieData>>): Interaction {
return Interaction.where(d `#actor sets cookie: ${ cookieData }`, async actor => {
const cookie = ensure('cookieData', await actor.answer(cookieData), isDefined(), isPlainObject());
const cookie = ensure('cookieData', await actor.answer(Question.fromObject(cookieData)) as CookieData, isDefined(), isPlainObject());

@@ -46,0 +107,0 @@ const page = await BrowseTheWeb.as(actor).currentPage();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc