Skip to content

Commit

Permalink
testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sehrish30 committed Jul 23, 2023
1 parent ec81df1 commit 6b24212
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion appartment-cdk/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CDK_DEFAULT_ACCOUNT=275102385991
CDK_DEFAULT_REGION=us-east-2
CDK_DEFAULT_REGION=us-east-2

Binary file not shown.
31 changes: 18 additions & 13 deletions headlessBrowserTesting/client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ export const handleToken = (token) => async (dispatch) => {
};

export const submitBlog = (values, file, history) => async (dispatch) => {
const uploadConfig = await axios.get("/api/upload", {
params: {
fileType: file.type,
},
});
let uploadConfig;
if (file) {
uploadConfig = await axios.get("/api/upload", {
params: {
fileType: file.type,
},
});
}

const res = await axios.post("/api/blogs", {
...values,
imageUrl: uploadConfig.data.key,
imageUrl: uploadConfig ? uploadConfig.data.key : null,
});

// uploading file from client
await axios.put(uploadConfig.data.url, file, {
headers: {
// same file type required for s3
"Content-Type": file.type,
},
});
if (uploadConfig) {
// uploading file from client
await axios.put(uploadConfig.data.url, file, {
headers: {
// same file type required for s3
"Content-Type": file.type,
},
});
}

history.push("/blogs");
dispatch({ type: FETCH_BLOG, payload: res.data });
Expand Down
2 changes: 2 additions & 0 deletions headlessBrowserTesting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mongoose.connect(keys.mongoURI, {
useUnifiedTopology: true,
});

const app = express();

app.use(bodyParser.json());

// maintaining a session on incoming requests
Expand Down
2 changes: 1 addition & 1 deletion headlessBrowserTesting/routes/uploadRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (app) => {

const fileType = req.query.fileType;

const fileExt = fileType.substring(fileType.indexOf("/") + 1);
const fileExt = fileType?.substring(fileType.indexOf("/") + 1) ?? "";

const key = `${req.user.id}/${uuidv4()}.${fileExt}`;

Expand Down
2 changes: 1 addition & 1 deletion headlessBrowserTesting/tests/helpers/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CustomPage {

static async build() {
const browser = await puppeteer.launch({
headless: true,
headless: "new", // false if u want to see browser and inspect it
// tinker around settings of vm
args: ["--no-sandbox"],
});
Expand Down

0 comments on commit 6b24212

Please sign in to comment.