Skip to content

Commit

Permalink
Merge pull request #145 from poap-xyz/development
Browse files Browse the repository at this point in the history
claim poaps inside kiosk + adminpanel restyled
  • Loading branch information
arvee-init authored Oct 25, 2023
2 parents 8f92a1d + bae253b commit 55a206c
Show file tree
Hide file tree
Showing 76 changed files with 2,047 additions and 439 deletions.
34 changes: 12 additions & 22 deletions cypress/e2e/advanced-usage/1-view-and-claim-naive-and-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
// /////////////////////////////*/

const { eth_address, custom_base_url } = require( '../../fixtures/mock-data' )
const { get_claim_function_url, extract_challenge_from_url, extract_redirect_url } = require( '../../support/e2e' )
const request_options = {
headers: {
Host: new URL( Cypress.env( 'VITE_publicUrl' ) ).host
},
failOnStatusCode: false
}
const { get_claim_function_url, extract_challenge_from_url, extract_redirect_url, request_options } = require( '../../support/e2e' )

context( 'Advanced functionality works', () => {

Expand All @@ -18,8 +12,8 @@ context( 'Advanced functionality works', () => {
cy.create_kiosk( 'two', 'naive' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )
cy.get( '#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )

} )

Expand Down Expand Up @@ -155,23 +149,20 @@ context( 'Advanced functionality works', () => {
expect( redirect_url ).to.contain( eth_address )

} )


} )

it( 'Event 1: Deletes the event when clicked', function() {

cy.visit( this.event_1_secretlink )

cy.on( 'window:alert', response => {
expect( response ).to.contain( 'Deletion success' )
} )
cy.on( 'window:confirm', response => {
expect( response ).to.contain( 'Are you sure' )
} )
cy.get( '#deleteEvent' ).click()

cy.contains( 'Delete Kiosk' )

cy.contains( 'Delete POAP Kiosk' ).click()
cy.contains( 'Delete POAP Kiosk' )
cy.get( '#safelyDeleteButton' ).click()

cy.contains( 'Deletion success!' )

cy.url().should( 'eq', Cypress.config().baseUrl + '/' )
} )
Expand All @@ -184,8 +175,8 @@ context( 'Advanced functionality works', () => {
cy.create_kiosk( 'five', 'custombase' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )
cy.get( '#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )

} )

Expand Down Expand Up @@ -219,6 +210,7 @@ context( 'Advanced functionality works', () => {

// Check if POAP link supplies the expected user_address and base url
cy.contains( 'POAP link' ).invoke( 'text' ).then( text => {
cy.log( `POAP link: `, text )
expect( text ).to.satisfy( base => base.includes( eth_address ) )
expect( text ).to.satisfy( base => base.includes( custom_base_url ) )
} )
Expand All @@ -229,6 +221,4 @@ context( 'Advanced functionality works', () => {

} )



} )
13 changes: 4 additions & 9 deletions cypress/e2e/advanced-usage/2-leadgen-mode-view-and-claim.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
const random_code = `testing-${ Math.random() }`
const random_email = `${ Math.random() }@email.com`
const invalid_code = `a_code_is_never_longer_than_6_characters-${ Math.random() }`
const { get_claim_function_url } = require( '../../support/e2e' )
const request_options = {
headers: {
Host: new URL( Cypress.env( 'VITE_publicUrl' ) ).host
},
failOnStatusCode: false
}
const { get_claim_function_url, request_options } = require( '../../support/e2e' )

async function extract_challenge_from_url ( response ) {

cy.log( `Url from which to extract challenge: `, response )
Expand All @@ -28,8 +23,8 @@ context( "User can view and claim through static QR url", function() {
cy.create_kiosk( 'two', 'leadgen' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )
cy.get( '#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )

} )

Expand Down
64 changes: 37 additions & 27 deletions cypress/e2e/user-admin/2-event-creation-and-deletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ context( 'Organiser successful event creation', () => {
expect( val ).to.include( 'Test Event' )
} )

// const tomorrow = new Date( Date.now() + 1000 * 60 * 60 * 24 )
// let month = tomorrow.getUTCMonth() + 1
// month = `${ month }`.length == 1 ? `0${ month }` : month
// let day = tomorrow.getDate()
// day = `${ day }`.length == 1 ? `0${ day }` : day
// const YMD = `${ tomorrow.getFullYear() }-${ month }-${ day }`
// cy.get( 'input#event-create-date' ).should( 'have.value', YMD )

const tomorrow = new Date( Date.now() + 1000 * 60 * 60 * 24 )
let month = tomorrow.getUTCMonth() + 1
month = `${ month }`.length == 1 ? `0${ month }` : month
let day = tomorrow.getDate()
day = `${ day }`.length == 1 ? `0${ day }` : day
const YMD = `${ tomorrow.getFullYear() }-${ month }-${ day }`
cy.get( 'input#event-create-date' ).should( 'have.value', YMD )
tomorrow.setUTCHours( 0, 0, 0, 0 ) // Set time to midnight UTC
const month = ( tomorrow.getUTCMonth() + 1 ).toString().padStart( 2, '0' )
const day = tomorrow.getUTCDate().toString().padStart( 2, '0' )
const expectedDate = `${ tomorrow.getUTCFullYear() }-${ month }-${ day }`

cy.get( 'input#event-create-date' )
.invoke( 'val' )
.should( 'eq', expectedDate )

cy.contains( 'Create Kiosk' )

Expand Down Expand Up @@ -90,15 +100,19 @@ context( 'Organiser successful event creation', () => {
const val = input.val()
expect( val ).to.include( 'Test Event' )
} )

const tomorrow = new Date( Date.now() + 1000 * 60 * 60 * 24 )
let month = tomorrow.getUTCMonth() + 1
month = `${ month }`.length == 1 ? `0${ month }` : month
let day = tomorrow.getDate()
day = `${ day }`.length == 1 ? `0${ day }` : day
const YMD = `${ tomorrow.getFullYear() }-${ month }-${ day }`
cy.get( 'input#event-create-date' ).should( 'have.value', YMD )

const tomorrow = new Date( Date.now() + 1000 * 60 * 60 * 24 )
const month = ( tomorrow.getUTCMonth() + 1 ).toString().padStart( 2, '0' )
const day = tomorrow.getUTCDate().toString().padStart( 2, '0' )
const expectedDate = `${ tomorrow.getUTCFullYear() }-${ month }-${ day }`

cy.get( 'input#event-create-date' )
.invoke( 'val' )
.then( ( inputDate ) => {
const inputDateObject = new Date( inputDate )
const expectedDateObject = new Date( expectedDate )
expect( inputDateObject ).to.be.at.least( expectedDateObject )
} )
cy.contains( 'Create Kiosk' )

} )
Expand Down Expand Up @@ -147,33 +161,29 @@ context( 'Organiser successful event creation', () => {
cy.contains( 'Creating POAP Kiosk' )
cy.url().should( 'include', '/event/admin' )

cy.contains( 'Your public POAP Kiosk link' )
cy.contains( 'Your secret admin link' )
cy.contains( 'Admin panel for' )
cy.contains( 'Admin link:' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )

} )

it( 'Deletes the event when clicked', function() {

cy.visit( this.event_1_secretlink )

cy.on( 'window:alert', response => {
expect( response ).to.contain( 'Deletion success' )
} )
cy.on( 'window:confirm', response => {
expect( response ).to.contain( 'Are you sure' )
} )
cy.get( '#deleteEvent' ).click()

cy.contains( 'Delete POAP Kiosk' ).click()
cy.contains( 'Delete POAP Kiosk' )
cy.contains( 'Delete Kiosk' )

cy.get( '#safelyDeleteButton' ).click()

cy.contains( 'Deletion success!' )

cy.url().should( 'eq', Cypress.config().baseUrl + '/' )

// Wait for firestore to delete old codes
cy.wait( 2000 )

} )

} )
87 changes: 48 additions & 39 deletions cypress/e2e/user-claimer/1-view-and-claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
// Event creation page
// /////////////////////////////*/

const admin = require( '../../fixtures/admin-user' )
const { get_claim_function_url, check_if_code_is_expected } = require( '../../support/e2e' )
const { get_claim_function_url, check_if_code_is_expected, request_options } = require( '../../support/e2e' )
const twoCodes = require( `../../fixtures/two-correct-codes${ Cypress.env( 'LOCAL' ) ? '' : '-ci' }` )
const fiveCodes = require( `../../fixtures/five-correct-codes${ Cypress.env( 'LOCAL' ) ? '' : '-ci' }` )
const request_options = {
headers: {
Host: new URL( Cypress.env( 'VITE_publicUrl' ) ).host
},
failOnStatusCode: false
}

async function extract_challenge_from_url ( response ) {

Expand All @@ -37,8 +30,8 @@ context( 'Claimer can view valid events', () => {
cy.create_kiosk( 'two' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )
cy.get( '#admin-eventlink-public' ).invoke( 'val' ).as( 'event_1_publiclink' ).then( f => cy.log( this.event_1_publiclink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_1_secretlink' ).then( f => cy.log( this.event_1_secretlink ) )

} )

Expand Down Expand Up @@ -80,8 +73,7 @@ context( 'Claimer can view valid events', () => {

// Check if POAP link supplies one of the test codes
cy.get( '#loading_text' ).invoke( 'text' ).then( text => {
const [ base, code ] = text.split( '/claim/' )
expect( code ).to.satisfy( code => check_if_code_is_expected( code, twoCodes ) )
expect( text ).to.satisfy( mint_link => check_if_code_is_expected( mint_link, twoCodes ) )
} )

} )
Expand Down Expand Up @@ -128,12 +120,11 @@ context( 'Claimer can view valid events', () => {

// Check if POAP link supplies one of the test codes
cy.get( '#loading_text' ).invoke( 'text' ).then( text => {
const [ base, code ] = text.split( '/claim/' )
expect( code ).to.satisfy( coed => check_if_code_is_expected( code, twoCodes ) )
expect( text ).to.satisfy( mint_link => check_if_code_is_expected( mint_link, twoCodes ) )
} )

} )

// Visit public event link
cy.visit( this.event_1_publiclink )

Expand All @@ -154,13 +145,39 @@ context( 'Claimer can view valid events', () => {
// Visit the challenge link
cy.visit( `/claim/${ event_1_second_challenge }` )

// // Wait for code retreival
// Wait for code retreival
cy.contains( 'No more POAP' )

} )

} )

it( "Event 1: shows all codes available when admin requests code refresh", function() {

// Visit admin event link
cy.visit( this.event_1_secretlink )

// Open recalculation Modal and expect screen
cy.contains( 'Refresh counter' ).click()
cy.contains( 'Are you sure you want to refresh ' )

// Click recalculation button
cy.get( '#recalculateButton' ).click()

// Wait for recalculation to finish and expect success message
cy.contains( 'Recalculation succeeded' )

// Visit public event link
cy.visit( this.event_1_publiclink )

// Accept disclaimer
cy.get( '#event-view-accept-disclaimer' ).click()

// Expect all codes to be available, note: the behaviour of a refresh causing all codes to be available is CI-only, in production it checks against the API
cy.contains( '0 of 2 codes' )

} )

// /////////////////////////////
// Second event
// /////////////////////////////
Expand All @@ -170,8 +187,8 @@ context( 'Claimer can view valid events', () => {
cy.create_kiosk( 'five' )

// Save the event and admin links for further use
cy.get( 'input#admin-eventlink-public' ).invoke( 'val' ).as( 'event_2_publiclink' ).then( f => cy.log( this.event_2_publiclink ) )
cy.get( 'input#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_2_secretlink' ).then( f => cy.log( this.event_2_secretlink ) )
cy.get( '#admin-eventlink-public' ).invoke( 'val' ).as( 'event_2_publiclink' ).then( f => cy.log( this.event_2_publiclink ) )
cy.get( '#admin-eventlink-secret' ).invoke( 'val' ).as( 'event_2_secretlink' ).then( f => cy.log( this.event_2_secretlink ) )


} )
Expand Down Expand Up @@ -215,8 +232,7 @@ context( 'Claimer can view valid events', () => {

// Check if POAP link supplies one of the test codes
cy.get( '#loading_text' ).invoke( 'text' ).then( text => {
const [ base, code ] = text.split( '/claim/' )
expect( code ).to.satisfy( code => check_if_code_is_expected( code, fiveCodes ) )
expect( text ).to.satisfy( mint_link => check_if_code_is_expected( mint_link, fiveCodes ) )
} )

} )
Expand Down Expand Up @@ -264,24 +280,19 @@ context( 'Claimer can view valid events', () => {

} )



} )


it( 'Event 1: Deletes the event when clicked', function() {

cy.visit( this.event_1_secretlink )

cy.on( 'window:alert', response => {
expect( response ).to.contain( 'Deletion success' )
} )
cy.on( 'window:confirm', response => {
expect( response ).to.contain( 'Are you sure' )
} )
cy.get( '#deleteEvent' ).click()

cy.contains( 'Delete Kiosk' )

cy.contains( 'Delete POAP Kiosk' ).click()
cy.contains( 'Delete POAP Kiosk' )
cy.get( '#safelyDeleteButton' ).click()

cy.contains( 'Deletion success!' )

cy.url().should( 'eq', Cypress.config().baseUrl + '/' )
} )
Expand All @@ -290,15 +301,13 @@ context( 'Claimer can view valid events', () => {

cy.visit( this.event_2_secretlink )

cy.on( 'window:alert', response => {
expect( response ).to.contain( 'Deletion success' )
} )
cy.on( 'window:confirm', response => {
expect( response ).to.contain( 'Are you sure' )
} )
cy.get( '#deleteEvent' ).click()

cy.contains( 'Delete Kiosk' )

cy.get( '#safelyDeleteButton' ).click()

cy.contains( 'Delete POAP Kiosk' ).click()
cy.contains( 'Delete POAP Kiosk' )
cy.contains( 'Deletion success!' )

cy.url().should( 'eq', Cypress.config().baseUrl + '/' )
} )
Expand Down
Loading

0 comments on commit 55a206c

Please sign in to comment.