Skip to content

Commit 74b15c3

Browse files
committed
test: follow setting container visibility
1 parent 3dbd4e0 commit 74b15c3

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

‎tests/Node/Scripts/Screenshots/browser-flows.test.mjs‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ test('fillTelegramConnectionSettings follows the current settings labels', async
120120
]);
121121
});
122122

123-
test('enableCustomMessageSettings waits for hidden fields and reveals them after enabling the message', async () => {
123+
test('enableCustomMessageSettings waits for hidden setting containers and reveals them after enabling the message', async () => {
124124
let enabled = false;
125125
const waits = [];
126126

@@ -130,24 +130,32 @@ test('enableCustomMessageSettings waits for hidden fields and reveals them after
130130
},
131131
};
132132

133-
const buildDependentField = (name) => ({
133+
const buildContainer = (name) => ({
134134
async waitFor(options) {
135135
waits.push([name, options]);
136+
assert.equal(enabled, options.state === 'visible');
137+
},
138+
});
136139

137-
if (options.state === 'hidden') {
138-
assert.equal(enabled, false);
139-
return;
140-
}
140+
const formatContainer = buildContainer('format');
141+
const templateContainer = buildContainer('template');
142+
const messageTemplate = {};
141143

142-
assert.equal(options.state, 'visible');
143-
assert.equal(enabled, true);
144+
const buildField = (container) => ({
145+
first() {
146+
return this;
147+
},
148+
locator() {
149+
return container;
144150
},
145151
});
146152

147-
const messageFormatLabel = buildDependentField('format');
148-
const messageTemplate = buildDependentField('template');
149-
150153
const page = {
154+
locator(selector) {
155+
return selector.includes('ParseMode')
156+
? buildField(formatContainer)
157+
: buildField(templateContainer);
158+
},
151159
getByRole(role, options) {
152160
if (role === 'checkbox') {
153161
assert.deepEqual(options, { name: 'Send a custom message' });
@@ -158,11 +166,6 @@ test('enableCustomMessageSettings waits for hidden fields and reveals them after
158166
assert.deepEqual(options, { name: 'Message template' });
159167
return messageTemplate;
160168
},
161-
getByText(text, options) {
162-
assert.equal(text, 'Message format');
163-
assert.deepEqual(options, { exact: true });
164-
return messageFormatLabel;
165-
},
166169
};
167170

168171
const result = await enableCustomMessageSettings(page);

0 commit comments

Comments
 (0)