Skip to content

Instantly share code, notes, and snippets.

@rodmatola
rodmatola / inventory.js
Last active December 6, 2023 14:41
Dev.Pro
/*
Task 2: Inventory Management
Context: You are developing a simple inventory management system for a small store.
You need to create a function that takes a list of products with their names, prices, and stock levels, and returns a sorted list of products based on a given sort key (name, price, or stock) and order (ascending or descending).
Example Input:
products = [
{""name"": ""Product A"", ""price"": 100, ""stock"": 5},
{""name"": ""Product B"", ""price"": 200, ""stock"": 3},
CREDENCIAIS = {
'cpfs' => {
'leo' => ENV['LEOCPF'],
'dani' => ENV['DANICPF']
},
'senhas' => {
'leo' => ENV['LEOSENHA'],
'dani' => ENV['DANISENHA']
}
}.freeze
class LoginPage < SitePrism::Page
set_url ""
element :user_field, ""
element :password_field, ""
element :btn_login, ""
end
Given ("I am on the login screen") do
@login_page = LoginPage.new
@login_page.load
end
When ("I log in using {string}") do | user |
@login_page.user_field.set USER[user]
@login_page.password_field.set PASSWORD[user]
@login_page.btn_login.click
end
Given ("I am on the login screen") do
   pending # write code here that turns the phrase above into concrete actions
end
When ("I log in using {string}") do | string |
   pending # write code here that turns the phrase above into concrete actions
end
Then ("I should be directed to the main page") do
   pending # write code here that turns the phrase above into concrete actions
Feature: Successfull login
Background:
   Given I am on the login screen
Scenario: Successful login using username
   When I log in using "username"
   Then I should be directed to the main page
Scenario: Successful login using email
@rodmatola
rodmatola / login.po.rb
Last active June 17, 2018 18:29
Automação na Sprint: Como eu faço (tento)
class LoginPage < SitePrism::Page
set_url ""
element :campo_usuario, ""
element :campo_senha, ""
element :btn_login, ""
end
@rodmatola
rodmatola / login_steps.rb
Last active June 17, 2018 18:29
Automação na Sprint: Como eu faço (tento)
Dado("que estou na tela de login") do
@pagina_login = LoginPage.new
@pagina_login.load
end
Quando("realizo o login utilizando {string}") do |usuario|
@pagina_login.campo_usuario.set USUARIO[usuario]
@pagina_login.campo_senha.set SENHA[usuario]
@pagina_login.btn_login.click
end
@rodmatola
rodmatola / login_steps.rb
Last active June 16, 2018 21:21
Automação na Sprint: Como eu faço (tento)
Dado("que estou na tela de login") do
pending # Write code here that turns the phrase above into concrete actions
end
Quando("realizo o login utilizando {string}") do |string|
pending # Write code here that turns the phrase above into concrete actions
end
Então("devo ser direcionado à página principal") do
pending # Write code here that turns the phrase above into concrete actions
@rodmatola
rodmatola / login.feature
Last active June 16, 2018 21:21
Automação na Sprint: Como eu faço (tento)
Funcionalidade: login com sucesso
Contexto:
Dado que estou na tela de login
Cenário: login com sucesso utilizando username
Quando realizo o login utilizando "username"
Então devo ser direcionado à página principal
Cenário: login com sucesso utilizando email