<commit_before>﻿// Copyright (c) p<NAME> <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.News.Sidebar;

namespace osu.Game.Tests.Visual.Online
{
    public class TestSceneNewsSidebar : OsuTestScene
    {
        [Cached]
        private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);

        private NewsSidebar sidebar;

        [SetUp]
        public void SetUp() => Schedule(() => Child = sidebar = new NewsSidebar());

        [Test]
        public void TestYearsPanelVisibility()
        {
            AddUntilStep("Years panel is hidden", () => yearsPanel?.Alpha == 0);
            AddStep("Add data", () => sidebar.Metadata.Value = metadata);
            AddUntilStep("Years panel is visible", () => yearsPanel?.Alpha == 1);
        }

        [Test]
        public void TestMetadataWithNoPosts()
        {
            AddStep("Add data with no posts", () => sidebar.Metadata.Value = metadata_with_no_posts);
            AddUntilStep("No dropdowns were created", () => !sidebar.ChildrenOfType<MonthSection>().Any());
        }

        private YearsPanel yearsPanel => sidebar.ChildrenOfType<YearsPanel>().FirstOrDefault();

        private static readonly APINewsSidebar metadata = new APINewsSidebar
        {
            CurrentYear = 2021,
            Years = new[]
            {
                2021,
                2020,
                2019,
                2018,
                2017,
                2016,
                2015,
                2014,
                2013<commit_msg>Reorder tests to not have the first test show nothing<commit_after>﻿// Copyright (c) <NAME> <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.News.Sidebar;

namespace osu.Game.Tests.Visual.Online
{
    public class TestSceneNewsSidebar : OsuTestScene
    {
        [Cached]
        private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);

        private NewsSidebar sidebar;

        [SetUp]
        public void SetUp() => Schedule(() => Child = sidebar = new NewsSidebar());

        [Test]
        public void TestMetadataWithNoPosts()
        {
            AddStep("Add data with no posts", () => sidebar.Metadata.Value = metadata_with_no_posts);
            AddUntilStep("No dropdowns were created", () => !sidebar.ChildrenOfType<MonthSection>().Any());
        }

        [Test]
        public void TestYearsPanelVisibility()
        {
            AddUntilStep("Years panel is hidden", () => yearsPanel?.Alpha == 0);
            AddStep("Add data", () => sidebar.Metadata.Value = metadata);
            AddUntilStep("Years panel is visible", () => yearsPanel?.Alpha == 1);
        }

        private YearsPanel yearsPanel => sidebar.ChildrenOfType<YearsPanel>().FirstOrDefault();

        private static readonly APINewsSidebar metadata = new APINewsSidebar
        {
            CurrentYear = 2021,
            Years = new[]
            {
                2021,
                2020,
                2019,
                2018,
                2017,
                2016,
                2015,
                2014,
                2013
{'fraction_non_alphanumeric': 0.10119205298013245, 'fraction_numerical': 0.022251655629139073, 'mean_word_length': 2.2163543441226574, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3516561', 'n_tokens_mistral': 1086, 'n_tokens_neox': 995, 'n_words': 258}