/** * {{> seeInField }} */ async seeInField(field, value) { // const expectedValue = findElements.call(this, this.context, field).value; const els = await findFields.call(this, field); assertElementExists(els, field, 'Field'); const el = await els.nth(0); return this.t .expect(await el.value).eql(value) .catch(mapError); }
it('should build locator to match element by position', () => { const l = Locator.build('#fieldset-buttons') .find('//tr') .first() .find('td') .at(2); const nodes = xpath.select(l.toXPath(), doc); expect(nodes).to.have.length(1, l.toXPath()); expect(nodes[0].firstChild.data).to.eql('Edit'); });
describe('#methodsOfObject', () => { it('should get methods', () => { utils.methodsOfObject({ a: 1, hello: () => {}, world: () => {}, }).should.eql(['hello', 'world']); }); });
it('should select element by siblings', () => { const l = Locator.build('//table') .find('td') .after(Locator.build('td').withText('Also Edit')) .first(); const nodes = xpath.select(l.toXPath(), doc); expect(nodes).to.have.length(1, l.toXPath()); expect(nodes[0].firstChild.data).to.eql('Also Delete', l.toXPath()); });
/** * {{> seeNumberOfVisibleElements }} * */ async seeNumberOfVisibleElements(locator, num) { const count = (await findElements.call(this, this.context, locator)).filterVisible().count; return this.t .expect(count).eql(num) .catch(mapError); }
it('should create a new post with predefined field', async () => { await I.have('post', { author: 'Tapac' }); let resp = await I.restHelper.sendGetRequest('/posts/1'); resp.data.author.should.eql('davert'); resp = await I.restHelper.sendGetRequest('/posts/2'); resp.data.author.should.eql('Tapac'); });
test( 'should not load invalid persisted state', () => { const original = deepFreeze( { 2916284: '{INVALID', } ); const state = queries( original, { type: DESERIALIZE } ); expect( state ).to.eql( {} ); } );
describe('open page : #amOnPage', () => { it('should open main page of configured site', () => wd.amOnPage('/').getUrl().then(url => url.should.eql(`${siteUrl}/`))); it('should open any page of configured site', () => wd.amOnPage('/info').getUrl().then(url => url.should.eql(`${siteUrl}/info`))); it('should open absolute url', () => wd.amOnPage(siteUrl).getUrl().then(url => url.should.eql(`${siteUrl}/`))); });
describe('with Locator object argument', () => { it('should create id locator', () => { const l = new Locator(new Locator({ id: 'foo' })); expect(l).to.eql(new Locator({ id: 'foo' })); expect(l.type).to.equal('id'); expect(l.value).to.equal('foo'); expect(l.toString()).to.equal('{id: foo}'); }); });
describe( 'deleteConnections()', () => { test( 'should return an action object', () => { const action = deleteConnection( { ID: 2, site_ID: 2916284 } ); expect( action ).to.eql( { type: PUBLICIZE_CONNECTION_DELETE, connection: { ID: 2, site_ID: 2916284, }, } ); } ); } );
it('should build complex locator', () => { const l = Locator.build('#fieldset-buttons') .find('tr') .last() .find('td') .first(); const nodes = xpath.select(l.toXPath(), doc); expect(nodes).to.have.length(1, l.toXPath()); expect(nodes[0].firstChild.data).to.eql('Show'); });
describe( '#receiveConnections()', () => { test( 'should return an action object', () => { const data = { connections: [ { ID: 2, site_ID: 2916284 } ] }; const action = receiveConnections( 2916284, data ); expect( action ).to.eql( { type: PUBLICIZE_CONNECTIONS_RECEIVE, siteId: 2916284, data, } ); } ); } );
describe( '#receivePost()', () => { test( 'should return an action object', () => { const post = { ID: 841, title: 'Hello World' }; const action = receivePost( post ); expect( action ).to.eql( { type: POSTS_RECEIVE, posts: [ post ], } ); } ); } );
test( 'should not load invalid persisted state', () => { const original = '{INVALID'; const state = allSitesQueries( original, { type: DESERIALIZE } ); expect( state ).to.be.an.instanceof( PostQueryManager ); expect( state.data ).to.eql( { items: {}, queries: {} } ); expect( state.options ).to.eql( { itemKey: 'global_ID' } ); } );