Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

2.6 KB
Raw Blame
"""Noindex drift follows robots directives, including the none shorthand."""

import sys
from pathlib import Path

import pytest

sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))

from drift_compare import rule_04_noindex_added  # noqa: E402


@pytest.mark.parametrize("current", ["none", "NONE", " none , max-snippet:0"])
def test_none_added_blocks_indexing(current):
    result = rule_04_noindex_added({"robots": "index, follow"}, {"meta_robots": current})
    assert result["triggered"] is True
    assert result["severity"] == "CRITICAL"


@pytest.mark.parametrize("previous", ["none", "NONE", "noindex, nofollow"])
def test_equivalent_existing_restriction_is_not_new(previous):
    result = rule_04_noindex_added({"robots": previous}, {"meta_robots": "noindex"})
    assert result["triggered"] is False


@pytest.mark.parametrize("current", [
    "max-image-preview:none", "max-image-preview: none",
    "max-image-preview: none, follow", "not-noindex", "index, follow",
])
def test_values_or_substrings_are_not_noindex_directives(current):
    assert rule_04_noindex_added({}, {"meta_robots": current})["triggered"] is False


def test_comma_separated_noindex_still_triggers():
    assert rule_04_noindex_added({}, {"meta_robots": "follow, NOINDEX"})["triggered"] is True


@pytest.mark.parametrize("current", [
    "follow none", "max-image-preview: none noindex",
    "max-image-preview: none, NOINDEX",
])
def test_parameter_values_do_not_hide_an_independent_directive(current):
    assert rule_04_noindex_added({}, {"meta_robots": current})["triggered"] is True


def test_previous_parameter_value_does_not_hide_a_new_restriction():
    assert rule_04_noindex_added(
        {"robots": "max-image-preview: none"}, {"meta_robots": "none"},
    )["triggered"] is True


@pytest.mark.parametrize("current", [
    "noindex;nofollow", "index; NOINDEX", "follow;none",
    "max-image-preview:none;noindex", "max-snippet:0; noindex",
])
def test_semicolon_separated_noindex_triggers(current):
    assert rule_04_noindex_added({"robots": "index, follow"}, {"meta_robots": current})["triggered"] is True


def test_semicolon_separated_existing_restriction_is_not_new():
    result = rule_04_noindex_added({"robots": "noindex;nofollow"}, {"meta_robots": "noindex, nofollow"})
    assert result["triggered"] is False


@pytest.mark.parametrize("current", ["max-image-preview:none;follow", "index;follow", "max-snippet:0;max-image-preview: none"])
def test_semicolons_do_not_turn_parameter_values_into_directives(current):
    assert rule_04_noindex_added({}, {"meta_robots": current})["triggered"] is False