Fakultas Ilmu Komputer UI

Commit 97140fa2 authored by Shella Gabriella's avatar Shella Gabriella
Browse files

[CHORES] Fix Merge Conflict

parents efcd4c67 dd4a256a
Pipeline #81873 passed with stages
in 2 minutes and 56 seconds
......@@ -4,17 +4,20 @@ stages:
default:
before_script:
- npm cache clean --force
- npm rebuild
- rm -rf node_modules
- npm install
lint:
image: node:12.18.4
image: node:15.11.0
stage: lint
script:
- npm run lint
test:
image: node:12.18.4
image: node:15.11.0
stage: test
artifacts:
expire_in: 1 hour
......
This diff is collapsed.
......@@ -27,8 +27,10 @@
"react-moment": "^0.9.7",
"react-number-format": "^4.4.1",
"react-promise-tracker": "^2.1.0",
"react-text-mask": "^5.4.3",
"react-toastify": "^7.0.3",
"reactstrap": "^8.9.0"
"reactstrap": "^8.9.0",
"text-mask-addons": "^3.8.0"
},
"scripts": {
"start": "cross-env REACT_APP_BASE_URL=http://localhost:8000 parcel public/index.html",
......
......@@ -94,4 +94,31 @@ test("Test tanggal form required", async () => {
expect(formBatch.textContent).toContain(
"Tanggal berakhir tidak boleh kosong"
);
});
\ No newline at end of file
});
test("Test tanggal mulai lebih dari tanggal akhir", async () => {
const wrapper = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<TambahBatch />
</AuthContext.Provider>
);
const startDateMoment = moment("Fri Apr 17 2021 00:00:00 GMT+0700")
const endDateMoment = moment("Sat Apr 16 2021 00:00:00 GMT+0700")
const name_batch = wrapper.getByTestId("name-batch-input");
const start_date = wrapper.getByTitle("start-date-title");
const end_date = wrapper.getByTitle("end-date-title");
await act(async () => {
await fireEvent.input(name_batch, { target: { value: "test" } });
});
await act(async () => {
await fireEvent.input(start_date, { target: { value: startDateMoment } });
});
await act(async () => {
await fireEvent.input(end_date, { target: { value: endDateMoment } });
});
await act(async () => {
await fireEvent.submit(wrapper.getByTestId("submit-batch"));
});
const batch = wrapper.getByTestId("tambah-batch");
expect(batch.textContent).toContain("Tanggal mulai tidak boleh melebihi tanggal akhir!");
})
\ No newline at end of file
import { act, cleanup, fireEvent, render } from "@testing-library/react";
import AuthContext from "../../utils/contex";
import { waitFor } from "@testing-library/dom";
import React from "react";
import EditProduk from "../../page/produk/EditProduk";
import { matchers } from "@emotion/jest";
expect.extend(matchers);
beforeEach(() => {
fetch.resetMocks();
});
afterEach(cleanup);
test("Test edit produk renders", async () => {
fetch
.once(
JSON.stringify({
id: "3d403cd3-e356-4c15-9a86-8843333e2778",
code: "5VK6TY",
name: "a",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "celana",
price: "50000.00",
stock: 9,
image: null,
profit: "100000.00",
modal: "10.00",
total_profit: "0.00",
unit: "pcs",
})
)
.once(
JSON.stringify({
count: 4,
next: null,
previous: null,
results: [
{
id: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
name: "Baju",
image: null,
},
{
id: "69faa710-fbe2-45f1-98e8-f80d3c4c1bbe",
name: "Celana",
image: null,
},
{
id: "0664247c-d9ea-4e56-bb02-4b8463f9e14c",
name: "Mainan",
image: null,
},
{
id: "8c2c06e6-0ead-4b9a-8de1-37237fc6bdc9",
name: "Makanan",
image: null,
},
],
})
)
.once(
JSON.stringify({
count: 2,
next: null,
previous: null,
results: [
{
id: "1fac049f-592c-4c15-afe6-9e05a2ce1540",
name: "Baju Pergi",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
image: null,
},
{
id: "626aa022-50a7-4d3a-b658-79cb0f059b03",
name: "Baju Tidur",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
image: null,
},
{
id: "e44da96a-44e3-4e69-8346-bd1da7b8e41f",
name: "Kue",
category: "8c2c06e6-0ead-4b9a-8de1-37237fc6bdc9",
category_name: "Makanan",
image: null,
},
],
})
)
.once(
JSON.stringify({
id: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
name: "avengers endgame",
category: "0664247c-d9ea-4e56-bb02-4b8463f9e14c",
category_name: "Mainan",
image:
"https://industripilar-api-staging.s3.amazonaws.com/media/uploads/subcategories/1_txtcYocQEGtOFN33ZCTDbw.png",
})
)
.once(
JSON.stringify({
id: "3d403cd3-e356-4c15-9a86-8843333e2778",
code: "5VK6TY",
name: "a",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "celana",
price: "50000.00",
stock: 9,
image: null,
profit: "100000.00",
modal: "10.00",
total_profit: "0.00",
unit: "pcs",
}),
{
status: 200,
}
);
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<EditProduk />
</AuthContext.Provider>
);
const waitProduk = getByTestId("waiting-edit-produk");
expect(waitProduk.textContent).toContain("Fetching data..");
await waitFor(() => getByTestId("edit-produk"));
const name_produk = getByTestId("name-produk-input");
expect(name_produk.value).toEqual("a");
const descProduk = getByTestId("desc-produk-input");
expect(descProduk).toHaveAttribute("rows", "4");
const descProdukParent = getByTestId("desc-produk-input-parent");
expect(descProdukParent).toHaveStyleRule("height", "100%");
await act(async () => {
await fireEvent.input(name_produk, { target: { value: "test" } });
});
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
expect(fetch.mock.calls.length).toEqual(5);
});
test("Test edit produk renders error", async () => {
fetch
.once(
JSON.stringify({
id: "3d403cd3-e356-4c15-9a86-8843333e2778",
code: "5VK6TY",
name: "a",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "celana",
price: "50000.00",
stock: 9,
image: null,
profit: "100000.00",
modal: "10.00",
total_profit: "0.00",
unit: "pcs",
})
)
.once(
JSON.stringify({
count: 4,
next: null,
previous: null,
results: [
{
id: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
name: "Baju",
image: null,
},
{
id: "69faa710-fbe2-45f1-98e8-f80d3c4c1bbe",
name: "Celana",
image: null,
},
{
id: "0664247c-d9ea-4e56-bb02-4b8463f9e14c",
name: "Mainan",
image: null,
},
{
id: "8c2c06e6-0ead-4b9a-8de1-37237fc6bdc9",
name: "Makanan",
image: null,
},
],
})
)
.once(
JSON.stringify({
count: 2,
next: null,
previous: null,
results: [
{
id: "1fac049f-592c-4c15-afe6-9e05a2ce1540",
name: "Baju Pergi",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
image: null,
},
{
id: "626aa022-50a7-4d3a-b658-79cb0f059b03",
name: "Baju Tidur",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
image: null,
},
{
id: "e44da96a-44e3-4e69-8346-bd1da7b8e41f",
name: "Kue",
category: "8c2c06e6-0ead-4b9a-8de1-37237fc6bdc9",
category_name: "Makanan",
image: null,
},
],
})
)
.once(
JSON.stringify({
id: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
name: "avengers endgame",
category: "0664247c-d9ea-4e56-bb02-4b8463f9e14c",
category_name: "Mainan",
image:
"https://industripilar-api-staging.s3.amazonaws.com/media/uploads/subcategories/1_txtcYocQEGtOFN33ZCTDbw.png",
})
)
.once(
JSON.stringify({
id: "3d403cd3-e356-4c15-9a86-8843333e2778",
code: "5VK6TY",
name: "a",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "celana",
price: "50000.00",
stock: 9,
image: null,
profit: "100000.00",
modal: "10.00",
total_profit: "0.00",
unit: "pcs",
}),
{
status: 500,
}
);
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<EditProduk />
</AuthContext.Provider>
);
const waitProduk = getByTestId("waiting-edit-produk");
expect(waitProduk.textContent).toContain("Fetching data..");
await waitFor(() => getByTestId("edit-produk"));
const name_produk = getByTestId("name-produk-input");
expect(name_produk.value).toEqual("a");
const descProduk = getByTestId("desc-produk-input");
expect(descProduk).toHaveAttribute("rows", "4");
const descProdukParent = getByTestId("desc-produk-input-parent");
expect(descProdukParent).toHaveStyleRule("height", "100%");
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
expect(fetch.mock.calls.length).toEqual(5);
const bank = getByTestId("edit-produk");
expect(bank.textContent).toContain("Error !, Data tidak dapat disimpan");
});
import { cleanup, render } from "@testing-library/react";
import AuthContext from "../../utils/contex";
import React from "react";
import { waitFor } from "@testing-library/dom";
import ListProduk from "../../page/produk/ListProduk";
beforeEach(() => {
fetch.resetMocks();
});
afterEach(cleanup);
test("Test List produk", async () => {
fetch.mockResponseOnce(
JSON.stringify({
count: 23,
next: null,
previous: null,
results: [
{
id: "3d403cd3-e356-4c15-9a86-8843333e2778",
code: "5VK6TY",
name: "a",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "celana",
price: "50000.00",
stock: 9,
unit: "pcs",
image: null,
profit: "100000.00"
},
{
id: "9a0bccaa-70f6-48a8-89fc-5c5994684729",
code: "4QKSBC",
name: "Piyama",
category: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
category_name: "Baju",
subcategory: "626aa022-50a7-4d3a-b658-79cb0f059b03",
subcategory_name: "Baju Tidur hehe",
description: "piyama",
price: "50000.00",
stock: 14,
unit: "pcs",
image: null,
profit: "100000.00"
},
],
})
);
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "tester" } }}>
<ListProduk />
</AuthContext.Provider>
);
await waitFor(() => getByTestId("tableList"));
const data = getByTestId("tableList");
expect(data.textContent).toContain("Piyama");
expect(data.textContent).toContain("Rp 100.000");
expect(data.textContent).toContain("pcs");
expect(fetch.mock.calls.length).toEqual(1);
});
import { act, cleanup, fireEvent, render } from "@testing-library/react";
import { act, cleanup, fireEvent, render, waitFor } from "@testing-library/react";
import AuthContext from "../../utils/contex";
import React from "react";
import TambahProduk from "../../page/produk/TambahProduk";
......@@ -84,10 +84,24 @@ test("Test tambah produk renders", async () => {
await act(async () => {
await fireEvent.input(modal_produk, {target: { value: "1" } });
});
const stock_produk = getByTestId("stock-produk-input");
const tipe_hampers = getByTestId("is-hampers-2")
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await fireEvent.click(tipe_hampers, {target: {value: "true"}})
})
const price_hampers = getByTestId("hampers-price-input")
await act(async () => {
await fireEvent.input(price_hampers, { target: { value: "1" } });
})
const tipe_produk = getByTestId("is-preorder-input-2")
await act(async () => {
await fireEvent.click(tipe_produk, {target: {value: "false"}})
})
await waitFor(() => getByTestId("stock-produk-input")).then(async () => {
const stock_produk = getByTestId("stock-produk-input");
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
})
const unit_produk = getByTestId("unit-produk-input");
await act(async () => {
await fireEvent.input(unit_produk, { target: { value: "pcs" } });
......@@ -244,10 +258,24 @@ test("Test tambah produk error", async () => {
await act(async () => {
await fireEvent.input(modal_produk, {target: { value: "1" } });
});
const stock_produk = getByTestId("stock-produk-input");
const tipe_hampers = getByTestId("is-hampers-2")
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await fireEvent.click(tipe_hampers, {target: {value: "true"}})
})
const price_hampers = getByTestId("hampers-price-input")
await act(async () => {
await fireEvent.input(price_hampers, { target: { value: "1" } });
})
const tipe_produk = getByTestId("is-preorder-input-2")
await act(async () => {
await fireEvent.click(tipe_produk, {target: {value: "false"}})
})
await waitFor(() => getByTestId("stock-produk-input")).then(async () => {
const stock_produk = getByTestId("stock-produk-input");
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
})
const unit_produk = getByTestId("unit-produk-input");
await act(async () => {
await fireEvent.input(unit_produk, { target: { value: "pcs" } });
......@@ -339,10 +367,24 @@ test("Test modal produk required", async () => {
await act(async () => {
await fireEvent.input(modal_produk, {target: { value: "1" } });
});
const stock_produk = getByTestId("stock-produk-input");
const tipe_hampers = getByTestId("is-hampers-2")
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await fireEvent.click(tipe_hampers, {target: {value: "true"}})
})
const price_hampers = getByTestId("hampers-price-input")
await act(async () => {
await fireEvent.input(price_hampers, { target: { value: "1" } });
})
const tipe_produk = getByTestId("is-preorder-input-2")
await act(async () => {
await fireEvent.click(tipe_produk, {target: {value: "false"}})
})
await waitFor(() => getByTestId("stock-produk-input")).then(async () => {
const stock_produk = getByTestId("stock-produk-input");
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
})
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
......@@ -424,10 +466,24 @@ test("Test modal produk required", async () => {
await act(async () => {
await fireEvent.input(price_produk, { target: { value: "1" } });
});
const stock_produk = getByTestId("stock-produk-input");
const tipe_hampers = getByTestId("is-hampers-2")
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await fireEvent.click(tipe_hampers, {target: {value: "true"}})
})
const price_hampers = getByTestId("hampers-price-input")
await act(async () => {
await fireEvent.input(price_hampers, { target: { value: "1" } });
})
const tipe_produk = getByTestId("is-preorder-input-2")
await act(async () => {
await fireEvent.click(tipe_produk, {target: {value: "false"}})
})
await waitFor(() => getByTestId("stock-produk-input")).then(async () => {
const stock_produk = getByTestId("stock-produk-input");
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
})
const unit_produk = getByTestId("unit-produk-input");
await act(async () => {
await fireEvent.input(unit_produk, { target: { value: "pcs" } });
......@@ -437,73 +493,5 @@ test("Test modal produk required", async () => {
});
const formCategory = getByTestId("form-produk");
expect(formCategory.textContent).toContain("Modal tidak boleh kosong");
expect(fetch.mock.calls.length).toEqual(3);
});
test("Test tambah produk required marks", async () => {
fetch
.once(
JSON.stringify({
count: 4,
next: null,
previous: null,
results: [
{
id: "f0c08b4f-7421-4298-89e4-3d4a40ef15b4",
name: "Baju",
image: null,
},
{
id: "0664247c-d9ea-4e56-bb02-4b8463f9e14c",
name: "Mainan",
image: null,
},
{
id: "8c2c06e6-0ead-4b9a-8de1-37237fc6bdc9",
name: "Makanan",
image: null,
},
{
id: "b8a9909b-9131-4c2b-bcc5-6bceb18f702c",
name: "Minuman",
image: null,
},
],
})
)
.once(
JSON.stringify({
count: 7,
next: null,
previous: null,
results: [
{
id: "626aa022-50a7-4d3a-b658-79cb0f059b03",
name: "Baju Tidur hehe",