diff options
Diffstat (limited to 'browser/components/shopping/tests/browser/browser_unanalyzed_product.js')
-rw-r--r-- | browser/components/shopping/tests/browser/browser_unanalyzed_product.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/browser/components/shopping/tests/browser/browser_unanalyzed_product.js b/browser/components/shopping/tests/browser/browser_unanalyzed_product.js new file mode 100644 index 0000000000..a28611cdbf --- /dev/null +++ b/browser/components/shopping/tests/browser/browser_unanalyzed_product.js @@ -0,0 +1,86 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Tests that the unanalyzed product card appears if a product has no analysis yet. + * Settings should be the only other component that is visible. + */ +add_task(async function test_unanalyzed_product() { + await BrowserTestUtils.withNewTab( + { + url: "about:shoppingsidebar", + gBrowser, + }, + async browser => { + let shoppingContainer = await getAnalysisDetails( + browser, + MOCK_UNANALYZED_PRODUCT_RESPONSE + ); + + ok( + shoppingContainer.unanalyzedProductEl, + "Got the unanalyzed-product-card element" + ); + + verifyAnalysisDetailsHidden(shoppingContainer); + verifyFooterVisible(shoppingContainer); + } + ); +}); + +/** + * Tests that the unanalyzed product card is hidden if a product already has an up-to-date analysis. + * Other analysis details should be visible. + */ +add_task(async function test_analyzed_product() { + await BrowserTestUtils.withNewTab( + { + url: "about:shoppingsidebar", + gBrowser, + }, + async browser => { + let shoppingContainer = await getAnalysisDetails( + browser, + MOCK_ANALYZED_PRODUCT_RESPONSE + ); + + ok( + !shoppingContainer.unanalyzedProductEl, + "unanalyzed-product-card should not be visible" + ); + + verifyAnalysisDetailsVisible(shoppingContainer); + verifyFooterVisible(shoppingContainer); + } + ); +}); + +/** + * Tests that the unanalyzed product card appears if a product has no grade, + * even if a product id is available. + * Settings should be the only other component that is visible. + */ +add_task(async function test_ungraded_product() { + await BrowserTestUtils.withNewTab( + { + url: "about:shoppingsidebar", + gBrowser, + }, + async browser => { + let shoppingContainer = await getAnalysisDetails( + browser, + MOCK_UNGRADED_PRODUCT_RESPONSE + ); + + ok( + shoppingContainer.unanalyzedProductEl, + "Got the unanalyzed-product-card element" + ); + + verifyAnalysisDetailsHidden(shoppingContainer); + verifyFooterVisible(shoppingContainer); + } + ); +}); |