mirror of
https://github.com/Ujwal223/FocusGram.git
synced 2026-07-02 17:35:46 +02:00
Feature Pack with bug fixes for V2
This commit is contained in:
@@ -5,20 +5,22 @@ import 'package:focusgram/scripts/focus_scripts.dart';
|
||||
|
||||
void main() {
|
||||
group('FocusSettings — Field cleanup', () {
|
||||
test('only ghostMode remains (fullDmGhost and storyGhost removed)',
|
||||
() async {
|
||||
const settings = FocusSettings(ghostMode: true);
|
||||
test(
|
||||
'only ghostMode remains (fullDmGhost and storyGhost removed)',
|
||||
() async {
|
||||
const settings = FocusSettings(ghostMode: true);
|
||||
|
||||
expect(settings.ghostMode, isTrue);
|
||||
expect(settings.noAds, isTrue);
|
||||
expect(settings.noStories, isFalse);
|
||||
expect(settings.noReels, isFalse);
|
||||
expect(settings.noAutoplay, isFalse);
|
||||
expect(settings.noDMs, isFalse);
|
||||
expect(settings.ghostMode, isTrue);
|
||||
expect(settings.noAds, isTrue);
|
||||
expect(settings.noStories, isFalse);
|
||||
expect(settings.noReels, isFalse);
|
||||
expect(settings.noAutoplay, isFalse);
|
||||
expect(settings.noDMs, isFalse);
|
||||
|
||||
// Verify fullDmGhost and storyGhost are NOT fields anymore
|
||||
// (these would be compile errors if they existed)
|
||||
});
|
||||
// Verify fullDmGhost and storyGhost are NOT fields anymore
|
||||
// (these would be compile errors if they existed)
|
||||
},
|
||||
);
|
||||
|
||||
test('default ghostMode is false', () async {
|
||||
const settings = FocusSettings();
|
||||
@@ -48,13 +50,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('does NOT inject ghost scripts when ghostMode is false', () async {
|
||||
final scripts =
|
||||
buildUserScripts(const FocusSettings(ghostMode: false));
|
||||
final scripts = buildUserScripts(const FocusSettings(ghostMode: false));
|
||||
|
||||
// Should have no DOCUMENT_START scripts
|
||||
final startScripts =
|
||||
scripts.where((s) =>
|
||||
s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_START);
|
||||
final startScripts = scripts.where(
|
||||
(s) => s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||
);
|
||||
for (final s in startScripts) {
|
||||
expect(s.source.contains('__fgFullDmGhost'), isFalse);
|
||||
}
|
||||
@@ -65,28 +66,28 @@ void main() {
|
||||
const FocusSettings(ghostMode: true, noAutoplay: true),
|
||||
);
|
||||
|
||||
final startScripts =
|
||||
scripts.where((s) =>
|
||||
s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_START);
|
||||
final startScripts = scripts.where(
|
||||
(s) => s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||
);
|
||||
expect(startScripts.length, equals(1));
|
||||
expect(startScripts.first.source, contains('__fgFullDmGhost=true'));
|
||||
expect(startScripts.first.source, contains('document.addEventListener'));
|
||||
});
|
||||
|
||||
test('injects hideStoryTray at DOCUMENT_END when noStories is true',
|
||||
() async {
|
||||
final scripts = buildUserScripts(
|
||||
const FocusSettings(noStories: true),
|
||||
);
|
||||
test(
|
||||
'injects hideStoryTray at DOCUMENT_END when noStories is true',
|
||||
() async {
|
||||
final scripts = buildUserScripts(const FocusSettings(noStories: true));
|
||||
|
||||
final endScripts =
|
||||
scripts.where((s) =>
|
||||
s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_END);
|
||||
expect(endScripts.length, equals(1));
|
||||
expect(
|
||||
endScripts.first.source,
|
||||
contains('[data-pagelet="story_tray"]'),
|
||||
);
|
||||
});
|
||||
final endScripts = scripts.where(
|
||||
(s) => s.injectionTime == UserScriptInjectionTime.AT_DOCUMENT_END,
|
||||
);
|
||||
expect(endScripts.length, equals(1));
|
||||
expect(
|
||||
endScripts.first.source,
|
||||
contains('[data-pagelet="story_tray"]'),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user