Skip to content

Commit

Permalink
Update UI and add BDD steps for Create Promotions
Browse files Browse the repository at this point in the history
  • Loading branch information
amandaulia committed Apr 11, 2024
1 parent 26bb63b commit 208e14d
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 95 deletions.
37 changes: 36 additions & 1 deletion features/promotions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,39 @@ Feature: The promotion store service back-end
Scenario: The server is running
When I visit the "Home Page"
Then I should see "promotion Demo RESTful Service" in the title
And I should not see "404 Not Found"
And I should not see "404 Not Found"

Scenario: Create a Promotion
When I visit the "Home Page"
And I set the "Promo Code" to "SUMMERSALE"
And I select "PERCENT" in the "Type" dropdown
And I set the "Value" to "25"
And I set the "Quantity" to "100"
And I set the "Start Date" to "05/01/2024"
And I set the "End Date" to "05/03/2024"
And I select "True" in the "Active" dropdown
And I set the "Product ID" to "9588"
And I press the "Create" button
Then I should see the message "Success"
When I copy the "Promo ID" field
And I press the "Clear" button
Then the "Promo ID" field should be empty
And the "Promo Code" field should be empty
And the "Type" field should be empty
And the "Value" field should be empty
And the "Quantity" field should be empty
And the "Start Date" field should be empty
And the "End Date" field should be empty
And the "Active" field should be empty
And the "Product ID" field should be empty
When I paste the "Promo ID" field
And I press the "Retrieve" button
Then I should see the message "Success"
And I should see "SUMMERSALE" in the "Promo Code" field
And I should see "Percent" in the "Type" dropdown
And I should see "25" in the "Value" field
And I should see "100" in the "Quantity" field
And I should see "05/01/2024" in the "Start Date" field
And I should see "05/03/2024" in the "End Date" field
And I should see "True" in the "Active" dropdown
And I should see "9588" in the "Product ID" field
92 changes: 60 additions & 32 deletions service/static/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>promotion Demo RESTful Service</title>
<title>Promotion Demo RESTful Service</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -11,7 +11,7 @@
<body>
<div class="container">
<div class="page-header">
<h1>promotion Demo REST API Service</h1>
<h1>Promotion Demo REST API Service</h1>
</div>

<!-- Flash Message -->
Expand All @@ -27,9 +27,9 @@ <h3>Create, Retrieve, Update, and Delete a promotion:</h3>
<div class="well">
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_id">promotion ID:</label>
<label class="control-label col-sm-2" for="promo_id">Promo ID:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="promotion_id" placeholder="Enter ID of promotion">
<input type="text" class="form-control" id="promo_id" placeholder="Enter ID of promotion">
</div>
<div class="col-sm-4">
<button type="submit" class="btn btn-primary" id="retrieve-btn">Retrieve</button>
Expand All @@ -40,53 +40,77 @@ <h3>Create, Retrieve, Update, and Delete a promotion:</h3>

<div class="form-horizontal">

<!-- NAME -->
<!-- PROMO CODE -->
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_name">Name:</label>
<label class="control-label col-sm-2" for="cust_promo_code">Promo Code:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="promotion_name" placeholder="Enter name for promotion">
<input type="text" class="form-control" id="cust_promo_code" placeholder="Enter code for promotion">
</div>
</div>

<!-- CATEGORY -->
<!-- TYPE -->
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_category">Category:</label>
<label class="control-label col-sm-2" for="type">Type:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="promotion_category" placeholder="Enter category for promotion">
<select class="form-control" id="type">
<option value="PERCENT" selected>Percent</option>
<option value="SAVING">Saving</option>
<option value="BOGO">Buy 1 Get 1</option>
</select>
</div>
</div>

<!-- AVAILABLE -->
<!-- VALUE -->
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_available">Available:</label>
<label class="control-label col-sm-2" for="value">Value:</label>
<div class="col-sm-10">
<select class="form-control" id="promotion_available">
<option value="true" selected>True</option>
<option value="false">False</option>
</select>
<input type="text" class="form-control" id="value" placeholder="Enter value for promotion">
</div>
</div>

<!-- GENDER -->
<!-- QUANTITY -->
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_gender">Gender:</label>
<label class="control-label col-sm-2" for="quantity">Quantity:</label>
<div class="col-sm-10">
<select class="form-control" id="promotion_gender">
<option value="UNKNOWN" selected>Unknown</option>
<option value="MALE">Male</option>
<option value="FEMALE">Female</option>
</select>
<input type="text" class="form-control" id="quantity" placeholder="Enter quantity for promotion">
</div>
</div>

<!-- START DATE -->
<div class="form-group">
<label class="control-label col-sm-2" for="start_date">Start Date:</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="start_date" placeholder="2020-04-01">
</div>
</div>

<!-- END DATE -->
<div class="form-group">
<label class="control-label col-sm-2" for="end_date">End Date:</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="end_date" placeholder="2020-04-01">
</div>
</div>

<!-- BIRTHDAY -->
<!-- ACTIVE -->
<div class="form-group">
<label class="control-label col-sm-2" for="promotion_birthday">Birthday:</label>
<label class="control-label col-sm-2" for="active">Active:</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="promotion_birthday" placeholder="2020-04-01">
<select class="form-control" id="active">
<option value="true" selected>True</option>
<option value="false">False</option>
</select>
</div>
</div>

<!-- PRODUCT ID -->
<div class="form-group">
<label class="control-label col-sm-2" for="product_id">Product ID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="product_id" placeholder="Enter Product ID for promotion">
</div>
</div>


<!-- SUBMIT BUTTONS -->
<div class="form-group">
Expand All @@ -106,12 +130,16 @@ <h3>Create, Retrieve, Update, and Delete a promotion:</h3>
<table class="table table-striped">
<thead>
<tr>
<th class="col-md-1">ID</th>
<th class="col-md-4">Name</th>
<th class="col-md-4">Category</th>
<th class="col-md-3">Available</th>
<th class="col-md-3">Gender</th>
<th class="col-md-3">Birthday</th>
<th class="col-md-1">Promo ID</th>
<th class="col-md-4">Promo Code</th>
<th class="col-md-4">Type</th>
<th class="col-md-3">Value</th>
<th class="col-md-3">Quantity</th>
<th class="col-md-3">Start Date</th>
<th class="col-md-3">End Date</th>
<th class="col-md-3">Active</th>
<th class="col-md-3">Product ID</th>
<th class="col-md-3">Created At</th>
</tr>
</thead>
</table>
Expand Down
Loading

0 comments on commit 208e14d

Please sign in to comment.