|
| 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 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds |
| 12 | + |
| 13 | + // Selecting Clocking block |
| 14 | + 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'; |
| 15 | + const clockingBlock = await window.waitForSelector(clockingBlockSelector); |
| 16 | + await clockingBlock.click(); |
| 17 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds |
| 18 | + |
| 19 | + // Clicking on Add button for Clocking |
| 20 | + const addButtonSelector = '#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button'; |
| 21 | + const addButton = await window.waitForSelector(addButtonSelector); |
| 22 | + await addButton.click(); |
| 23 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds |
| 24 | + |
| 25 | + // Ensure modal is visible before interacting |
| 26 | + const modalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div'; |
| 27 | + await window.waitForSelector(modalSelector, { state: 'visible', timeout: 5000 }); // Wait for modal |
| 28 | + |
| 29 | + // Typing description as 'test' |
| 30 | + 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]'; |
| 31 | + const descriptionInput = await window.waitForSelector(descriptionSelector); |
| 32 | + await descriptionInput.click(); |
| 33 | + await descriptionInput.fill('test'); |
| 34 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 35 | + |
| 36 | + // Typing Port/Signal name as 'test' |
| 37 | + 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]'; |
| 38 | + const portSignalInput = await window.waitForSelector(portSignalSelector); |
| 39 | + await portSignalInput.click(); |
| 40 | + await portSignalInput.fill('test'); |
| 41 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 42 | + |
| 43 | + // Clicking OK to submit the clocking form |
| 44 | + const okButtonSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid'; |
| 45 | + const okButton = await window.waitForSelector(okButtonSelector); |
| 46 | + await okButton.click(); |
| 47 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit |
| 48 | + |
| 49 | + // Navigate to the DSP block |
| 50 | + 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'; |
| 51 | + const dspBlock = await window.waitForSelector(dspBlockSelector); |
| 52 | + await dspBlock.click(); |
| 53 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds |
| 54 | + |
| 55 | + // Clicking on Add button for DSP |
| 56 | + const addDSPButton = await window.waitForSelector(addButtonSelector); // Reusing the same addButtonSelector |
| 57 | + await addDSPButton.click(); |
| 58 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds |
| 59 | + |
| 60 | + // Typing Name/Hierarchy as 'test' |
| 61 | + 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]'; |
| 62 | + const nameHierarchyInput = await window.waitForSelector(nameHierarchySelector); |
| 63 | + await nameHierarchyInput.click(); |
| 64 | + await nameHierarchyInput.fill('test'); |
| 65 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 66 | + |
| 67 | + // Typing XX as 32 |
| 68 | + 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]'; |
| 69 | + const xxInput = await window.waitForSelector(xxSelector); |
| 70 | + await xxInput.click(); |
| 71 | + await xxInput.fill('32'); |
| 72 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 73 | + |
| 74 | + // Typing A-input width as 64 |
| 75 | + 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]'; |
| 76 | + const aInputWidthInput = await window.waitForSelector(aInputWidthSelector); |
| 77 | + await aInputWidthInput.click(); |
| 78 | + await aInputWidthInput.fill('64'); |
| 79 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 80 | + |
| 81 | + // Typing B-input width as 64 |
| 82 | + 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]'; |
| 83 | + const bInputWidthInput = await window.waitForSelector(bInputWidthSelector); |
| 84 | + await bInputWidthInput.click(); |
| 85 | + await bInputWidthInput.fill('64'); |
| 86 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 87 | + |
| 88 | + // Typing toggle rate as 50 |
| 89 | + 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]'; |
| 90 | + const toggleRateInput = await window.waitForSelector(toggleRateSelector); |
| 91 | + await toggleRateInput.click(); |
| 92 | + await toggleRateInput.fill('50'); |
| 93 | + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second |
| 94 | + |
| 95 | + // Take note of the DSP power generated (assuming it's shown in the UI somewhere, you can add the selector for DSP power if needed) |
| 96 | + |
| 97 | + // Clicking OK to submit the DSP form |
| 98 | + const dspOkButtonSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid'; |
| 99 | + const dspOkButton = await window.waitForSelector(dspOkButtonSelector); |
| 100 | + await dspOkButton.click(); |
| 101 | + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit |
| 102 | + |
| 103 | + // Closing the test |
| 104 | + await app.close(); |
| 105 | +}); |
0 commit comments