-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[runtime] hide queries in the browser #1155
Changes from all commits
93c5160
450e47b
1edf395
d5997f6
bb97ca1
2d6ae9d
8594046
6d78a6f
967ef94
0ae6fc7
c146d28
8de4a1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
import { test, expect, Locator } from '@playwright/test'; | ||
import { test, expect } from '@playwright/test'; | ||
import { ToolpadHome } from '../../models/ToolpadHome'; | ||
import { ToolpadEditor } from '../../models/ToolpadEditor'; | ||
import clickCenter from '../../utils/clickCenter'; | ||
import domInput from './domInput.json'; | ||
|
||
async function getPropControlInputLocator(editorModel: ToolpadEditor, inputPropName: string) { | ||
const propControlLabelHandle = await editorModel.componentEditor | ||
.locator(`label:has-text("${inputPropName}")`) | ||
.elementHandle(); | ||
const propControlLabelFor = await propControlLabelHandle?.getAttribute('for'); | ||
|
||
return editorModel.componentEditor.locator(`input[id="${propControlLabelFor}"]`); | ||
} | ||
|
||
async function getInputElementLabelLocator(editorModel: ToolpadEditor, inputLocator: Locator) { | ||
const inputHandle = await inputLocator.elementHandle(); | ||
const inputId = await inputHandle?.getAttribute('id'); | ||
|
||
return editorModel.appCanvas.locator(`label[for="${inputId}"]`); | ||
} | ||
|
||
test('can control component prop values in properties control panel', async ({ | ||
page, | ||
browserName, | ||
|
@@ -40,35 +24,28 @@ test('can control component prop values in properties control panel', async ({ | |
const firstInputLocator = canvasInputLocator.first(); | ||
await clickCenter(page, firstInputLocator); | ||
|
||
await editorModel.componentEditor.waitFor(); | ||
await editorModel.componentEditor.waitFor({ state: 'visible' }); | ||
|
||
const labelControlInput = editorModel.componentEditor.getByLabel('label', { exact: true }); | ||
|
||
const labelControlInputValue = await editorModel.componentEditor | ||
.locator(`label:text-is("label")`) | ||
.inputValue(); | ||
const labelControlInputValue = await labelControlInput.inputValue(); | ||
|
||
expect(labelControlInputValue).toBe('textField1'); | ||
|
||
// Change component prop values directly | ||
|
||
const TEST_VALUE_1 = 'value1'; | ||
|
||
const getValueControlInputValue = async () => | ||
editorModel.componentEditor.locator(`label:text-is("value")`).inputValue(); | ||
|
||
expect(await getValueControlInputValue()).not.toBe(TEST_VALUE_1); | ||
const valueControl = editorModel.componentEditor.getByLabel('value', { exact: true }); | ||
expect(await valueControl.inputValue()).not.toBe(TEST_VALUE_1); | ||
await firstInputLocator.fill(TEST_VALUE_1); | ||
expect(await getValueControlInputValue()).toBe(TEST_VALUE_1); | ||
expect(await valueControl.inputValue()).toBe(TEST_VALUE_1); | ||
|
||
// Change component prop values through controls | ||
|
||
const firstInputLabelLocator = await getInputElementLabelLocator(editorModel, firstInputLocator); | ||
const TEST_VALUE_2 = 'value2'; | ||
const inputByLabel = editorModel.appCanvas.getByLabel(TEST_VALUE_2, { exact: true }); | ||
await expect(inputByLabel).toHaveCount(0); | ||
await labelControlInput.click(); | ||
await labelControlInput.fill(''); | ||
await labelControlInput.fill(TEST_VALUE_2); | ||
|
||
await expect(firstInputLabelLocator).not.toHaveText(TEST_VALUE_2); | ||
|
||
const labelControlInputLocator = await getPropControlInputLocator(editorModel, 'label'); | ||
await labelControlInputLocator.fill(''); | ||
await labelControlInputLocator.fill(TEST_VALUE_2); | ||
|
||
await expect(firstInputLabelLocator).toHaveText(TEST_VALUE_2); | ||
await inputByLabel.waitFor({ state: 'visible' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we're not checking if the value in the label matches in the end anymore? Was there any issue with that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we are, if the value doesn't match this selector wouldn't locate elements There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh it checks with that value already, i missed that. looks good then! |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess i hadn't found this selector that gets the input for a label? seems pretty useful