test.disablePageReloads('Create article through form', async t => { debugger const typeOptions = { paste: true } await t.typeText(page.inputs.title, title, typeOptions) await t.typeText(page.inputs.teaser, teaser, typeOptions) await t.typeText(page.inputs.body, body, typeOptions) await t.typeText(page.inputs.published_at, publishedAt) await t.click(page.form.find('button[type=submit]')) await t.expect(page.title.innerText).eql(`Article #${db.articles.length + 1}`) })
/** * Get the swag item header based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagItemHeader(needle){ return this.getSwagItem(needle).find('.inventory_item_name'); }
test('Delete Test', async t => { await t .click(Selector('td').withText('Delete').nth(-1).find('.btn.btn-dark').nth(0)) .expect(Selector('tr').nth(-1).child().nextSibling(0).innerText).notEql('Pontiac') .expect(Selector('tr').nth(-1).child().nextSibling(1).innerText).notEql('TransAm') .expect(Selector('tr').nth(-1).child().nextSibling(2).innerText).notEql('1993'); });
test.disablePageReloads('Article can not be created without title', async t => { debugger await t.click(page.form.find('button[type=submit]')) await t.expect(Selector('#title-helper-text').innerText).eql('Title is required') })
test('Edit article through form', async t => { debugger const typeOptions = { paste: true, replace: true } await t.typeText(page.inputs.title, title, typeOptions) await t.click(page.form.find('button[type=submit]')) await t.expect(page.title.innerText).eql('Articles') const titleFields = Selector('[data-test="field-title"]') await t.expect(titleFields.nth((await titleFields.count) - 1).innerText).eql(title) })
test('Edit Test', async t => { await t .click(Selector('td').withText('Edit').find('.btn.btn-primary').nth(0)) .selectText(Selector('[name="make"].form-control')) .typeText(Selector('[name="make"].form-control'), 'DMC') .selectText(Selector('[name="model"].form-control')) .typeText(Selector('[name="model"].form-control'), 'DeLorean') .selectText(Selector('[name="year"].form-control')) .typeText(Selector('[name="year"].form-control'), '1981') .click(Selector('button').withText('Save')) .expect(Selector('tbody > tr > td').nextSibling(0).innerText).eql('DMC') .expect(Selector('tbody > tr > td').nextSibling(1).innerText).eql('DeLorean') .expect(Selector('tbody > tr > td').nextSibling(2).innerText).eql('1981'); });
/** * Get the swag remove button based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagRemoveButton(needle){ return this.getCartItem(needle).find('.btn_secondary.cart_button'); }
/** * Get the swag item add button based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagItemAddButton(needle){ return this.getSwagItem(needle).find('.btn_primary.btn_inventory'); }
/** * Get the swag item remove button based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagItemRemoveButton(needle){ return this.getSwagItem(needle).find('.btn_secondary.btn_inventory'); }