test('create first shopping list', async t => { await t.typeText(Selector('input[type=text]').nth(0), 'First Shopping List') await t.click(Selector('button').withText('Add Shopping List')) await t.expect(await Selector('td > a').count).eql(1) })
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'); });
/** * Get a swag item based on text or a number * * @param {number|string} needle * * @returns {Selector} */ swag(needle) { if (typeof needle === 'string') { return this.items.withText(needle); } return this.items.nth(needle); }
test('create items in first shopping list', async t => { await t.click(Selector('a').withText('First Shopping List')) await t.wait(3000) await t.typeText(Selector('input[type=text]').nth(1), 'Item 1') await t.click(Selector('button').withText('Add Item')) await t.typeText(Selector('input[type=text]').nth(1), 'Item 2') await t.click(Selector('button').withText('Add Item')) await t.typeText(Selector('input[type=text]').nth(1), 'Item 3') await t.click(Selector('button').withText('Add Item')) await t.expect(Selector('label').withText('Item 1').exists).eql(true) await t.expect(Selector('label').withText('Item 2').exists).eql(true) await t.expect(Selector('label').withText('Item 3').exists).eql(true) })
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'); });
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('Gradually delete tasks and check it item', async t => { const page = new TodosPage(); await page.fillForm(t) await t .click(Selector('.alert').nth(0)) .expect(Selector('.alert').count).eql(2) .expect(Selector('.alert').nth(0).innerText).eql('task 2') .expect(Selector('.alert').nth(1).innerText).eql('task 3') .click(Selector('.alert').nth(1)) .expect(Selector('.alert').nth(0).innerText).eql('task 2') .click(Selector('.alert').nth(0)) .expect(Selector('.alert').count).eql(0) })
/** * Get a swag item * * @param {number|string} needle * * @returns {Selector} */ getSwagItem(needle){ if (typeof needle === 'string') { return this.swagItems.withText(needle); } return this.swagItems.nth(needle); }
test('toggle items in first shopping list', async t => { await t.click(Selector('a').withText('First Shopping List')) await t.wait(3000) await t.click(Selector('label').withText('Item 1')) await t.click(Selector('label').withText('Item 2')) await t.click(Selector('label').withText('Item 3')) await t .expect(Selector('label > input[type=checkbox]').nth(0).checked) .eql(true) await t .expect(Selector('label > input[type=checkbox]').nth(1).checked) .eql(true) await t .expect(Selector('label > input[type=checkbox]').nth(2).checked) .eql(true) })
/** * Get a cart item * * @param {number|string} needle * * @returns {Selector} */ getCartItem(needle) { if (typeof needle === 'string') { return this.cartItems.withText(needle); } return this.cartItems.nth(needle); }
test('Create 3 task and check it items', async t => { await t .typeText('input', 'task 1') .click('button') .typeText('input', 'task 2') .click('button') .typeText('input', 'task 3') .click('button') .expect(Selector('.alert').count).eql(3) .expect(Selector('.alert').nth(0).innerText).eql('task 1') .expect(Selector('.alert').nth(1).innerText).eql('task 2') .expect(Selector('.alert').nth(2).innerText).eql('task 3') })
test('Add Test', async t => { await t .click(Selector('button').withText('Add')) .selectText(Selector('[name="make"].form-control')) .typeText(Selector('[name="make"].form-control'), 'Pontiac') .selectText(Selector('[name="model"].form-control')) .typeText(Selector('[name="model"].form-control'), 'TransAm') .selectText(Selector('[name="year"].form-control')) .typeText(Selector('[name="year"].form-control'), '1993') .click(Selector('button').withText('Save')) .expect(Selector('tr').nth(-1).child().nextSibling(0).innerText).eql('Pontiac') .expect(Selector('tr').nth(-1).child().nextSibling(1).innerText).eql('TransAm') .expect(Selector('tr').nth(-1).child().nextSibling(2).innerText).eql('1993'); });
test('create second shopping list', async t => { await t.typeText(Selector('input[type=text]').nth(0), 'Second Shopping List') await t.click(Selector('button').withText('Add Shopping List')) await t.expect(await Selector('td > a').count).eql(2) })
test('create items in second shopping list', async t => { await t.click(Selector('a').withText('Second Shopping List')) await t.wait(3000) await t.typeText(Selector('input[type=text]').nth(1), 'Item 1') await t.click(Selector('button').withText('Add Item')) await t.typeText(Selector('input[type=text]').nth(1), 'Item 2') await t.click(Selector('button').withText('Add Item')) await t.typeText(Selector('input[type=text]').nth(1), 'Item 3') await t.click(Selector('button').withText('Add Item')) await t.expect(Selector('label').withText('Item 1').exists).eql(true) await t.expect(Selector('label').withText('Item 2').exists).eql(true) await t.expect(Selector('label').withText('Item 3').exists).eql(true) })
test('toggle items in second shopping list', async t => { await t.click(Selector('a').withText('Second Shopping List')) await t.wait(3000) await t.click(Selector('label').withText('Item 1')) await t.click(Selector('label').withText('Item 2')) await t.click(Selector('label').withText('Item 3')) await t .expect(Selector('label > input[type=checkbox]').nth(0).checked) .eql(true) await t .expect(Selector('label > input[type=checkbox]').nth(1).checked) .eql(true) await t .expect(Selector('label > input[type=checkbox]').nth(2).checked) .eql(true) })