|
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | +function delay(time) { |
| 5 | + return new Promise(resolve => setTimeout(resolve, time)); |
| 6 | +} |
| 7 | + |
| 8 | + |
| 9 | +describe('Sign-up flow', () => { |
| 10 | + beforeAll(async () => { |
| 11 | + await device.launchApp({ |
| 12 | + newInstance: true, |
| 13 | + launchArgs: { isDetoxTest: true } |
| 14 | + }); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should allow a user to sign up and delete the account after', async () => { |
| 18 | + |
| 19 | + await new Promise(resolve => setTimeout(resolve, 10000)); |
| 20 | + |
| 21 | + // Wait for the sign-up link to be visible |
| 22 | + await waitFor(element(by.id('signup-link'))).toBeVisible().withTimeout(10000); |
| 23 | + |
| 24 | + // Introduce a delay (e.g., 2000 milliseconds) |
| 25 | + await new Promise(resolve => setTimeout(resolve, 10000)); |
| 26 | + await element(by.id('signup-link')).tap(); |
| 27 | + |
| 28 | + await waitFor(element(by.id('signup-fname-input'))).toBeVisible().withTimeout(5000); |
| 29 | + await element(by.id('signup-fname-input')).typeText('TestFirstName'); |
| 30 | + |
| 31 | + await waitFor(element(by.id('signup-lname-input'))) |
| 32 | + .toBeVisible() |
| 33 | + .whileElement(by.id('scrollViewId')) |
| 34 | + .scroll(400, 'down'); |
| 35 | + await element(by.id('signup-lname-input')).typeText('TestLastName'); |
| 36 | + |
| 37 | + await waitFor(element(by.id('signup-email-input'))).toBeVisible().withTimeout(5000); |
| 38 | + // const testEmail = `test${new Date().getTime()}@example.com`; // Dynamic email to avoid conflicts |
| 39 | + await element(by.id('signup-email-input')).typeText('[email protected]'); |
| 40 | + //await element(by.id('signup-email-input')).typeText(`test${Date.now()}@example.com`); |
| 41 | + |
| 42 | + await waitFor(element(by.id('signup-password-input'))).toBeVisible().withTimeout(5000); |
| 43 | + await element(by.id('signup-password-input')).typeText('password123'); |
| 44 | + |
| 45 | + await waitFor(element(by.id('signup-repassword-input'))).toBeVisible().withTimeout(5000); |
| 46 | + await element(by.id('signup-repassword-input')).typeText('password123'); |
| 47 | + |
| 48 | + if (device.getPlatform() === 'android') { |
| 49 | + await device.pressBack(); // to close the keyboard |
| 50 | + } |
| 51 | + |
| 52 | + // Accepting terms and conditions |
| 53 | + await element(by.id('signup-terms-checkbox')).tap(); |
| 54 | + //await element(by.id('signup-terms-checkbox')).tap(); |
| 55 | + |
| 56 | + // Use the delay function before scrolling |
| 57 | + await delay(30000); // Waits for 50 seconds |
| 58 | + |
| 59 | + await waitFor(element(by.id('signup-terms-modal'))) |
| 60 | + .toBeVisible() |
| 61 | + .whileElement(by.id('scrollViewModal')) |
| 62 | + .scrollTo('bottom'); |
| 63 | + //.scroll(400, 'down'); |
| 64 | + //await element(by.id('signup-terms-modal-checkbox')).tap(); |
| 65 | + await element(by.id('signup-terms-checkbox')).tap(); |
| 66 | + |
| 67 | + // await waitFor(element(by.id('signup-terms-modal'))).toBeVisible().withTimeout(5000); |
| 68 | + |
| 69 | + await element(by.id('close-modal-button')).tap(); |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + // Attempt to scroll a significant distance down |
| 74 | + //await element(by.id('scrollViewModal')).scroll(200, 'down'); |
| 75 | + |
| 76 | + // await waitFor(element(by.id('signup-terms-modal-checkbox'))) |
| 77 | + // .toBeVisible() |
| 78 | + // .whileElement(by.id('scrollViewModal')) |
| 79 | + // .scroll(400, 'down'); |
| 80 | + |
| 81 | + //await element(by.id('signup-terms-modal-checkbox')).tap(); |
| 82 | + |
| 83 | + await waitFor(element(by.id('signup-submit-button'))).toBeVisible().withTimeout(5000); |
| 84 | + await element(by.id('signup-submit-button')).tap(); |
| 85 | + |
| 86 | + // Assuming you navigate to a "success" screen after sign up |
| 87 | + await waitFor(element(by.id('signup-success-message'))).toBeVisible().withTimeout(10000); |
| 88 | + |
| 89 | + // Here, you should add validation that the sign-up was successful |
| 90 | + // For example, checking for a welcome message or successful navigation |
| 91 | + |
| 92 | + // **Teardown - Deleting the test account** |
| 93 | + // This step assumes you have a mechanism to trigger account deletion via an API or direct backend call |
| 94 | + // The implementation of this would be specific to your backend and not provided here |
| 95 | + }, 300000); |
| 96 | + |
| 97 | + afterAll(async () => { |
| 98 | + // Cleanup: delete the account if your test created one. |
| 99 | + // This is pseudocode and would need to be adapted to your application's context. |
| 100 | + // await deleteTestAccount(testEmail, 'password123'); |
| 101 | + }); |
| 102 | +}); |
0 commit comments