Skip to content

Commit

Permalink
e2e(4259): adapt tests to new components and refactor delete test
Browse files Browse the repository at this point in the history
  • Loading branch information
funtigr committed Nov 16, 2024
1 parent c78704f commit ad7daf1
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/components/generic/input/FormDollarInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function FormDollarInput({
if (!id) id = _kebabCase(name);

return (
<div className={classNames?.wrapper}>
<div className={cn('dollar-input', classNames?.wrapper)}>
{label && (
<Label
htmlFor={id}
Expand Down
2 changes: 1 addition & 1 deletion app/components/generic/input/FormTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function FormTextInput({
if (!id) id = _kebabCase(name);

return (
<div className={classNames?.wrapper}>
<div className={cn('text-input', classNames?.wrapper)}>
{label && (
<Label
htmlFor={id}
Expand Down
2 changes: 1 addition & 1 deletion app/components/generic/input/FormTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function FormTextarea({
const _ref = useRef<HTMLTextAreaElement>(null);

return (
<div className={classNames?.wrapper}>
<div className={cn('textarea', classNames?.wrapper)}>
{label && (
<Label
htmlFor={id}
Expand Down
17 changes: 0 additions & 17 deletions cypress/_tmp/delete-product-test.feature

This file was deleted.

4 changes: 2 additions & 2 deletions cypress/integration/1. create-request-private-test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Feature: New Request
And User clicks tab "Common components"
And User checks checkbox "The app does not use..."
And User makes a screenshot
And User clicks button "SUBMIT REQUEST"
And User checks checkbox "By checking this box..."
And User clicks button "Submit"
And User checks checkbox "By checking this box..."
And User clicks modal window button "Submit"
And User clicks modal window button "Close"
Then User should be redirected to Requests tab
And User should see "Automated Test Product Name"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: New Request
Given User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
And User waits for "3" seconds
When User clicks tab "PUBLIC CLOUD LANDING ZONES"
And User clicks button "REQUEST A NEW PRODUCT"
And User clicks button "Request a new product"
And User types "Automated Test Product Name" in "Product name"
And User types "Automated Test Description" in "Description"
And User selects "Citizens Services" in "Ministry"
Expand All @@ -30,7 +30,7 @@ Feature: New Request
And User types "78901" in "Service Line (SL)"
And User types "2345" in "Standard Object of Expense (STOB)"
And User types "6789012" in "Project Code"
And User clicks button "SUBMIT REQUEST"
And User clicks button "Submit"
And User checks checkbox "No eMOU exists for this account coding."
And User checks checkbox "...team is liable to pay the base charge..."
And User clicks modal window button "Submit"
Expand Down
49 changes: 49 additions & 0 deletions cypress/integration/3. delete-product-test.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Feature: Delete Request
Scenario: Delete Request and check visibility
Given User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
When User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks button "Request a new product"
And User types "Automated Test Product Name" in "Product name"
And User types "Automated Test Description" in "Description"
And User selects "Citizens Services" in "Ministry"
And User clicks and selects "SILVER" in "Hosting tier"
And User clicks tab "Team contacts"
And User types and selects "james.smith@gov.bc.ca" in "Product Owner email"
And User waits for "2" seconds
And User types and selects "john.doe@gov.bc.ca" in "Technical Lead email"
And User clicks tab "Common components"
And User checks checkbox "The app does not use..."
And User makes a screenshot
And User clicks button "Submit"
And User checks checkbox "By checking this box..."
And User clicks modal window button "Submit"
And User clicks modal window button "Close"
Then User should be redirected to Requests tab
And User should see "Automated Test Product Name"
And User logs out
And User logs in with username "private.reviewer.system@gov.bc.ca" and password "private.reviewer.system@gov.bc.ca"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User waits for "3" seconds
And User clicks tab "Requests"
And User waits for "3" seconds
And User clicks link "Automated Test Product Name"
And User clicks button "Approve"
And User clicks modal window button "Submit"
And User clicks modal window button "Return to Dashboard"
And User logs out
And User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks link "Automated Test Product Name"
And User waits for "10" seconds
And User clicks button "Delete"
And User copies value of "Licence plate"
And User pastes from clipboard to "Licence plate number"
And User copies value of "Product Owner"
And User pastes from clipboard to "Product owner email"
And User clicks modal window button "Submit"
And User clicks button "Close"
And User clicks tab "Requests"
Then User should see "Automated Test Product Name"
And User should see badge "DELETE"
And User logs out
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Requests Review
Background:
Given User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
When User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks button "REQUEST A NEW PRODUCT"
And User clicks button "Request a new product"
And User types "Automated Test Product Name" in "Product name"
And User types "Automated Test Description" in "Description"
And User selects "Citizens Services" in "Ministry"
Expand All @@ -14,9 +14,9 @@ Feature: Requests Review
And User clicks tab "Common components"
And User checks checkbox "The app does not use..."
And User makes a screenshot
And User clicks button "SUBMIT REQUEST"
And User checks checkbox "By checking this box..."
And User clicks button "Submit"
And User checks checkbox "By checking this box..."
And User clicks modal window button "Submit"
And User clicks modal window button "Close"
Then User should be redirected to Requests tab
And User should see "Automated Test Product Name"
Expand All @@ -29,7 +29,7 @@ Scenario: Approval Admin reviews New Request
And User clicks tab "Requests"
And User waits for "3" seconds
And User clicks link "Automated Test Product Name"
And User clicks button "APPROVE REQUEST"
And User clicks button "Approve"
And User clicks modal window button "Submit"
And User clicks modal window button "Return to Dashboard"
And User clicks tab "Products"
Expand All @@ -41,7 +41,7 @@ Scenario: Approval Admin reviews Edit Request
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
When User clicks link "Automated Test Product Name"
And User waits for "3" seconds
And User waits for "10" seconds
And User types "Automated Test Edit Request" in "Product name"
And User types "Automated Test Description Edit" in "Description"
And User selects "Finance" in "Ministry"
Expand Down Expand Up @@ -82,9 +82,9 @@ Scenario: Approval Admin reviews Edit Request
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User waits for "3" seconds
And User clicks tab "Requests"
And User waits for "3" seconds
And User waits for "10" seconds
And User clicks link "Automated Test Edit Request"
And User clicks button "APPROVE REQUEST"
And User clicks button "Approve"
And User clicks modal window button "Submit"
And User clicks modal window button "Return to Dashboard"
And User clicks tab "Products"
Expand All @@ -94,10 +94,37 @@ Scenario: Approval Admin reviews Edit Request
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks link "Automated Test Edit Request"
And User waits for "5" seconds
Then User sees "Automated Test Edit Request" in "Product name"
And User sees "Automated Test Description Edit" in "Description"
And User sees "FIN" in "Ministry"
And User clicks tab "Team contacts"
And User sees "david.johnson@gov.bc.ca" in "Product Owner email"
And User sees "sarah.williams@gov.bc.ca" in "Technical Lead email"
And User logs out

Scenario: Approval Admin reviews Delete Request
When User logs in with username "david.johnson@gov.bc.ca" and password "david.johnson@gov.bc.ca"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks link "Automated Test Edit Request"
And User waits for "10" seconds
And User clicks button "Delete"
And User copies value of "Licence plate"
And User pastes from clipboard to "Licence plate number"
And User copies value of "Product Owner"
And User pastes from clipboard to "Product owner email"
And User clicks modal window button "Submit"
And User clicks button "Close"
And User clicks tab "Requests"
Then User should see "Automated Test Edit Request"
And User should see badge "DELETE"
And User logs out
When User logs in with username "private.reviewer.system@gov.bc.ca" and password "private.reviewer.system@gov.bc.ca"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User waits for "3" seconds
And User clicks tab "Requests"
And User waits for "10" seconds
And User clicks link "Automated Test Edit Request"
And User waits for "5" seconds
And User clicks button "Approve"
And User clicks modal window button "Submit"
And User clicks modal window button "Return to Dashboard"
And User clicks tab "Products"
Then User should not see "Automated Test Edit Request"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Edit Request
Scenario: Create Private Cloud Edit Request and check visibility
Given User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
When User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks button "REQUEST A NEW PRODUCT"
And User clicks button "Request a new product"
And User types "Automated Test Product Name" in "Product name"
And User types "Automated Test Description" in "Description"
And User selects "Citizens Services" in "Ministry"
Expand All @@ -15,9 +15,9 @@ Feature: Edit Request
And User clicks tab "Common components"
And User checks checkbox "The app does not use..."
And User makes a screenshot
And User clicks button "SUBMIT REQUEST"
And User checks checkbox "By checking this box..."
And User clicks button "Submit"
And User checks checkbox "By checking this box..."
And User clicks modal window button "Submit"
And User clicks modal window button "Close"
Then User should be redirected to Requests tab
And User should see "Automated Test Product Name"
Expand All @@ -28,15 +28,15 @@ Feature: Edit Request
And User clicks tab "Requests"
And User waits for "3" seconds
And User clicks link "Automated Test Product Name"
And User clicks button "APPROVE REQUEST"
And User clicks button "Approve"
And User clicks modal window button "Submit"
And User clicks modal window button "Return to Dashboard"
And User logs out
And User logs in with username "james.smith@gov.bc.ca" and password "james.smith@gov.bc.ca"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
And User clicks tab "PRIVATE CLOUD OPENSHIFT"
When User clicks link "Automated Test Product Name"
And User waits for "3" seconds
And User waits for "10" seconds
And User types "Automated Test Edit Request" in "Product name"
And User types "Automated Test Description Edit" in "Description"
And User selects "Finance" in "Ministry"
Expand Down
49 changes: 47 additions & 2 deletions cypress/support/step_definitions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ When(/^User clicks link "(.*)"$/, (buttonText: string) => {
});

When(/^User types (?!.*\band selects\b)"(.*)" in "?(.*?)(?:\.\.\.)?"$/, (text: string, textFieldLabel: string) => {
cy.contains('label', textFieldLabel).parent().find('input, textarea').first().scrollIntoView().clear().type(text);
cy.contains('label', textFieldLabel)
.closest('.text-input, .textarea, .dollar-input')
.find('input, textarea')
.scrollIntoView()
.clear()
.type(text);
});

When(/^User types and selects "(.*)" in "(.*)"$/, (contactEmail: string, contactLabel: string) => {
Expand Down Expand Up @@ -118,17 +123,57 @@ When('User makes a screenshot', () => {

When(/^User sees "(.*)" in "?(.*?)(?:\.\.\.)?"$/, (text: string, textFieldLabel: string) => {
cy.contains('label', textFieldLabel)
.parent()
.parents()
.eq(2)
.find('input, textarea, select')
.first()
.scrollIntoView()
.should('have.value', text);
});

When(/^User copies value of "(.*)"$/, (elementLabel: string) => {
cy.get('section[role="dialog"]').then(($modal) => {
if ($modal.length) {
cy.get('div[aria-modal="true"], section[role="dialog"]')
.contains('p', elementLabel)
.parent()
.find('p')
.last()
.then((element) => {
const copiedText = element.text();
cy.wrap(copiedText).as('copiedText');
});
} else {
cy.contains('p', elementLabel)
.parent()
.find('p')
.last()
.then((element) => {
const copiedText = element.text();
cy.wrap(copiedText).as('copiedText');
});
}
});
});

When(/^User pastes from clipboard to "?(.*?)(?:\.\.\.)?"$/, (textfieldLabel) => {
cy.get('@copiedText').then((copiedText) => {
cy.get(`input[placeholder="${textfieldLabel}"]`).click().invoke('val', copiedText);
});
});

Then('User should be redirected to Requests tab', () => {
cy.contains('p', 'These requests are currently under admin review.').should('be.visible');
});

Then(/^User should see "(.*)"$/, (requestName: string) => {
cy.contains('span', requestName).should('be.visible');
});

Then(/^User should not see "(.*)"$/, (productName: string) => {
cy.contains('span', productName).should('not.exist');
});

Then(/^User should see badge "(.*)"$/, (badgeText: string) => {
cy.contains('span', badgeText).should('be.visible');
});

0 comments on commit ad7daf1

Please sign in to comment.