This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f722671
commit d908ca3
Showing
18 changed files
with
249 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Avoid commiting sensitive data | ||
cypress.env.json | ||
serviceAccount.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { defineConfig } from 'cypress' | ||
import admin from 'firebase-admin' | ||
import { plugin as cypressFirebasePlugin } from 'cypress-firebase' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3333', | ||
chromeWebSecurity: false, | ||
specPattern: 'cypress/e2e/**/*.spec.*', | ||
supportFile: false, | ||
setupNodeEvents(on, config) { | ||
cypressFirebasePlugin(on, config, admin) | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"TEST_UID": "0000000000000000000000000000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const Locators = { | ||
welcomeMessageRefreshButton: '[data-test=welcome-message-refresh-button]', | ||
welcomeMessageResult: '[data-test=welcome-message-result]', | ||
remoteMathInput: '[data-test=remote-math-input]', | ||
remoteMathSubmitButton: '[data-test=remote-math-submit-button]', | ||
remoteMathResultOutput: '[data-test=remote-math-result-output]', | ||
remoteMathResultWhen: '[data-test=remote-math-result-when]', | ||
} | ||
|
||
function normalizeNumberString(str: string) { | ||
return str.replace(/[^0-9.]/g, '') | ||
} | ||
|
||
context('API Test Page', () => { | ||
before(() => { | ||
cy.login() | ||
.visit('/api-test') | ||
}) | ||
|
||
context('Welcome Message', () => { | ||
it('Can refresh welcome message', () => { | ||
cy.intercept('POST', '/*/*/getWelcomeMessage') | ||
.as('getWelcomeMessage') | ||
|
||
// The refresh button for the welcome message should be visible | ||
cy.get(Locators.welcomeMessageRefreshButton) | ||
.should('be.visible') | ||
|
||
// Clicking the refresh button should trigger a request to the API | ||
cy.get(Locators.welcomeMessageRefreshButton) | ||
.click() | ||
.wait('@getWelcomeMessage') | ||
|
||
// The result should be visible | ||
cy.get(Locators.welcomeMessageResult) | ||
.should('be.visible') | ||
}) | ||
}) | ||
|
||
context('Remote Math', () => { | ||
it('Can get accurate results', () => { | ||
const inputs = [123, 456] | ||
|
||
cy.intercept('POST', '/*/*/calculateSquare') | ||
.as('calculateSquare') | ||
|
||
for (const input of inputs) { | ||
cy.get(Locators.remoteMathInput) | ||
.clear() | ||
.type(input.toString()) | ||
|
||
// Clicking the submit button should trigger a request to the API | ||
cy.get(Locators.remoteMathSubmitButton) | ||
.click() | ||
.wait('@calculateSquare') | ||
|
||
// The result should be visible | ||
cy.get(Locators.remoteMathResultWhen) | ||
.should('be.visible') | ||
cy.get(Locators.remoteMathResultOutput) | ||
.should('be.visible') | ||
.should((output) => { | ||
// The result should be accurate | ||
expect(normalizeNumberString(output.text())).to.eq((input * input).toString()) | ||
}) | ||
} | ||
}) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
context('Login', () => { | ||
it('Detects logging in', () => { | ||
cy.logout() | ||
.visit('/') | ||
.url() | ||
.should('eq', 'http://localhost:3333/') | ||
|
||
cy.get('[data-test=login-button]') | ||
.should('exist') | ||
|
||
// Login which app should detect | ||
cy.login() | ||
|
||
cy.get('[data-test=logout-button]') | ||
.should('exist') | ||
}) | ||
|
||
it('Can log out', () => { | ||
cy.get('[data-test=logout-button]') | ||
.should('exist') | ||
.click() | ||
|
||
cy.get('[data-test=login-button]') | ||
.should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import firebase from 'firebase/compat/app' | ||
import 'firebase/compat/auth' | ||
import 'firebase/compat/database' | ||
import 'firebase/compat/firestore' | ||
import { attachCustomCommands } from 'cypress-firebase' | ||
import { app } from '../../src/firebase/app.g' | ||
|
||
firebase.initializeApp({ | ||
...app.options, | ||
}) | ||
|
||
attachCustomCommands({ Cypress, cy, firebase }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "", | ||
"private_key_id": "", | ||
"private_key": "", | ||
"client_email": "", | ||
"client_id": "", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.