Page MenuHomePhabricator

[Bug] As an anonymous user I get night theme enabled on pages where night mode should be disabled
Closed, ResolvedPublic1 Estimated Story Points

Description

Background

Due to complications arising from using two different storage mechanisms for some Vector 2022 features (user options for logged-in users and cookies via clientPreferences.js for anons) it was discovered that the night mode "exclude" feature does not work consistently for anonymous users. The "exclude" configuration, which should prevent some pages from appearing in dark mode, works for logged-in users, but not for anonymous user who have set a clientPreferences cookie via the Appearance menu.

Reproduction steps

  1. As an anonymous user, on https://en.wikipedia.beta.wmflabs.org/ ensure you have deleted the enwikimwclientpreferences cookie.
  2. Go to https://en.wikipedia.beta.wmflabs.org/wiki/Banana - the Appearance settings should be greyed out.
  3. Go to https://en.wikipedia.beta.wmflabs.org - change the appearanse menu settings to 'night mode'
  4. Go back to https://en.wikipedia.beta.wmflabs.org/wiki/Banana

expected

  • The Appearance menu settings should continue to be greyed out after you set the client-preferences cookie.

observed

  • The Appearance menu setting become available after setting the client-preferences cookie.

User story

  • When switching between logged-in and logged-out, I expect the same pages to be excluded from night mode.

Requirements

  • On pages that are excluded from night-mode via configuration (e.g. $wgVectorNightModeOptions['exclude']['mainpage'] = true) the night-mode settings in the Appearance menu should be greyed out for logged-in users, logged-out users, and when a logged-out or logged-in user changes the setting on a different page, then goes back to the excluded page, they should still be greyed out.

BDD

Feature: Night Mode Exclusion Logic

  Scenario: Night mode settings greyed out for logged-in users on excluded pages
    Given the user is logged into Wikipedia
    And the user navigates to a page excluded from night mode
    Then the night mode settings in the Appearance menu should be greyed out

  Scenario: Night mode settings greyed out for logged-out users on excluded pages
    Given the user is logged out of Wikipedia
    And the user navigates to a page excluded from night mode
    Then the night mode settings in the Appearance menu should be greyed out

  Scenario: Night mode settings persist for logged-out users when returning to an excluded page
    Given the user is logged out of Wikipedia
    And the user changes the night mode setting on a non-excluded page
    When the user returns to an excluded page
    Then the night mode settings in the Appearance menu should still be greyed out

  Scenario: Night mode settings persist for logged-in users when returning to an excluded page
    Given the user is logged into Wikipedia
    And the user changes the night mode setting on a non-excluded page
    When the user returns to an excluded page
    Then the night mode settings in the Appearance menu should still be greyed out

Test Steps

Test Case 1: Night Mode Settings Greyed Out for Logged-In Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Navigate to a page excluded from night mode.
  3. AC1: Confirm that the night mode settings in the Appearance menu are greyed out.

Test Case 2: Night Mode Settings Greyed Out for Logged-Out Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Navigate to a page excluded from night mode.
  3. AC2: Confirm that the night mode settings in the Appearance menu are greyed out.

Test Case 3: Night Mode Settings Persist for Logged-Out Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC3: Confirm that the night mode settings in the Appearance menu are still greyed out.

Test Case 4: Night Mode Settings Persist for Logged-In Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC4: Confirm that the night mode settings in the Appearance menu are still greyed out.

Design

  • Add mockups and design requirements

Acceptance criteria

  • If I am an anonymous user, and I have selected night mode from the appearance menu in Vector, then I go to a page that should have night mode disabled, e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Banana the night mode options should be disable in the appearance menu.

Communication criteria - does this need an announcement or discussion?

  • N/A

QA Results - Beta

Task Description:

QA Results - PROD

Event Timeline

Change #1026891 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/core@master] feature(core-skin): Preserve configured overrides in clientprefs.js

https://gerrit.wikimedia.org/r/1026891

Change #1026892 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/skins/Vector@master] feature(vector): Refine class handling for dark mode exclusions

https://gerrit.wikimedia.org/r/1026892

Jdlrobson renamed this task from Support overrides in ClientPreferences.js to [Bug] As an anonymous user I get night theme enabled on pages where night mode should be disabled.May 4 2024, 2:59 AM

Change #1027057 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Fixes: exclusion logic for anonymous users

https://gerrit.wikimedia.org/r/1027057

Could you please rephrase this ticket as a bug without biasing towards a different solution?

I believe this can be achieved via a patch in Vector (possibly https://gerrit.wikimedia.org/r/1026892 which needs a unit test to prove it) and we should attempt solving the issue here first before resorting to a change in the upstream API.

Change #1026891 abandoned by Mabualruz:

[mediawiki/core@master] feature(core-skin): Preserve configured overrides in clientprefs.js

Reason:

1027057 has a change without changes in core

https://gerrit.wikimedia.org/r/1026891

Change #1026892 abandoned by Mabualruz:

[mediawiki/skins/Vector@master] feature(vector): Refine class handling for dark mode exclusions

Reason:

1027057 has a change without changes in core

https://gerrit.wikimedia.org/r/1026892

Could you please rephrase this ticket as a bug without biasing towards a different solution?

@Jdlrobson sure thing. I was pretty sure we'd have to go into core to fix this, but it looks like with your patch we won't :) https://gerrit.wikimedia.org/r/1027057
I changed the task description to include some reproduction steps for this bug.

Change #1027057 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fixes: exclusion logic for anonymous users

https://gerrit.wikimedia.org/r/1027057

Change #1026891 restored by Mabualruz:

[mediawiki/core@master] feature(core-skin): Preserve configured overrides in clientprefs.js

https://gerrit.wikimedia.org/r/1026891

Edtadros subscribed.

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Sonoma
Browser: Chrome
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Night Mode Settings Greyed Out for Logged-In Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Navigate to a page excluded from night mode.
  3. AC1: Confirm that the night mode settings in the Appearance menu are greyed out.

screenshot 341.png (1×1 px, 461 KB)

Test Case 2: Night Mode Settings Greyed Out for Logged-Out Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Navigate to a page excluded from night mode.
  3. AC2: Confirm that the night mode settings in the Appearance menu are greyed out.

screenshot 342.png (1×1 px, 474 KB)

Test Case 3: Night Mode Settings Persist for Logged-Out Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC3: Confirm that the night mode settings in the Appearance menu are still greyed out.

screenshot 63.mov.gif (1×1 px, 1 MB)

Test Case 4: Night Mode Settings Persist for Logged-In Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC4: Confirm that the night mode settings in the Appearance menu are still greyed out.

screenshot 64.mov.gif (1×1 px, 1 MB)

Test Result - PROD

Status: ✅ PASS
Environment: PROD
OS: macOS Sonoma 14.4.1
Browser: Chrome 124
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Night Mode Settings Greyed Out for Logged-In Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Navigate to a page excluded from night mode.
  3. AC1: Confirm that the night mode settings in the Appearance menu are greyed out.

https://test.wikipedia.org/wiki/Banana?vectornightmode=1
https://en.wikipedia.org/wiki/Special:Preferences

Test.WikiPROD
2024-05-16_20-46-58.png (1×2 px, 704 KB)
2024-05-16_18-07-23.png (901×2 px, 246 KB)

Test Case 2: Night Mode Settings Greyed Out for Logged-Out Users on Excluded Pages

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Navigate to a page excluded from night mode.
  3. AC2: Confirm that the night mode settings in the Appearance menu are greyed out.

https://test.wikipedia.org/wiki/Banana?vectornightmode=1

2024-05-16_20-22-15.png (1×3 px, 790 KB)

Test Case 3: Night Mode Settings Persist for Logged-Out Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log out if logged in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC3: Confirm that the night mode settings in the Appearance menu are still greyed out.


Test Case 4: Night Mode Settings Persist for Logged-In Users When Returning to an Excluded Page

  1. Open Wikipedia on the Vector 2022 skin and log in.
  2. Change the night mode setting on a non-excluded page.
  3. Navigate back to a page excluded from night mode.
  4. AC4: Confirm that the night mode settings in the Appearance menu are still greyed out.

ovasileva claimed this task.
ovasileva subscribed.

Looks good and pages are appearing as expected