|
| 1 | +# Copyright 2025 Snowflake Inc. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +"""End-to-end coverage for Tier 1 column_config keys: label, help, width, pinned.""" |
| 17 | + |
| 18 | +from __future__ import annotations |
| 19 | + |
| 20 | +from playwright.sync_api import Page, expect |
| 21 | + |
| 22 | +from e2e_utils import get_pivot |
| 23 | + |
| 24 | + |
| 25 | +def test_column_config_label_row_dim(page_at_app: Page): |
| 26 | + """column_config.label renames a row dimension header without changing the |
| 27 | + underlying field id.""" |
| 28 | + page = page_at_app |
| 29 | + container = get_pivot(page, "test_pivot_cc_label") |
| 30 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 31 | + |
| 32 | + row_dim = container.get_by_test_id("pivot-row-dim-label-Region") |
| 33 | + expect(row_dim).to_contain_text("Area") |
| 34 | + expect(row_dim).not_to_contain_text("Region (") |
| 35 | + |
| 36 | + |
| 37 | +def test_column_config_label_measure(page_at_app: Page): |
| 38 | + """column_config.label renames a measure header.""" |
| 39 | + page = page_at_app |
| 40 | + container = get_pivot(page, "test_pivot_cc_label") |
| 41 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 42 | + |
| 43 | + thead = container.locator("thead") |
| 44 | + expect(thead).to_contain_text("Rev") |
| 45 | + |
| 46 | + |
| 47 | +def test_column_config_help_tooltip_row_dim(page_at_app: Page): |
| 48 | + """column_config.help flows through as a title attribute on the row dim header.""" |
| 49 | + page = page_at_app |
| 50 | + container = get_pivot(page, "test_pivot_cc_help") |
| 51 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 52 | + |
| 53 | + row_dim = container.get_by_test_id("pivot-row-dim-label-Region") |
| 54 | + expect(row_dim).to_have_attribute("title", "Geographic region") |
| 55 | + |
| 56 | + |
| 57 | +def test_column_config_help_tooltip_measure(page_at_app: Page): |
| 58 | + """column_config.help flows through as a title attribute on a measure header.""" |
| 59 | + page = page_at_app |
| 60 | + container = get_pivot(page, "test_pivot_cc_help") |
| 61 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 62 | + |
| 63 | + measure_cell = container.locator( |
| 64 | + '[data-testid="pivot-header-cell"][title="Revenue in USD"]' |
| 65 | + ).first |
| 66 | + expect(measure_cell).to_be_visible() |
| 67 | + |
| 68 | + |
| 69 | +def test_column_config_width_pixel(page_at_app: Page): |
| 70 | + """column_config.width with a pixel integer applies to the row dim header.""" |
| 71 | + page = page_at_app |
| 72 | + container = get_pivot(page, "test_pivot_cc_width_px") |
| 73 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 74 | + |
| 75 | + row_dim = container.get_by_test_id("pivot-row-dim-label-Region") |
| 76 | + style = row_dim.get_attribute("style") or "" |
| 77 | + assert "width: 180px" in style, f"expected 180px width, got style={style!r}" |
| 78 | + |
| 79 | + |
| 80 | +def test_column_config_width_preset(page_at_app: Page): |
| 81 | + """column_config.width with a preset string maps to documented pixel values.""" |
| 82 | + page = page_at_app |
| 83 | + container = get_pivot(page, "test_pivot_cc_width_preset") |
| 84 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 85 | + |
| 86 | + row_dim = container.get_by_test_id("pivot-row-dim-label-Region") |
| 87 | + style = row_dim.get_attribute("style") or "" |
| 88 | + assert "width: 200px" in style, f"expected 'large' -> 200px, got style={style!r}" |
| 89 | + |
| 90 | + |
| 91 | +def test_column_config_pinned_locks_in_config_ui(page_at_app: Page): |
| 92 | + """column_config.pinned=True locks the field in the config UI (same behavior |
| 93 | + as frozen_columns): the chip renders but its remove (×) button is absent.""" |
| 94 | + page = page_at_app |
| 95 | + container = get_pivot(page, "test_pivot_cc_pinned") |
| 96 | + expect(container.get_by_test_id("pivot-table")).to_be_visible(timeout=15000) |
| 97 | + |
| 98 | + chip = container.get_by_test_id("toolbar-rows-chip-Region") |
| 99 | + expect(chip).to_be_visible(timeout=5000) |
| 100 | + remove_btn = container.get_by_test_id("toolbar-rows-remove-Region") |
| 101 | + expect(remove_btn).to_have_count(0) |
0 commit comments