Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Production/RAMMIT-Stable/Tests/TestUi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ try {
Check('launch button counts', (await Text('#LaunchBtn')) === 'LAUNCH 4 SELECTED');
await Page.click('#SelectAllBtn'); await Wait(150);
Check('clear all', await Count('#AccountList .Selected') === 0);
const Persisted = await CallApi('GetSettings');
Check('selection persisted by username', Array.isArray(Persisted.SelectedAccounts) && Persisted.SelectedAccounts.length === 0);
Check('selection persisted by username', await WaitFor(async () => Array.isArray((await CallApi('GetSettings')).SelectedAccounts) && (await CallApi('GetSettings')).SelectedAccounts.length === 0));

// ------------------------------------------------------------ launching
await Pick('LaunchOptionSelect', 'Home');
Expand Down Expand Up @@ -167,17 +166,17 @@ try {
await Page.click('#SaveSettingsBtn'); await Wait(200);
Check('max instances 0 rejected', /1 to 100/.test(await Text('#StatusMessage')), await Text('#StatusMessage') + ' / ' + await Page.$eval('#MaxInstances', E => E.value));
await SetValue(Page, '#MaxInstances', '10');
await Page.click('#SaveSettingsBtn'); await Wait(300);
Check('settings saved', (await Text('#StatusMessage')) === 'Settings saved' && (await CallApi('GetSettings')).MaxInstances === 10);
await Page.click('#SaveSettingsBtn');
Check('settings saved', await WaitFor(async () => (await Text('#StatusMessage')) === 'Settings saved' && (await CallApi('GetSettings')).MaxInstances === 10));
Check('backend rejects bad types', !!(await CallApi('UpdateSetting', 'MaxInstances', 'lots')).Error && !!(await CallApi('UpdateSetting', 'Bogus', 1)).Error);
await SetValue(Page, '#ChannelEntry', 'bad channel!');
await Page.click('#SaveChannelBtn'); await Wait(250);
Check('invalid channel rejected', /letters, numbers/.test(await Text('#StatusMessage')));
await SetValue(Page, '#ChannelEntry', 'zbeta');
await Page.click('#SaveChannelBtn'); await Wait(250);
Check('valid channel saved', (await Text('#StatusMessage')) === 'Channel updated', await Text('#StatusMessage'));
await Page.click('#SettingsToggle'); await Wait(450);
Check('settings fold away', await Page.$eval('#SettingsPanel', E => E.classList.contains('Collapsed')) && (await CallApi('GetSettings')).SettingsCollapsed === true);
await Page.click('#SettingsToggle');
Check('settings fold away', await WaitFor(async () => (await Page.$eval('#SettingsPanel', E => E.classList.contains('Collapsed'))) && (await CallApi('GetSettings')).SettingsCollapsed === true));
await Page.click('#SettingsToggle'); await Wait(450);

// ------------------------------------------------------------ configs + wizard
Expand Down Expand Up @@ -232,9 +231,9 @@ try {
// ------------------------------------------------------------ themes
Check('theme list has 4 themes', await Count('#ThemeSelect .CustomSelectOption') === 4 && await Count('#ThemeSelect .CustomSelectOption .ThemeSwatch') === 4 && await Count('#ThemeSelect .CustomSelectText .ThemeSwatch') === 0 && !!(await Page.$('#ActiveThemeSwatch')));
const DarkBg = await Bg();
await Promise.all([Page.waitForNavigation({ waitUntil: 'load' }), Pick('ThemeSelect', 'Light')]); await Wait(900);
Check('Light theme loads', (await Bg()) === 'rgb(228, 228, 228)' && (await Text('#ThemeSelect .CustomSelectText')) === '2016 Roblox', await Bg());
Check('Light uses its own stylesheet', await Page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--Accent').trim()) === '#00a2ff');
await Promise.all([Page.waitForNavigation({ waitUntil: 'load' }), Pick('ThemeSelect', 'Light')]);
Check('Light theme loads', await WaitFor(async () => (await Bg()) === 'rgb(228, 228, 228)' && (await Text('#ThemeSelect .CustomSelectText')) === '2016 Roblox'), await Bg());
Check('Light uses its own stylesheet', await WaitFor(async () => (await Page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--Accent').trim())) === '#00a2ff'));
await Shot('03-Light');
await Promise.all([Page.waitForNavigation({ waitUntil: 'load' }), Pick('ThemeSelect', 'MyCustomTheme')]); await Wait(900);
Check('MyCustomTheme loads', (await Bg()) === 'rgb(13, 15, 26)', await Bg());
Expand Down
34 changes: 34 additions & 0 deletions Production/RAMMIT-Stable/Tests/TestUiWaits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pathlib
import unittest

# The headless UI test must poll (WaitFor) for these checks, not sleep a fixed time, or it flakes on a busy PC.
POLLED_CHECKS = [
'selection persisted by username',
'settings saved',
'settings fold away',
'Light theme loads',
'Light uses its own stylesheet',
]

UI_TEST = pathlib.Path(__file__).with_name('TestUi.mjs')


class TestUiWaits(unittest.TestCase):
def test_polled_checks_use_waitfor_without_fixed_sleep(self):
lines = UI_TEST.read_text(encoding='utf-8').splitlines()
for label in POLLED_CHECKS:
with self.subTest(check=label):
start = f"Check('{label}'"
matches = [index for index, line in enumerate(lines) if start in line]
self.assertEqual(len(matches), 1, f"expected one line for {label}")
index = matches[0]
self.assertIn('WaitFor(', lines[index], f"Check '{label}' does not poll with WaitFor")
# The steps since the previous Check must not sleep a fixed time before this one looks.
for before in reversed(lines[:index]):
if 'Check(' in before:
break
self.assertNotIn('Wait(', before, f"Check '{label}' still has a fixed Wait() before it")


if __name__ == '__main__':
unittest.main()