Path: blob/trunk/rb/spec/integration/selenium/webdriver/fedcm_spec.rb
4058 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require_relative 'spec_helper'2021module Selenium22module WebDriver23module FedCM24describe FedCM, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: %i[chrome edge]}] do25let(:dialog) { driver.fedcm_dialog }2627before { driver.get url_for('fedcm/fedcm.html') }28after { reset_driver! }2930context 'without dialog present' do31it 'throws an error' do32expect { dialog.title }.to raise_error(Error::NoSuchAlertError)33expect { dialog.subtitle }.to raise_error(Error::NoSuchAlertError)34expect { dialog.type }.to raise_error(Error::NoSuchAlertError)35expect { dialog.accounts }.to raise_error(Error::NoSuchAlertError)36expect { dialog.select_account(1) }.to raise_error(Error::NoSuchAlertError)37expect { dialog.cancel }.to raise_error(Error::NoSuchAlertError)38end39end4041context 'with dialog present' do42before do43driver.execute_script('triggerFedCm();')44driver.wait_for_fedcm_dialog45end4647it 'returns the title' do48expect(dialog.title).to eq('Sign in to localhost with localhost')49end5051it 'returns the subtitle' do52expect(dialog.subtitle).to be_nil53end5455it 'returns the type' do56expect(dialog.type).to eq('AccountChooser')57end5859it 'returns the accounts' do60first_account = dialog.accounts.first61expect(first_account.name).to eq 'John Doe'62end6364it 'selects an account' do65expect(dialog.select_account(1)).to be_nil66end6768it 'clicks the dialog', except: {browser: %i[chrome edge],69reason: "error: 'Use another account' not supported for this IDP"} do70expect(dialog.click).to be_nil71end7273it 'cancels the dialog' do74dialog.cancel75expect { dialog.title }.to raise_error(Error::NoSuchAlertError)76end7778it 'sets the delay' do79expect(driver.enable_fedcm_delay = true).to be_truthy80end8182it 'resets the cooldown' do83expect(driver.reset_fedcm_cooldown).to be_nil84end85end86end87end # FedCm88end # WebDriver89end # Selenium909192