|
1 | | -const { test } = require('@playwright/test'); |
| 1 | +const { test, expect } = require('@playwright/test'); |
2 | 2 |
|
3 | 3 | const common = require('../../common'); |
4 | 4 |
|
5 | 5 | test.beforeEach(common.launchEmbedded); |
6 | 6 |
|
7 | 7 | test.describe('E2E test', () => { |
8 | | - test('Embedded: should launch, select a service plan and fill details', async ({ page }) => { |
9 | | - const silverPlan = page.locator('button:has-text("shop now") >> nth=1'); |
10 | | - await silverPlan.click(); |
| 8 | + test('Embedded: should launch, select a phone and purchase the phone', async ({ page }) => { |
| 9 | + const selectPhone = page.locator('button:has-text("Buy now") >> nth=1'); |
| 10 | + await selectPhone.click(); |
| 11 | + |
| 12 | + const storageSelectableCard = await page.locator('div[id="selectable-card"] >> nth=1'); |
| 13 | + await storageSelectableCard.locator('label >> span >> input >> nth=1').click(); |
| 14 | + |
| 15 | + const colorSelectableCard = await page.locator('div[id="selectable-card"] >> nth=2'); |
| 16 | + await colorSelectableCard.locator('label >> span >> input >> nth=1').click(); |
| 17 | + |
| 18 | + await page.locator('button:has-text("next")').click(); |
| 19 | + |
| 20 | + const phonenumber = page.locator('div[role="radiogroup"] >> nth=0'); |
| 21 | + const requiredInput = phonenumber.locator('label >> span >> input >> nth=1'); |
| 22 | + await requiredInput.click(); |
| 23 | + |
| 24 | + const tradeIn = page.locator('div[role="radiogroup"] >> nth=1'); |
| 25 | + const tradeInInput = tradeIn.locator('label >> span >> input >> nth=1'); |
| 26 | + await tradeInInput.click(); |
| 27 | + |
| 28 | + const paymentOptionsSelectableCard = await page.locator('div[id="selectable-card"] >> nth=0'); |
| 29 | + await paymentOptionsSelectableCard.locator('label >> span >> input >> nth=1').click(); |
| 30 | + |
| 31 | + await page.locator('button:has-text("next")').click(); |
11 | 32 |
|
12 | 33 | const firstNameInput = page.locator('input[data-test-id="BC910F8BDF70F29374F496F05BE0330C"]'); |
13 | 34 | await firstNameInput.click(); |
14 | 35 | await firstNameInput.fill('John'); |
15 | 36 |
|
16 | | - const middleNameInput = page.locator('input[data-test-id="D3691D297D95C48EF1A2B7D6523EF3F0"]'); |
17 | | - await middleNameInput.click(); |
18 | | - await middleNameInput.fill(''); |
19 | | - |
20 | 37 | const lastNameInput = page.locator('input[data-test-id="77587239BF4C54EA493C7033E1DBF636"]'); |
21 | 38 | await lastNameInput.click(); |
22 | 39 | await lastNameInput.fill('Doe'); |
23 | 40 |
|
24 | | - const suffix = page.locator('div[data-test-id="56E6DDD1CB6CEC596B433440DFB21C17"]'); |
25 | | - await suffix.locator('button[title="Open"]').click(); |
26 | | - await page.locator('li:has-text("Jr")').click(); |
27 | | - |
28 | | - const emailInput = page.locator('input[data-test-id="CE8AE9DA5B7CD6C3DF2929543A9AF92D"]'); |
| 41 | + const emailInput = page.locator('input[data-test-id="643a860f992333b8600ea264aca7c4fc"]'); |
29 | 42 | await emailInput.click(); |
30 | 43 | await emailInput.fill('[email protected]'); |
31 | 44 |
|
| 45 | + const phone = page.locator('div[data-test-id="1e4dbc7eaa78468a3bc1448a3d68d906"]'); |
| 46 | + const countrySelector = phone.locator('button'); |
| 47 | + await countrySelector.click(); |
| 48 | + await page.locator('text=United States+1 >> nth=0').click(); |
| 49 | + await common.enterPhoneNumber(phone, '6175551212'); |
| 50 | + |
| 51 | + await page.locator('button:has-text("next")').click(); |
| 52 | + |
| 53 | + const nameOnCard = page.locator('input[data-test-id="c2b63e85bd5e4dc9b6cf5a4693847e06"]'); |
| 54 | + await nameOnCard.click(); |
| 55 | + await nameOnCard.fill('John Doe'); |
| 56 | + |
32 | 57 | await page.locator('button:has-text("next")').click(); |
33 | 58 |
|
34 | 59 | const streetInput = page.locator('input[data-test-id="D61EBDD8A0C0CD57C22455E9F0918C65"]'); |
35 | 60 | await streetInput.click(); |
36 | 61 | await streetInput.fill('Main St'); |
37 | 62 |
|
38 | | - await page.locator('button:has-text("previous")').click(); |
39 | | - |
40 | | - await page.locator('h6:has-text("Customer Info")').click(); |
41 | | - |
42 | | - await page.locator('button:has-text("next")').click(); |
43 | | - |
44 | | - await page.locator('h6:has-text("Customer Address")').click(); |
| 63 | + const apartmentInput = page.locator('input[data-test-id="73786cb2bc433cfb06603ab61f15e04e"]'); |
| 64 | + await apartmentInput.click(); |
| 65 | + await apartmentInput.fill('Glenalmond Avenue'); |
45 | 66 |
|
46 | 67 | const cityInput = page.locator('input[data-test-id="57D056ED0984166336B7879C2AF3657F"]'); |
47 | 68 | await cityInput.click(); |
48 | 69 | await cityInput.fill('Cambridge'); |
49 | 70 |
|
50 | | - const state = page.locator('div[data-test-id="46A2A41CC6E552044816A2D04634545D"]'); |
51 | | - const stateSelector = state.locator('div[role="combobox"]'); |
52 | | - await stateSelector.click(); |
53 | | - await page.locator('li[data-value="MA"]').click(); |
| 71 | + const stateInput = page.locator('input[data-test-id="46A2A41CC6E552044816A2D04634545D"]'); |
| 72 | + await stateInput.click(); |
| 73 | + await stateInput.fill('Indiana'); |
54 | 74 |
|
55 | 75 | const postalCodeInput = page.locator('input[data-test-id="572ED696F21038E6CC6C86BB272A3222"]'); |
56 | 76 | await postalCodeInput.click(); |
57 | 77 | await postalCodeInput.fill('02142'); |
58 | 78 |
|
59 | | - const phone = page.locator('div[data-test-id="1F8261D17452A959E013666C5DF45E07"]'); |
60 | | - const countrySelector = phone.locator('button'); |
61 | | - await countrySelector.click(); |
62 | | - await page.locator('text=United States+1 >> nth=0').click(); |
63 | | - await common.enterPhoneNumber(phone, '6175551212'); |
64 | | - |
65 | | - await page.locator('button:has-text("next")').click(); |
66 | | - |
67 | | - const dataServiceBeginDate = page.locator('div[data-test-id="1321FA74451B96BC02663B0EF96CCBB9"]'); |
68 | | - const dataServiceBeginDateInput = dataServiceBeginDate.locator('input'); |
69 | | - await dataServiceBeginDateInput.click(); |
70 | | - const futureDate = common.getFutureDate(); |
71 | | - await dataServiceBeginDateInput.pressSequentially(futureDate); |
72 | | - |
73 | | - await page.locator('button:has-text("next")').click(); |
74 | | - |
75 | 79 | await page.locator('button:has-text("submit")').click(); |
76 | 80 |
|
77 | | - await page.locator('text=Thanks for selecting a package with us. ').click(); |
| 81 | + await expect(page.locator('p:has-text("Oceonix 25 Max")')).toBeVisible(); |
| 82 | + await expect(page.locator('p:has-text("[email protected]")')).toBeVisible(); |
| 83 | + |
| 84 | + await page.locator('a:has-text("Done")').click(); |
78 | 85 | }, 10000); |
79 | 86 | }); |
80 | 87 |
|
|
0 commit comments