Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] chore(storage-browser): add Loading state e2e tests for storage browser #5743

Draft
wants to merge 31 commits into
base: feat-storage-browser/main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f63a675
chore(storage-browser): set up e2e tests for storage browser
timngyn Aug 23, 2024
d712b0a
remove unused variable
timngyn Aug 23, 2024
1bd1f93
remove unused var
timngyn Aug 23, 2024
867df3e
Merge branch 'feat-storage-browser/main' into feat-storage-browser/e2…
timngyn Aug 28, 2024
83fdc3b
add e2e tests for create folder
timngyn Aug 28, 2024
a93eb9e
add e2e tests for navigate control
timngyn Aug 28, 2024
0d80349
remove render-storage-browser.feature
timngyn Aug 28, 2024
5c4bcee
add e2e tests for download file
timngyn Aug 28, 2024
c96c5a9
Merge branch 'feat-storage-browser/main' into feat-storage-browser/e2…
jordanvn Aug 30, 2024
e583231
chore: add tests for 403 response and error boundary to forbidden act…
jordanvn Sep 3, 2024
143cc08
chore: making more generic references to button contents
jordanvn Sep 3, 2024
050ea17
chore: temporarily removing status code validation prior to cleaner a…
jordanvn Sep 3, 2024
7c0287e
chore: restoring resolution to unauthed tests with cleaner solution
jordanvn Sep 3, 2024
5ebdece
Merge branch 'feat-storage-browser/main' into feat-storage-browser/e2…
jordanvn Sep 3, 2024
18c3d4c
chore: removing file download test for now to ensure passing pipeline…
jordanvn Sep 3, 2024
f4daeb2
chore: add newline charactersd
jordanvn Sep 4, 2024
b72bfef
chore: adding additional newline character
jordanvn Sep 4, 2024
7100d81
loading e2e tests for storage browser
hbuchel Sep 4, 2024
9c43991
new line
hbuchel Sep 4, 2024
c689570
updates
hbuchel Sep 4, 2024
9bd0047
Merge branch 'feat-storage-browser/main' into feat-storage-browser/e2…
hbuchel Sep 5, 2024
36aa6cc
updates
hbuchel Sep 5, 2024
6686884
Merge branch 'feat-storage-browser/e2e-storage-browser' into feat-sto…
hbuchel Sep 5, 2024
6768e01
test
hbuchel Sep 5, 2024
b9c140b
use step file
hbuchel Sep 5, 2024
f78ea18
Merge branch 'feat-storage-browser/main' into feat-storage-browser/e2…
hbuchel Sep 5, 2024
dfa759c
Merge branch 'feat-storage-browser/e2e-storage-browser' into feat-sto…
hbuchel Sep 5, 2024
53fa02c
increase delay time for ci
hbuchel Sep 6, 2024
f082af2
increase delay
hbuchel Sep 6, 2024
f0439eb
change when we intercept requests for delay
hbuchel Sep 6, 2024
ba6f2a1
increase delay
hbuchel Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
cypress/fixtures/example.json
cypress/screenshots
cypress/videos
cypress/downloads

detox/screenshots

Expand Down
34 changes: 34 additions & 0 deletions packages/e2e/cypress/integration/common/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ const typeInInputHandler = (field: string, value: string) => {
};
When('I type a new {string} with value {string}', typeInInputHandler);

When('I lose focus on {string} input', (field: string) => {
cy.findInputField(field).blur();
});

When('I click the {string} tab', (label: string) => {
cy.findByRole('tab', {
name: new RegExp(`^${escapeRegExp(label)}$`, 'i'),
Expand All @@ -244,6 +248,18 @@ When('I click the {string} button', (name: string) => {
}).click();
});

When('I click the button containing {string}', (name: string) => {
cy.findByRole('button', {
name: new RegExp(`${escapeRegExp(name)}`, 'i'),
}).click();
});

Then('I see the button containing {string}', (name: string) => {
cy.findByRole('button', {
name: new RegExp(`${escapeRegExp(name)}`, 'i'),
}).should('exist');
});

Then('I see the {string} button', (name: string) => {
cy.findByRole('button', {
name: new RegExp(`^${escapeRegExp(name)}$`, 'i'),
Expand All @@ -256,6 +272,18 @@ Then('I do not see the {string} button', (name: string) => {
}).should('not.exist');
});

When('I click the {string} menuitem', (label: string) => {
cy.findByRole('menuitem', {
name: new RegExp(`^${escapeRegExp(label)}$`, 'i'),
}).click();
});

Then('I see the {string} menuitem', (label: string) => {
cy.findByRole('menuitem', {
name: new RegExp(`^${escapeRegExp(label)}$`, 'i'),
}).should('exist');
});

When('I click the {string} checkbox', (label: string) => {
cy.findByLabelText(new RegExp(`^${escapeRegExp(label)}`, 'i')).click({
// We have to force this click because the checkbox button isn't visible by default
Expand Down Expand Up @@ -286,6 +314,12 @@ Then('I see {string}', (message: string) => {
.should('exist');
});

Then('I do not see {string}', (message: string) => {
cy.findByRole('document')
.contains(new RegExp(escapeRegExp(message), 'i'))
.should('not.exist');
});

Then('I see {string} element', (id: string) => {
cy.findByTestId(id).should('exist');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';
import { escapeRegExp } from 'lodash';

When(
'I click the button containing {string} on a slow connection',
(name: string) => {
cy.intercept({ method: 'GET', query: { 'list-type': '2' } }, (req) => {
req.on('response', (res) => {
res.setDelay(5000);
});
});

cy.findByRole('button', {
name: new RegExp(`${escapeRegExp(name)}`, 'i'),
}).click();
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Create folder with Storage Browser

Background:
Given I'm running the example "ui/components/storage/storage-browser/default-auth"

@react
Scenario: Create folder
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
When I click the button containing "public"
Then I see the "Actions" button
When I click the "Actions" button
Then I see the "Create Folder" menuitem
When I click the "Create Folder" menuitem
Then I see "Enter folder name:"
Then I see the "Create Folder" button
Then the "Create Folder" button is disabled
When I type a new "Enter folder name:" with value "Blackberry"
Then I see the "Create Folder" button
When I click the "Create Folder" button
Then I see "Folder created."


@react
Scenario: Create folder input shows error message when folder name contains "/"
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
When I click the button containing "public"
Then I see the "Actions" button
When I click the "Actions" button
Then I see the "Create Folder" menuitem
When I click the "Create Folder" menuitem
Then I see "Enter folder name:"
Then I see the "Create Folder" button
Then the "Create Folder" button is disabled
When I type a new "Enter folder name:" with value "Blackberry/"
When I lose focus on "Enter folder name:" input
Then I see "Folder name must be at least one character and cannot contain a \"/\"."
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: Storage Browser uses error boundry

Background:
Given I'm running the example "ui/components/storage/storage-browser/default-auth"

@react
Scenario: Attempt to access forbidden folder
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I see the "Sign in" button
When I click the "Sign in" button
When I click the button containing "forbidden"
Then I see "no identity-based policy allows the s3:ListBucket action"


@react
Scenario: Attempt to add folder without write access
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I see the "Sign in" button
When I click the "Sign in" button
When I click the button containing "forbidden"
Then I see the "Actions" button
When I click the "Actions" button
Then I see the "Create Folder" menuitem
When I click the "Create Folder" menuitem
Then I see "Enter folder name:"
Then I see the "Create Folder" button
Then the "Create Folder" button is disabled
When I type a new "Enter folder name:" with value "Blackberry"
Then I see the "Create Folder" button
When I click the "Create Folder" button
Then I see "no identity-based policy allows the s3:PutObject action"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Feature: Storage Browser denied access without sufficient permissions

Background:
Given I'm running the example "ui/components/storage/storage-browser/default-auth"

@react
Scenario: Attempt to access forbidden folder
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I see the "Sign in" button
When I click the "Sign in" button
When I click the button containing "forbidden"
Then I don't see "amplify-table"

@react
Scenario: Attempt to add folder without write access
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I see the "Sign in" button
When I click the "Sign in" button
When I click the button containing "forbidden"
Then I see the "Actions" button
When I click the "Actions" button
Then I see the "Create Folder" menuitem
When I click the "Create Folder" menuitem
Then I see "Enter folder name:"
Then I see the "Create Folder" button
Then the "Create Folder" button is disabled
When I type a new "Enter folder name:" with value "Blackberry"
Then I see the "Create Folder" button
When I click the "Create Folder" button
Then I do not see "Folder created."
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: (Default Auth) Loading spinner on Storage Browser views

Background:
Given I'm running the example "ui/components/storage/storage-browser/default-auth"

@react
Scenario: Loading spinner on LocationDetailView
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
Then I click the button containing "public" on a slow connection
Then I see "Loading"

@react
Scenario: Loading spinner on LocationDetailView after using the Refresh control
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
Then I click the button containing "public"
Then I click the button containing "Refresh table" on a slow connection
Then I see "Loading"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: (Managed Auth) Loading spinner on Storage Browser views

Background:
Given I'm running the example "ui/components/storage/storage-browser/managed-auth"

@react
Scenario: Loading spinner on LocationDetailView


@react
Scenario: Loading spinner on LocationDetailView after using the Refresh control

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Feature: Storage Browser navigate breadcrumbs

Background:
Given I'm running the example "ui/components/storage/storage-browser/default-auth"

@react
Scenario: Navigate back to Home
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
When I click the button containing "public"
Then I see the "Home" button
When I click the "Home" button
Then I see "HOME"
Then I see the button containing "public"

@react
Scenario: Navigate back up to prefix
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
When I click the button containing "public"
Then I see the "Blueberry/" button
When I click the "Blueberry/" button
Then I see "Blackberry/"
When I click the "Blackberry/" button
Then I see "Blueberry/"
When I click the "Blueberry" button
Then I see "Blueberry/"

@react
Scenario: Navigate to parent folder from nested child folder
When I type my "email" with status "CONFIRMED"
Then I type my password
Then I click the "Sign in" button
When I click the button containing "public"
Then I see the "Blueberry/" button
When I click the "Blueberry/" button
Then I see the "Acai/" button
When I click the "Acai/" button
Then I see "Acai/"
Then I see the "Blueberry" button
When I click the "Blueberry" button
Then I see "Blueberry/"
Loading