|
1 | 1 | import 'cypress-file-upload';
|
| 2 | +import { randomEmail } from '../support/faker'; |
2 | 3 | const random = Math.round(Math.random() * 100000);
|
3 | 4 | const expenseDescription = `New expense ${random}`;
|
4 | 5 |
|
@@ -47,7 +48,7 @@ describe('New expense flow', () => {
|
47 | 48 | cy.getByDataCy('expense-create-help').should('not.exist');
|
48 | 49 | });
|
49 | 50 |
|
50 |
| - it('submits new expense ', () => { |
| 51 | + it('submits new expense then edit it', () => { |
51 | 52 | cy.getByDataCy('radio-expense-type-RECEIPT').click();
|
52 | 53 | cy.get('input[name="description"]').type('Brussels January team retreat');
|
53 | 54 |
|
@@ -92,8 +93,55 @@ describe('New expense flow', () => {
|
92 | 93 | cy.getByDataCy('expense-summary-items').should('contain', 'Fancy restaurant');
|
93 | 94 | cy.getByDataCy('expense-summary-items').should('contain', 'Potatoes for the giant raclette');
|
94 | 95 |
|
| 96 | + // Submit! |
95 | 97 | cy.getByDataCy('submit-expense-btn').click();
|
| 98 | + cy.contains('[data-cy="temporary-notification"]', 'Expense submited!'); |
96 | 99 | cy.contains('[data-cy="expense-page-content"]', 'Brussels January team retreat');
|
| 100 | + cy.getByDataCy('dismiss-temporary-notification-btn').click(); |
| 101 | + cy.getByDataCy('temporary-notification').should('not.exist'); |
| 102 | + |
| 103 | + // Start editing |
| 104 | + cy.getByDataCy('edit-expense-btn').click(); |
| 105 | + cy.get('input[name="description"]').type(' edited'); |
| 106 | + cy.get('input[name="items[0].description"]').type(' but not too expensive'); |
| 107 | + cy.get('input[name="items[0].amount"]').type('{selectall}111'); |
| 108 | + // Add new item |
| 109 | + cy.getByDataCy('expense-add-item-btn').click(); |
| 110 | + cy.get('input[name="items[2].description"]').type('Some more delicious stuff'); |
| 111 | + cy.get('input[name="items[2].amount"]').type('{selectall}34'); |
| 112 | + cy.fixture('images/receipt.jpg').then(fileContent => { |
| 113 | + cy.getByDataCy('items[2].url-dropzone').upload( |
| 114 | + [{ fileContent, fileName: `receipt2.jpg`, mimeType: 'image/jpeg' }], |
| 115 | + { subjectType: 'drag-n-drop' }, |
| 116 | + ); |
| 117 | + }); |
| 118 | + // Change payee - use a new organization |
| 119 | + cy.getByDataCy('select-expense-payee').click(); |
| 120 | + cy.getByDataCy('collective-type-picker-ORGANIZATION').click(); |
| 121 | + cy.getByDataCy('create-collective-mini-form').then($form => { |
| 122 | + cy.wrap($form).find('input[name="members[0].member.email"]').type(randomEmail()); |
| 123 | + cy.wrap($form).find('input[name="members[0].member.name"]').type('Jack'); |
| 124 | + cy.wrap($form).find('input[name="name"]').type('PayeeOrg'); |
| 125 | + cy.wrap($form).find('button[type="submit"]').click(); |
| 126 | + }); |
| 127 | + cy.getByDataCy('create-collective-mini-form').should('not.exist'); // Wait for form to be submitted |
| 128 | + cy.getByDataCy('payout-method-select').click(); |
| 129 | + cy.contains('[data-cy="select-option"]', 'New PayPal account').click(); |
| 130 | + cy.get('input[name="payoutMethod.data.email"]').type('paypal-test-2@opencollective.com'); |
| 131 | + cy.getByDataCy('expense-summary-btn').click(); |
| 132 | + cy.getByDataCy('submit-expense-btn').click(); |
| 133 | + cy.getByDataCy('submit-expense-btn').should('not.exist'); // wait for form to be submitted |
| 134 | + |
| 135 | + // Check final expense page |
| 136 | + cy.contains('[data-cy="expense-page-content"]', 'Brussels January team retreat edited'); |
| 137 | + cy.getByDataCy('expense-summary-payee').should('contain', 'PayeeOrg'); |
| 138 | + cy.getByDataCy('expense-summary-host').should('contain', 'Open Source Collective org'); |
| 139 | + cy.getByDataCy('expense-summary-payout-method-data').should('contain', 'paypal-test-2@opencollective.com'); |
| 140 | + cy.getByDataCy('expense-summary-payout-method-type').should('contain', 'PayPal'); |
| 141 | + cy.getByDataCy('expense-items-total-amount').should('contain', '$237.50 USD'); |
| 142 | + cy.getByDataCy('expense-summary-items').should('contain', 'Fancy restaurant'); |
| 143 | + cy.getByDataCy('expense-summary-items').should('contain', 'Potatoes for the giant raclette'); |
| 144 | + cy.getByDataCy('expense-summary-items').should('contain', 'Some more delicious stuff'); |
97 | 145 | });
|
98 | 146 |
|
99 | 147 | // This can happen if you start with an invoice then switch to receipts
|
|
0 commit comments