forked from ruifigueira/playwright-crx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(codegen): testIdAttributeName configuration added to recorder
Fixes: ruifigueira#15
- Loading branch information
1 parent
d9ca927
commit 536c6f3
Showing
7 changed files
with
154 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Playwright CRX - Configuration</title> | ||
</head> | ||
<body> | ||
<form id="options-form"> | ||
<label for="test-id">TestID Attribute Name:</label> | ||
<input type="text" id="test-id" name="test-id" placeholder="Enter Attribute Name" pattern="[a-zA-Z][\w\-]*" title="Must be a valid attribute name"> | ||
<button id="submit" type="submit">Save</button> | ||
</form> | ||
<script type="module" src="/src/options.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
body { | ||
font-family: sans-serif; | ||
margin: 20px; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
margin-bottom: 15px; | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
label { | ||
font-weight: bold; | ||
} | ||
|
||
input[type="text"] { | ||
padding: 5px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
width: 100%; | ||
} | ||
|
||
button[type="submit"] { | ||
background-color: #4CAF50; | ||
border: none; | ||
color: white; | ||
padding: 10px 20px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
font-size: 16px; | ||
margin: 4px 2px; | ||
cursor: pointer; | ||
border-radius: 4px; | ||
transition: background-color 0.2s ease-in-out; | ||
} | ||
|
||
button:hover { | ||
background-color: #45A049; | ||
} | ||
|
||
button[type="submit"]:disabled { | ||
background-color: #ccc; | ||
color: #666; | ||
cursor: not-allowed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import './options.css'; | ||
|
||
async function initialize() { | ||
const formElem = document.getElementById('options-form') as HTMLFormElement; | ||
const testIdAttributeNameElem = document.getElementById('test-id') as HTMLInputElement; | ||
const submitElem = document.getElementById('submit') as HTMLButtonElement; | ||
|
||
if (!testIdAttributeNameElem || !formElem || !submitElem) return; | ||
|
||
testIdAttributeNameElem.addEventListener('input', () => { | ||
submitElem.disabled = false; | ||
}); | ||
|
||
formElem.addEventListener('submit', (e) => { | ||
if (!formElem.reportValidity()) return; | ||
|
||
e.preventDefault(); | ||
|
||
submitElem.disabled = true; | ||
const testIdAttributeName = testIdAttributeNameElem.value; | ||
chrome.storage.sync.set({ testIdAttributeName }).catch(() => {}); | ||
|
||
return false; | ||
}); | ||
|
||
submitElem.disabled = true; | ||
const { testIdAttributeName } = await chrome.storage.sync.get('testIdAttributeName'); | ||
testIdAttributeNameElem.value = testIdAttributeName ?? 'data-testid'; | ||
} | ||
|
||
initialize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters