Skip to content

Commit

Permalink
fix: phone number input tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed Apr 16, 2024
1 parent 8bbeda6 commit 0019c0f
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 62 deletions.
3 changes: 2 additions & 1 deletion packages/blade/.storybook/react/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="https://unpkg.com/@razorpay/blade/fonts.css" rel="stylesheet">
<style>
/*
Expand Down Expand Up @@ -42,4 +43,4 @@
.css-1dt41f3 {
background-color: #111218 !important;
}
</style>
</style>
12 changes: 6 additions & 6 deletions packages/blade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@
"@razorpay/i18nify-react": "4.0.6",
"ts-node": "10.9.2",
"@testing-library/webdriverio": "3.2.1",
"@wdio/browserstack-service": "8.35.1",
"@wdio/local-runner": "8.35.1",
"@wdio/mocha-framework": "8.35.0",
"@wdio/globals": "8.35.1",
"@wdio/cli": "8.35.1",
"webdriverio": "8.35.1",
"@wdio/browserstack-service": "8.36.0",
"@wdio/local-runner": "8.36.0",
"@wdio/mocha-framework": "8.36.0",
"@wdio/globals": "8.36.0",
"@wdio/cli": "8.36.0",
"webdriverio": "8.36.0",
"chai": "5.1.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-floating-promises */
import { expect, browser } from '@wdio/globals';
Expand All @@ -7,14 +8,16 @@ import { Key } from 'webdriverio';
const goTo = async (test: string): Promise<void> => {
await browser.url(`?args=&id=${test}&viewMode=story`);
await browser.waitUntil(async () => (await browser.getTitle()).match(test), {
timeout: 5000,
timeout: 20000,
});
};

const label = 'Phone Number';

describe('PhoneNumberInput', () => {
it('Should select a country', async () => {
it.skip('Should select a country', async () => {
if (browser.isMobile) return;

await goTo('components-e2e-tests-phonenumberinput--select-a-country');
const { getByLabelText, getByRole, queryByRole } = setupBrowser(browser);

Expand Down Expand Up @@ -61,6 +64,8 @@ describe('PhoneNumberInput', () => {
await input.setValue('1234567890');

// Ensure the value of the input updates
// Some issue with iOS wdio, toHaveValue is not working
// https://github.com/webdriverio/webdriverio/issues/7039
await expect(input).toHaveValue('1234567890');

// expect onChange to be called
Expand Down Expand Up @@ -88,9 +93,12 @@ describe('PhoneNumberInput', () => {
await expect(input).toHaveValue('9876543210');

// Type inside input
// browser.keys doesn't work on iOS for some reason
// related issue: https://github.com/appium/appium/issues/19670
const length = (await input.getValue()).length;
const backSpaces = new Array(length).fill(Key.Backspace);
await browser.keys(backSpaces);
for (let i = 0; i < length; i++) {
await driver.elementSendKeys(input.elementId, Key.Backspace);
}
await input.setValue('1234567890');

// Ensure the value of the input updates
Expand All @@ -112,6 +120,7 @@ describe('PhoneNumberInput', () => {
const { getByLabelText } = setupBrowser(browser);

const input = await getByLabelText(label);

await expect(input).toHaveValue('');

// Ensure the input is disabled
Expand Down
9 changes: 3 additions & 6 deletions packages/blade/wdio.bstack.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { config as baseConfig } from './wdio.base.conf.js';
const commonCapabilities = {
buildName: 'blade browserstack build',
buildIdentifier: '#${BUILD_NUMBER}',
appiumVersion: '2.4.1',
};

const bstackConfig: Options.Testrunner = {
Expand All @@ -19,6 +20,8 @@ const bstackConfig: Options.Testrunner = {
{
buildIdentifier: '#${BUILD_NUMBER}',
browserstackLocal: true,
// set appium version
appiumVersion: '2.4.1',
},
],
],
Expand Down Expand Up @@ -83,10 +86,4 @@ const bstackConfig: Options.Testrunner = {

const config = { ...baseConfig, ...bstackConfig };

// Code to support common capabilities
// config.capabilities.forEach(function (caps) {
// for (const i in exports.config.commonCapabilities)
// caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i] };
// });

export { config };
2 changes: 1 addition & 1 deletion packages/blade/wdio.local.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const localConfig: Options.Testrunner = {
capabilities: [
{
browserName: 'chrome',
browserVersion: '121',
browserVersion: 'latest',
},
{
browserName: 'firefox',
Expand Down
Loading

0 comments on commit 0019c0f

Please sign in to comment.