Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: initialize test & authorization system frontend test #75

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dfe6273
build: initialize cypress
boomchanotai Feb 20, 2024
4fc42bd
build: setup cypress
boomchanotai Feb 20, 2024
68aee32
refactor: improve for test
boomchanotai Feb 20, 2024
88e5319
test: authentication
boomchanotai Feb 20, 2024
0934441
Feat: add favorite
MichaelScodaeng Feb 6, 2024
68036cb
Refactor:code
MichaelScodaeng Feb 6, 2024
3235c19
Update index.tsx
MichaelScodaeng Feb 6, 2024
1fd644f
fix
MichaelScodaeng Feb 20, 2024
912a4a2
Fix: makes it works properly
MichaelScodaeng Feb 20, 2024
6a13836
fix:pnpm remove react-query
MichaelScodaeng Feb 20, 2024
fccd804
fix: lint:fix
MichaelScodaeng Feb 20, 2024
17f5485
fix: admin/filter not working
punchanabu Feb 20, 2024
8aed13d
fix: linter
punchanabu Feb 20, 2024
3ec6413
feat: QUery
ChanatpakornS Feb 19, 2024
86f3eda
fixed: casting type
ChanatpakornS Feb 19, 2024
5e89108
feat: query picture and text
ChanatpakornS Feb 20, 2024
43c59ea
feat: handle query picture
ChanatpakornS Feb 20, 2024
e8ad045
feat: fallback
ChanatpakornS Feb 20, 2024
34c149c
refactor: fallback
ChanatpakornS Feb 20, 2024
3bd0f34
merge dev
ChanatpakornS Feb 20, 2024
7e5d560
refactor: date & minor fallback
ChanatpakornS Feb 20, 2024
b8c20f6
fix: home responsive
boomchanotai Feb 20, 2024
0a6467c
fix: responsive
boomchanotai Feb 20, 2024
c264cef
fix: home flicker
boomchanotai Feb 20, 2024
d92562f
feat: implement fav system to card (#76)
boomchanotai Feb 20, 2024
d506447
refactor: change option value to english
ThanaphomH Feb 20, 2024
7385e06
build: initialize cypress
boomchanotai Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: "http://localhost:5173",
testIsolation: false,
},
});
58 changes: 58 additions & 0 deletions cypress/e2e/authentication.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
describe("authentication", () => {
it("can visit the site", () => {
cy.visit("/");
cy.wait(2000);
localStorage.clear();
});

it("can open sidebar", () => {
cy.get("#open-sidebar").click();
});

it("can navigate to login page", () => {
cy.get("a").contains("Admin Login").click();

cy.wait(1000);
cy.url().should("include", "/admin");
cy.get("h1").contains("เข้าสู่ระบบ");
});

it("can login", () => {
cy.wait(2000);
cy.get(`input[name="email"]`).type("[email protected]");
cy.get(`input[name="password"]`).type("12345678");
cy.get("button").contains("เข้าสู่ระบบ").click();

cy.wait(2000);
cy.url().should("include", "/admin/pets");
cy.get("#open-sidebar").click();
cy.get("button").contains("Logout").should("exist");
});

it("can logout", () => {
cy.get("button").contains("Logout").click();

cy.wait(1000);
cy.url().should("include", "/admin");
});

it("can navigate to forget password page", () => {
cy.get("a").contains("ลืมรหัสผ่าน?").click();

cy.wait(1000);
cy.url().should("include", "/admin/forget-password");
cy.get("h1").contains("ลืมรหัสผ่าน?");
});

it("can request forget password", () => {
cy.get(`input[name="email"]`).type("[email protected]");
cy.get("button").contains("รีเซตรหัสผ่าน").click();

cy.wait(1000);
cy.get("h2").contains("อีเมลรีเซ็ตถูกส่งแล้ว").should("exist");
cy.get("button").contains("กลับไปหน้าเข้าสู่ระบบ").click();

cy.wait(1000);
cy.url().should("include", "/admin");
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"],
},
"include": ["**/*.ts"],
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"cypress:open": "cypress open",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
Expand Down Expand Up @@ -39,6 +40,7 @@
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.16",
"cypress": "^13.6.4",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.0",
Expand Down
Loading