test('create second shopping list', async (t) => { await loginFirstUser(t) await waitSelector(t, 'ShoppingLists', Selector('.example-form-control')) await t.typeText( await Selector('.example-form-control'), 'Second Shopping List' ) await t.click(await Selector('button').withText('Add Shopping List')) await refreshAndWait(t, () => Selector('.shopping-list').count, 3) })
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 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('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('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('remove items in first shopping list', async (t) => { await loginFirstUser(t) await waitSelector( t, 'ShoppingLists', Selector('a').withText('First Shopping List') ) await t.click(Selector('a').withText('First Shopping List')) await waitSelector(t, 'ShoppingLists', Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.expect(Selector('.shopping-list').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('remove items in first shopping list', async t => { await t.click(Selector('a').withText('First Shopping List')) await t.wait(3000) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.expect(await Selector('td > a').count).eql(0) })
/** * 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('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 first shopping list', async (t) => { await loginFirstUser(t) await waitSelector(t, 'ShoppingLists', Selector('.example-form-control')) await t.typeText( await Selector('.example-form-control'), 'First Shopping List' ) await t.click(await Selector('button').withText('Add Shopping List')) await refreshAndWait(t, () => Selector('.shopping-list').count, 2) })
test('remove items in second shopping list', async t => { await t.click(Selector('a').withText('Second Shopping List')) await t.wait(3000) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.click(Selector('.example-close-button')) await t.expect(await Selector('td > a').count).eql(0) })
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 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) })