|
1 | | -// const { _electron: electron } = require('playwright'); |
2 | | -// const { test, expect } = require('@playwright/test'); |
3 | | - |
4 | | -// test('Launch Electron app, add clocking source, navigate to DSP block, configure DSP, and submit form', async () => { |
5 | | -// const app = await electron.launch({ args: ['main.js'] }); |
6 | | -// const window = await app.firstWindow(); |
7 | | - |
8 | | -// // Select the device (MPW1 Gemini) |
9 | | -// await window.selectOption('#deviceId', 'MPW1'); |
10 | | - |
11 | | -// // Select Clocking block and click Add |
12 | | -// await window.click('#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(2) > div:nth-child(1) > div'); |
13 | | -// await window.click('#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button'); |
14 | | - |
15 | | -// // Fill and submit Clocking form |
16 | | -// await window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=text]', 'test'); |
17 | | -// await window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(3) > input[type=text]', 'test'); |
18 | | -// await window.click('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn-primary'); |
19 | | - |
20 | | -// // Navigate to DSP block and click Add |
21 | | -// await window.click('#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(3) > div:nth-child(2) > div'); |
22 | | -// await window.click('#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button'); |
23 | | - |
24 | | -// // Fill and submit DSP form |
25 | | -// await Promise.all([ |
26 | | -// window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(1) > input[type=text]', 'test'), |
27 | | -// window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=number]', '32'), |
28 | | -// window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(4) > input[type=number]', '64'), |
29 | | -// window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(5) > input[type=number]', '64'), |
30 | | -// window.fill('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(8) > input[type=number]', '50') |
31 | | -// ]); |
32 | | -// await window.click('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn-primary'); |
33 | | - |
34 | | -// // Close the test |
35 | | -// await app.close(); |
36 | | -// }); |
| 1 | +const { _electron: electron } = require('playwright'); |
| 2 | +const { test, expect } = require('@playwright/test'); |
| 3 | + |
| 4 | +test('Launch Electron app, add clocking source, navigate to DSP block, configure DSP, and submit form', async () => { |
| 5 | + const app = await electron.launch({ args: ['main.js'] }); |
| 6 | + const window = await app.firstWindow(); |
| 7 | + |
| 8 | + // Selecting the device (MPW1 Gemini) |
| 9 | + const deviceDropdown = await window.waitForSelector('#deviceId'); |
| 10 | + await deviceDropdown.selectOption('MPW1'); |
| 11 | + |
| 12 | + // Selecting Clocking block |
| 13 | + const clockingBlockSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(2) > div:nth-child(1) > div'; |
| 14 | + const clockingBlock = await window.waitForSelector(clockingBlockSelector); |
| 15 | + await clockingBlock.click(); |
| 16 | + |
| 17 | + // Clicking on Add button for Clocking |
| 18 | + const addButtonSelector = '#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button'; |
| 19 | + const addButton = await window.waitForSelector(addButtonSelector); |
| 20 | + await addButton.click(); |
| 21 | + |
| 22 | + // Ensure modal is visible before interacting |
| 23 | + const modalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div'; |
| 24 | + await window.waitForSelector(modalSelector, { state: 'visible' }); |
| 25 | + |
| 26 | + // Typing description as 'test' |
| 27 | + const descriptionSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=text]'; |
| 28 | + const descriptionInput = await window.waitForSelector(descriptionSelector); |
| 29 | + await descriptionInput.fill('test'); |
| 30 | + |
| 31 | + // Typing Port/Signal name as 'test' |
| 32 | + const portSignalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(3) > input[type=text]'; |
| 33 | + const portSignalInput = await window.waitForSelector(portSignalSelector); |
| 34 | + await portSignalInput.fill('test'); |
| 35 | + |
| 36 | + // Clicking OK to submit the form |
| 37 | + const modalFooterSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer'; |
| 38 | + const okButton = await window.locator(`${modalFooterSelector} button.ant-btn-primary`); |
| 39 | + await okButton.click(); |
| 40 | + |
| 41 | + // Navigate to the DSP block |
| 42 | + const dspBlockSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(3) > div:nth-child(2) > div'; |
| 43 | + const dspBlock = await window.waitForSelector(dspBlockSelector); |
| 44 | + await dspBlock.click(); |
| 45 | + |
| 46 | + // Clicking on Add button for DSP |
| 47 | + const addDSPButton = await window.waitForSelector(addButtonSelector); // Reusing the same addButtonSelector |
| 48 | + await addDSPButton.click(); |
| 49 | + |
| 50 | + // Typing Name/Hierarchy as 'test' |
| 51 | + const nameHierarchySelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(1) > input[type=text]'; |
| 52 | + const nameHierarchyInput = await window.waitForSelector(nameHierarchySelector); |
| 53 | + await nameHierarchyInput.fill('test'); |
| 54 | + |
| 55 | + // Typing XX as 32 |
| 56 | + const xxSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=number]'; |
| 57 | + const xxInput = await window.waitForSelector(xxSelector); |
| 58 | + await xxInput.fill('32'); |
| 59 | + |
| 60 | + // Typing A-input width as 64 |
| 61 | + const aInputWidthSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(4) > input[type=number]'; |
| 62 | + const aInputWidthInput = await window.waitForSelector(aInputWidthSelector); |
| 63 | + await aInputWidthInput.fill('64'); |
| 64 | + |
| 65 | + // Typing B-input width as 64 |
| 66 | + const bInputWidthSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(5) > input[type=number]'; |
| 67 | + const bInputWidthInput = await window.waitForSelector(bInputWidthSelector); |
| 68 | + await bInputWidthInput.fill('64'); |
| 69 | + |
| 70 | + // Typing toggle rate as 50 |
| 71 | + const toggleRateSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(8) > input[type=number]'; |
| 72 | + const toggleRateInput = await window.waitForSelector(toggleRateSelector); |
| 73 | + await toggleRateInput.fill('50'); |
| 74 | + |
| 75 | +// Define the modal footer selector as the base context |
| 76 | + const dspModalFooterSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer'; |
| 77 | + |
| 78 | +// Locate the OK button within the modal footer |
| 79 | + const dspOkButton = await window.locator(`${dspModalFooterSelector} button.ant-btn-primary`); |
| 80 | + |
| 81 | +// Click the OK button |
| 82 | + await dspOkButton.click(); |
| 83 | + |
| 84 | + // Closing the test |
| 85 | + await app.close(); |
| 86 | +}); |
0 commit comments