Skip to content

Commit f6c6508

Browse files
committed
tests: adjust tests
1 parent 9cbee09 commit f6c6508

File tree

7 files changed

+76
-23
lines changed

7 files changed

+76
-23
lines changed

build-system-tests/e2e/cypress/integration/common/shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ Given(
2929
When('I click the {string} tab', (label: string) => {
3030
cy.findByRole('tab', {
3131
name: new RegExp(`^${escapeRegExp(label)}$`, 'i'),
32+
timeout: 5000,
3233
}).click();
3334
});
3435

3536
When('I click the {string} button', (name: string) => {
3637
cy.findByRole('button', {
3738
name: new RegExp(`^${escapeRegExp(name)}$`, 'i'),
39+
timeout: 5000,
3840
}).click();
3941
});
4042

4143
Then('I see the {string} button', (name: string) => {
4244
cy.findByRole('button', {
4345
name: new RegExp(`^${escapeRegExp(name)}$`, 'i'),
46+
timeout: 5000,
4447
}).should('be.visible');
4548
});
4649

packages/e2e/cypress/integration/common/fileuploader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ When('I select a file with file name {string}', (fileName: string) => {
77
When(
88
'I select a file with file name {string} and another file with file name {string}',
99
(fileName: string, fileName2: string) => {
10-
cy.fileInputUpload(fileName);
11-
cy.fileInputUpload(fileName2);
10+
cy.fileInputUpload([fileName, fileName2]);
1211
}
1312
);
1413

1514
When('I drag and drop a file with file name {string}', (fileName: string) => {
16-
cy.get('input[type=file]').trigger('drop', {
15+
const input = cy.get('input[type=file]', { timeout: 5000 }).wait(5000);
16+
input.trigger('drop', {
1717
dataTransfer: {
1818
files: [
1919
new File(['file contents'], fileName, { lastModified: Date.now() }),
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { Then, When } from '@badeball/cypress-cucumber-preprocessor';
22

33
When('I dismiss the banner', () => {
4-
cy.findByRole('button', { name: 'Dismiss message' }).click();
4+
cy.findByRole('button', { name: 'Dismiss message', timeout: 5000 }).click();
55
});
66

77
Then('I do not see the banner', () => {
8-
cy.findByRole('dialog').should('not.exist');
8+
cy.findByRole('dialog', { timeout: 5000 }).should('not.exist');
99
});
1010

1111
Then('the banner has {int} buttons', (buttonCount: number) => {
12+
const context = cy.findAllByRole('dialog');
1213
if (buttonCount > 0) {
13-
cy.findByRole('group').children().should('have.length', buttonCount);
14+
context
15+
.findByRole('group', { timeout: 5000 })
16+
.children()
17+
.should('have.length', buttonCount);
1418
} else {
15-
cy.findByRole('group').should('not.exist');
19+
context.findByRole('group', { timeout: 5000 }).should('not.exist');
1620
}
1721
});

packages/e2e/cypress/integration/common/shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <reference types="../../support/commands" />
44

55
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
6-
import { get, escapeRegExp } from 'lodash';
6+
import { escapeRegExp, get } from 'lodash';
77

88
let language = 'en-US';
99
let window = null;
@@ -290,6 +290,7 @@ When('I click the element with id attribute {string}', (id: string) => {
290290
When('I click the {string} button', (name: string) => {
291291
cy.findByRole('button', {
292292
name: new RegExp(`^${escapeRegExp(name)}$`, 'i'),
293+
timeout: 5000,
293294
}).click();
294295
});
295296

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
22

33
Given('{string} checkbox is checked', (checkboxName: string) => {
4-
cy.findByText(checkboxName)
5-
.next()
6-
.should('have.attr', 'data-checked', 'true');
4+
cy.findByRole('checkbox', { name: checkboxName, timeout: 5000 }).should(
5+
'be.checked'
6+
);
7+
});
8+
Given('{string} checkbox is unchecked', (checkboxName: string) => {
9+
cy.findByRole('checkbox', { name: checkboxName, timeout: 5000 }).should(
10+
'not.be.checked'
11+
);
712
});
813

9-
Given('{string} layout radio option is selected', (radioOption: string) => {
10-
cy.findByText(radioOption).next().should('have.attr', 'checked');
14+
Given('the {string} layout radio option is selected', (radioOption: string) => {
15+
cy.findByRole('radio', { name: radioOption, timeout: 5000 }).should(
16+
'be.checked'
17+
);
1118
});
1219

1320
When('I click the {string} layout radio option', (radioOption: string) => {
14-
cy.findByText(radioOption).click();
21+
cy.findByRole('radio', { name: radioOption, timeout: 5000 }).click();
1522
});
1623

1724
When('I toggle {string} checkbox', (checkboxName: string) => {
18-
cy.findByText(checkboxName).click();
25+
cy.findByRole('checkbox', { name: checkboxName, timeout: 5000 }).click();
1926
});
2027

2128
When('I wait for pinpoint messages to sync', () => {
@@ -28,17 +35,23 @@ When('I wait for pinpoint messages to sync', () => {
2835
});
2936

3037
Then('the banner has an image', () => {
31-
cy.findByRole('img', { name: 'In-App Message Image' }).should('exist');
38+
cy.findByRole('img', { name: 'In-App Message Image', timeout: 5000 }).should(
39+
'exist'
40+
);
3241
});
3342

3443
Then('I see a {string} banner dialog', (type: string) => {
35-
cy.findByRole('dialog')
44+
cy.findByRole('dialog', { timeout: 5000 })
3645
.should('exist')
3746
.should('have.attr', 'data-testid', `inappmessaging-${type}banner-dialog`);
3847
});
3948

4049
Then('I see a {string} dialog', (type: string) => {
41-
cy.findByRole('dialog')
50+
cy.findByRole('dialog', { timeout: 5000 })
4251
.should('exist')
4352
.should('have.attr', 'data-testid', `inappmessaging-${type}-dialog`);
4453
});
54+
55+
Then('I wait for {int} ms', (timeout: number) => {
56+
cy.wait(timeout);
57+
});

packages/e2e/cypress/support/commands.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,26 @@ Cypress.Commands.add('typeInInputHandler', (field: string, value: string) => {
9595
Cypress.Commands.add(
9696
'fileInputUpload',
9797
(
98-
fileName: string,
98+
fileName: string | string[],
9999
fileCount: number = 1,
100100
fileSize?: number,
101101
fileType?: string
102102
) => {
103+
let isArray = Array.isArray(fileName);
104+
if (isArray) {
105+
fileCount = fileName.length;
106+
}
103107
const folderFiles = [];
104108
for (let i = 1; i <= fileCount; i++) {
105109
folderFiles.push({
106110
contents: fileSize
107111
? Cypress.Buffer.alloc(fileSize)
108112
: Cypress.Buffer.from(`File ${i} content`),
109-
fileName: `${fileName}-${i}`,
113+
fileName: isArray ? fileName[i] : `${fileName}-${i}`,
110114
mimeType: fileType ?? 'text/plain',
111115
});
112116
}
113-
cy.get('input[type="file"]').selectFile(folderFiles, { force: true });
117+
const input = cy.get('input[type="file"]').wait(5000);
118+
input.selectFile(folderFiles, { force: true });
114119
}
115120
);

packages/e2e/features/ui/components/in-app-messaging/demo.feature

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ Feature: In-App Messaging demo page to show banners with various configurations
44

55
Background:
66
Given I'm running the example "ui/components/in-app-messaging/demo"
7+
Then I wait for 2000 ms
78

89
@react @react-native
910
Scenario: Verify that the default banner is top banner with primary and secondary buttons
1011
Given "Has Primary Button" checkbox is checked
1112
Then "Has Secondary Button" checkbox is checked
12-
Then "TOP_BANNER" layout radio option is selected
13+
Then the "TOP_BANNER" layout radio option is selected
14+
Then I see the "Display Demo Message" button
1315
When I click the "Display Demo Message" button
1416
Then I see a "top" banner dialog
1517
Then the banner has 2 buttons
@@ -18,13 +20,19 @@ Feature: In-App Messaging demo page to show banners with various configurations
1820

1921
@react @react-native
2022
Scenario: Verify that the banner has expected number of buttons
23+
Given "Has Primary Button" checkbox is checked
24+
Then "Has Secondary Button" checkbox is checked
2125
When I toggle "Has Secondary Button" checkbox
26+
Then "Has Secondary Button" checkbox is unchecked
27+
Then I see the "Display Demo Message" button
2228
Then I click the "Display Demo Message" button
2329
Then I see a "top" banner dialog
2430
Then the banner has 1 buttons
2531
When I dismiss the banner
2632
Then I do not see the banner
2733
When I toggle "Has Primary Button" checkbox
34+
Then "Has Primary Button" checkbox is unchecked
35+
Then I see the "Display Demo Message" button
2836
Then I click the "Display Demo Message" button
2937
Then I see a "top" banner dialog
3038
Then the banner has 0 buttons
@@ -34,31 +42,40 @@ Feature: In-App Messaging demo page to show banners with various configurations
3442
@react @react-native
3543
Scenario: Verify that the banner is shown as a bottom banner
3644
When I click the "BOTTOM_BANNER" layout radio option
45+
Then the "BOTTOM_BANNER" layout radio option is selected
46+
Then I see the "Display Demo Message" button
3747
Then I click the "Display Demo Message" button
3848
Then I see a "bottom" banner dialog
3949

4050
@react @react-native
4151
Scenario: Verify that the banner is shown as a middle banner
4252
When I click the "MIDDLE_BANNER" layout radio option
53+
Then the "MIDDLE_BANNER" layout radio option is selected
54+
Then I see the "Display Demo Message" button
4355
Then I click the "Display Demo Message" button
4456
Then I see a "middle" banner dialog
4557

4658
@react @react-native
4759
Scenario: Verify that the banner is shown as a modal
4860
When I click the "MODAL" layout radio option
61+
Then the "MODAL" layout radio option is selected
62+
Then I see the "Display Demo Message" button
4963
Then I click the "Display Demo Message" button
5064
Then I see a "modal" dialog
5165

5266
@react @react-native
5367
Scenario: Verify that the banner is shown as fullscreen
5468
When I click the "FULL_SCREEN" layout radio option
69+
Then the "FULL_SCREEN" layout radio option is selected
70+
Then I see the "Display Demo Message" button
5571
Then I click the "Display Demo Message" button
5672
Then I see a "fullscreen" dialog
5773

5874
@react @react-native
5975
Scenario: Verify that top banner is shown with an image
6076
Given "Has Image" checkbox is checked
61-
Then "TOP_BANNER" layout radio option is selected
77+
Then the "TOP_BANNER" layout radio option is selected
78+
Then I see the "Display Demo Message" button
6279
When I click the "Display Demo Message" button
6380
Then I see a "top" banner dialog
6481
Then the banner has an image
@@ -68,6 +85,8 @@ Feature: In-App Messaging demo page to show banners with various configurations
6885
When I toggle "Use Analytic events" checkbox
6986
Then I wait for pinpoint messages to sync
7087
Then I click the "TOP_BANNER" layout radio option
88+
Then the "TOP_BANNER" layout radio option is selected
89+
Then I see the "Display Demo Message" button
7190
Then I click the "Display Demo Message" button
7291
Then I see a "top" banner dialog
7392

@@ -76,6 +95,8 @@ Feature: In-App Messaging demo page to show banners with various configurations
7695
When I toggle "Use Analytic events" checkbox
7796
Then I wait for pinpoint messages to sync
7897
Then I click the "BOTTOM_BANNER" layout radio option
98+
Then the "BOTTOM_BANNER" layout radio option is selected
99+
Then I see the "Display Demo Message" button
79100
Then I click the "Display Demo Message" button
80101
Then I see a "bottom" banner dialog
81102

@@ -84,6 +105,8 @@ Feature: In-App Messaging demo page to show banners with various configurations
84105
When I toggle "Use Analytic events" checkbox
85106
Then I wait for pinpoint messages to sync
86107
Then I click the "MIDDLE_BANNER" layout radio option
108+
Then the "MIDDLE_BANNER" layout radio option is selected
109+
Then I see the "Display Demo Message" button
87110
Then I click the "Display Demo Message" button
88111
Then I see a "middle" banner dialog
89112

@@ -92,6 +115,8 @@ Feature: In-App Messaging demo page to show banners with various configurations
92115
When I toggle "Use Analytic events" checkbox
93116
Then I wait for pinpoint messages to sync
94117
Then I click the "MODAL" layout radio option
118+
Then the "MODAL" layout radio option is selected
119+
Then I see the "Display Demo Message" button
95120
Then I click the "Display Demo Message" button
96121
Then I see a "modal" dialog
97122

@@ -100,5 +125,7 @@ Feature: In-App Messaging demo page to show banners with various configurations
100125
When I toggle "Use Analytic events" checkbox
101126
Then I wait for pinpoint messages to sync
102127
Then I click the "FULL_SCREEN" layout radio option
128+
Then the "FULL_SCREEN" layout radio option is selected
129+
Then I see the "Display Demo Message" button
103130
Then I click the "Display Demo Message" button
104131
Then I see a "fullscreen" dialog

0 commit comments

Comments
 (0)